Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
build:
working_directory: ~/aws-lambda-graphql
docker:
- image: circleci/node:10.17.0
- image: cimg/node:22.19.0
steps:
- checkout
- run:
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### [Unreleased](https://github.com/michalkvasnicak/aws-lambda-graphql/compare/aws-lambda-graphql@1.0.0-alpha.24...HEAD)

- Update AWS SDK to V3 and Babel configuration by [@pixelport](https://github.com/pixelport), see [#152](https://github.com/michalkvasnicak/aws-lambda-graphql/issues/152)

### [v1.0.0-alpha.24](https://github.com/michalkvasnicak/aws-lambda-graphql/compare/aws-lambda-graphql@1.0.0-alpha.23..aws-lambda-graphql@1.0.0-alpha.24) - 2021-12-21

- Added visibility to DynamoDBEventProcessor by [@dorsev](https://github.com/dorsev), see [#158](https://github.com/michalkvasnicak/aws-lambda-graphql/pull/158)
Expand Down
13 changes: 11 additions & 2 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
module.exports = {
presets: [
['@babel/preset-env', { targets: { node: 'current' } }],
[
'@babel/preset-env',
{
targets: { node: 'current' },
},
],
'@babel/preset-react',
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-proposal-class-properties'],
plugins: [
'@babel/plugin-transform-class-properties',
'@babel/plugin-transform-private-methods',
'@babel/plugin-transform-class-static-block',
],
};
35 changes: 35 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,38 @@
module.exports = {
projects: ['packages/*'],
// Global configuration for Jest v29 and AWS SDK v3 compatibility
testEnvironment: 'node',
preset: 'ts-jest',
transform: {
'^.+\\.(ts|tsx)$': [
'ts-jest',
{
useESM: false,
tsconfig: {
target: 'es2020',
module: 'commonjs',
strict: false,
noImplicitAny: false,
strictNullChecks: false,
},
},
],
'^.+\\.(js|jsx)$': 'babel-jest',
},
moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'],
extensionsToTreatAsEsm: [],
moduleNameMapper: {
// Map node: prefixed imports to their standard equivalents for Jest
'^node:(.*)$': '$1',
// Mock all AWS SDK v3 packages to use our mocks
'^@aws-sdk/(.*)$':
'<rootDir>/packages/aws-lambda-graphql/src/__mocks__/aws-sdk.ts',
'^@smithy/(.*)$':
'<rootDir>/packages/aws-lambda-graphql/src/__mocks__/aws-sdk.ts',
},
transformIgnorePatterns: [
// Allow transformation of AWS SDK packages if needed
'node_modules/(?!((@aws-sdk|@smithy)/.*\\.js$))',
],
testPathIgnorePatterns: ['/node_modules/', '/dist/'],
};
66 changes: 66 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/* eslint-disable */
// Jest setup file to handle Node.js built-in modules and AWS SDK v3 compatibility

// Mock Node.js built-in modules that cause issues with AWS SDK v3
const mockNodeModules = {
stream: require('stream'),
util: require('util'),
crypto: require('crypto'),
fs: require('fs'),
path: require('path'),
url: require('url'),
buffer: require('buffer'),
events: require('events'),
process: require('process'),
os: require('os'),
querystring: require('querystring'),
};

// Override module resolution for node: prefixed imports
const originalResolveFilename = require.resolve;
require.resolve = function (id, options) {
if (id.startsWith('node:')) {
const moduleName = id.slice(5); // Remove 'node:' prefix
if (mockNodeModules[moduleName]) {
return moduleName;
}
}
return originalResolveFilename.call(this, id, options);
};

// Set up global mocks for problematic AWS SDK imports
global.mockStream = mockNodeModules.stream;
global.mockUtil = mockNodeModules.util;

// Prevent AWS SDK from trying to access browser-specific globals
global.window = undefined;
global.document = undefined;

// Mock crypto.webcrypto which AWS SDK v3 sometimes tries to access
if (!global.crypto) {
global.crypto = mockNodeModules.crypto;
}

// Mock performance API that AWS SDK might use
if (!global.performance) {
global.performance = {
now: () => Date.now(),
mark: () => {},
measure: () => {},
};
}

// Suppress console warnings from AWS SDK about missing browser APIs
const originalConsoleWarn = console.warn;
console.warn = (...args) => {
const message = args.join(' ');
if (
message.includes('AWS SDK') ||
message.includes('@aws-sdk') ||
message.includes('@smithy') ||
message.includes('node:')
) {
return; // Suppress AWS SDK warnings
}
originalConsoleWarn.apply(console, args);
};
Loading