Derek Kershner
02/08/2022, 5:38 PM{"errorType":"Error","errorMessage":"Dynamic require of \"stream\" is not supported","stack":["Error: Dynamic require of \"stream\" is not supported"," at file:///var/task/src/api/graphql/index.js:1:464"
I am not sure this is even the fault of the SST implementation, as it happens in AWS itself, but worth knowing perhaps.
I am not doing anything with stream
directly myself, so it must be inside apollo or another package.Derek Kershner
02/08/2022, 5:42 PMthdxr
02/08/2022, 6:01 PMthdxr
02/08/2022, 6:02 PMRoss Gerbasi
02/08/2022, 6:12 PMDerek Kershner
02/08/2022, 6:18 PMDerek Kershner
02/08/2022, 6:20 PMthdxr
02/08/2022, 6:21 PMimport { MyThing } from "./myfile"
it'll include all of myfile
and all of myfiles
imports.
It will not trace MyThing
and only import what MyThing references from what I could tellRoss Gerbasi
02/08/2022, 6:22 PMDerek Kershner
02/08/2022, 6:22 PM@mycompany/base-models
which has cognito, dynamo, etc in it. I needed it to shake the SDK for cognito. it did not.thdxr
02/08/2022, 6:22 PMthdxr
02/08/2022, 6:23 PM@acme/core
which my functions import from and I generally see treeshaking happening (just not to the ultimate degree like rollup does)Derek Kershner
02/08/2022, 6:23 PMimport {
AdminAddUserToGroupCommand,
AdminDeleteUserCommand,
CognitoIdentityProviderClient,
} from "@aws-sdk/client-cognito-identity-provider";
thdxr
02/08/2022, 6:23 PMthdxr
02/08/2022, 6:24 PMDerek Kershner
02/08/2022, 6:25 PMthdxr
02/08/2022, 6:25 PMnpx esbuild --analyze=verbose --target=esnext --platform=node --target=esnext --format=esm --bundle ./backend/functions/auth/events.ts
thdxr
02/08/2022, 6:25 PMRoss Gerbasi
02/08/2022, 6:25 PMDerek Kershner
02/08/2022, 6:26 PMDerek Kershner
02/08/2022, 6:26 PMDerek Kershner
02/08/2022, 6:26 PMthdxr
02/08/2022, 6:27 PMRoss Gerbasi
02/08/2022, 6:27 PMthdxr
02/08/2022, 6:27 PMRoss Gerbasi
02/08/2022, 6:28 PM@aws-sdk
to the external modules config for esbuild would be a no-go?Ross Gerbasi
02/08/2022, 6:28 PMDerek Kershner
02/08/2022, 6:28 PMDerek Kershner
02/08/2022, 6:29 PMthdxr
02/08/2022, 6:29 PMDerek Kershner
02/08/2022, 6:29 PMthdxr
02/08/2022, 6:29 PM"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
thdxr
02/08/2022, 6:30 PM"module": "dist/esm/index.js",
"main": "dist/cjs/index.js",
I don't know which of these makes it work but I have them all in thereDerek Kershner
02/08/2022, 6:30 PM"main": "dist/cjs/index.js",
Â
"module": "dist/esm/index.js",
Derek Kershner
02/08/2022, 6:30 PMDerek Kershner
02/08/2022, 6:31 PM"sideEffects": false,
as wellthdxr
02/08/2022, 6:31 PMexports
is the thing to useDerek Kershner
02/08/2022, 6:31 PMthdxr
02/08/2022, 6:32 PMthdxr
02/08/2022, 6:33 PMDerek Kershner
02/08/2022, 6:34 PMDerek Kershner
02/08/2022, 6:35 PMthdxr
02/08/2022, 6:35 PMThe default main fields depend on the current platform setting and are essentially browser,module,main for the browser and main,module for node.
thdxr
02/08/2022, 6:35 PMDerek Kershner
02/08/2022, 6:36 PMthdxr
02/08/2022, 6:36 PM--main-fields
Derek Kershner
02/08/2022, 6:37 PMthdxr
02/08/2022, 6:37 PMDerek Kershner
02/08/2022, 6:38 PMDerek Kershner
02/08/2022, 6:38 PMDerek Kershner
02/08/2022, 6:38 PMnode_modules/@aws-sdk/middleware-endpoint-discovery/dist-es/getCacheKey.js ──────────────────────────────────────────────────────── 16b ──── 0.0%
│ └ node_modules/@aws-sdk/middleware-endpoint-discovery/dist-es/endpointDiscoveryMiddleware.js
│ └ node_modules/@aws-sdk/middleware-endpoint-discovery/dist-es/getEndpointDiscoveryPlugin.js
│ └ node_modules/@aws-sdk/middleware-endpoint-discovery/dist-es/index.js
│ └ node_modules/@aws-sdk/client-dynamodb/dist-es/DynamoDBClient.js
│ └ node_modules/@aws-sdk/client-dynamodb/dist-es/index.js
│ └ src/lib/dynamo/client.ts
│ └ src/lib/graphql/dataLoaders/commonDataLoaderModelProps.ts
Ross Gerbasi
02/08/2022, 6:39 PMnode_modules/@serverless-stack/core/dist/runtime/handler/node.js
just hack it in and see what you're getting out?Ross Gerbasi
02/08/2022, 6:43 PMthdxr
02/08/2022, 6:43 PMmain,module
. I do remember I removed the main
file for one of my libraries and it started to pickup the esm oneRoss Gerbasi
02/08/2022, 6:44 PMthdxr
02/08/2022, 6:44 PMDerek Kershner
02/08/2022, 6:44 PMDerek Kershner
02/08/2022, 6:45 PMconst result = await esbuild.build({
...config,
plugins: plugins ? require(plugins) : undefined,
metafile: true,
minify: false,
incremental: true,
});
Derek Kershner
02/08/2022, 6:45 PMthdxr
02/08/2022, 6:45 PMconst config =
Derek Kershner
02/08/2022, 6:45 PMconst config = {
loader: bundle.loader,
minify: bundle.minify,
define: (_a = bundle.esbuildConfig) === null || _a === void 0 ? void 0 : _a.define,
keepNames: (_b = bundle.esbuildConfig) === null || _b === void 0 ? void 0 : _b.keepNames,
entryPoints: [path_1.default.join(opts.srcPath, file)],
bundle: opts.bundle !== false,
external: [
...(bundle.format === "esm" ? [] : ["aws-sdk"]),
...(bundle.externalModules || []),
...(bundle.nodeModules || []),
],
sourcemap: true,
platform: "node",
...(bundle.format === "esm"
? {
target: "esnext",
format: "esm",
banner: {
js: [
`import { createRequire as topLevelCreateRequire } from 'module'`,
`const require = topLevelCreateRequire(import.meta.url)`,
].join("\n"),
},
}
: {
target: "node14",
format: "cjs",
}),
outfile: target,
};
thdxr
02/08/2022, 6:45 PMRoss Gerbasi
02/08/2022, 6:46 PMDerek Kershner
02/08/2022, 6:46 PMmainFields: "module"
?thdxr
02/08/2022, 6:46 PMthdxr
02/08/2022, 6:46 PMDerek Kershner
02/08/2022, 6:47 PMDerek Kershner
02/08/2022, 6:47 PMDerek Kershner
02/08/2022, 6:50 PMthdxr
02/08/2022, 6:50 PMDerek Kershner
02/08/2022, 6:50 PMRoss Gerbasi
02/08/2022, 6:50 PMDerek Kershner
02/08/2022, 6:51 PM"Cannot use GraphQLSchema
LOTS HERE
from another module or realm.\n\nEnsure that there is only one instance of \"graphql\" in the node_modules\ndirectory. If different versions of \"graphql\" are the dependencies of other\nrelied on modules, use \"resolutions\" to ensure only one version is installed.\n\n<https://yarnpkg.com/en/docs/selective-version-resolutions>\n\nDuplicate \"graphql\" modules cannot be used at the same time since different\nversions may have different capabilities and behavior. The data from one\nversion used in the function from another could produce confusing and\nspurious results.
Derek Kershner
02/08/2022, 6:52 PMDerek Kershner
02/08/2022, 6:54 PMsst
package clash, I think you guys install the same as me, thoughDerek Kershner
02/08/2022, 6:55 PMDerek Kershner
02/08/2022, 6:56 PMDerek Kershner
02/08/2022, 6:59 PM.mjs
files, but SOME things are still using .js
, that is probably the problemRoss Gerbasi
02/08/2022, 7:00 PMDerek Kershner
02/08/2022, 7:00 PMDerek Kershner
02/08/2022, 7:00 PMDerek Kershner
02/08/2022, 7:01 PMDerek Kershner
02/08/2022, 7:01 PMRoss Gerbasi
02/08/2022, 7:02 PMDerek Kershner
02/08/2022, 7:03 PMDerek Kershner
02/08/2022, 7:03 PMDerek Kershner
02/08/2022, 7:04 PMthdxr
02/08/2022, 7:09 PMthdxr
02/08/2022, 7:09 PMShadab
03/21/2022, 4:44 PMserverless-stack/node
but even after trying for many hours wasn't able to get it workingShadab
03/21/2022, 4:48 PMDerek Kershner
03/21/2022, 4:50 PMDerek Kershner
03/21/2022, 4:51 PMDerek Kershner
03/21/2022, 4:53 PMShadab
03/21/2022, 4:57 PM{
errorType: 'Runtime.UnhandledPromiseRejection',
errorMessage:
'Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: undefined, astNode: undefined, extensionASTNodes: [], _queryType: Query, _mutationType: Mutation, _subscriptionType: undefined, _directives: [@cacheControl, @include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, Mutation: Mutation, CreateUserInput: CreateUserInput, User: User, CacheControlScope: CacheControlScope, Upload: Upload, Int: Int, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed.<https://yarnpkg.com/en/docs/selective-version-resolutionsDuplicate> "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.',
reason:
'Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: undefined, astNode: undefined, extensionASTNodes: [], _queryType: Query, _mutationType: Mutation, _subscriptionType: undefined, _directives: [@cacheControl, @include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, Mutation: Mutation, CreateUserInput: CreateUserInput, User: User, CacheControlScope: CacheControlScope, Upload: Upload, Int: Int, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.Ensure that there is only one instance of "graphql" in the node_modules directory. If different versions of "graphql" are the dependencies of other relied on modules, use "resolutions" to ensure only one version is installed.<https://yarnpkg.com/en/docs/selective-version-resolutionsDuplicate> "graphql" modules cannot be used at the same time since different versions may have different capabilities and behavior. The data from one version used in the function from another could produce confusing and spurious results.',
promise: {},
stack: [
'Runtime.UnhandledPromiseRejection: Error: Cannot use GraphQLSchema "{ __validationErrors: undefined, description: undefined, extensions: undefined, astNode: undefined, extensionASTNodes: [], _queryType: Query, _mutationType: Mutation, _subscriptionType: undefined, _directives: [@cacheControl, @include, @skip, @deprecated, @specifiedBy], _typeMap: { Query: Query, String: String, Mutation: Mutation, CreateUserInput: CreateUserInput, User: User, CacheControlScope: CacheControlScope, Upload: Upload, Int: Int, Boolean: Boolean, __Schema: __Schema, __Type: __Type, __TypeKind: __TypeKind, __Field: __Field, __InputValue: __InputValue, __EnumValue: __EnumValue, __Directive: __Directive, __DirectiveLocation: __DirectiveLocation }, _subTypeMap: {}, _implementationsMap: {} }" from another module or realm.',
'',
'Ensure that there is only one instance of "graphql" in the node_modules',
'directory. If different versions of "graphql" are the dependencies of other',
'relied on modules, use "resolutions" to ensure only one version is installed.',
'',
'<https://yarnpkg.com/en/docs/selective-version-resolutions>',
'',
'Duplicate "graphql" modules cannot be used at the same time since different',
'versions may have different capabilities and behavior. The data from one',
'version used in the function from another could produce confusing and',
'spurious results.',
' at process.<anonymous> (file:///home/MYPC/Desktop/Freelancing/backend/node_modules/@serverless-stack/aws-lambda-ric/lib/index.js:34:23)',
' at process.emit (events.js:376:20)',
' at processPromiseRejections (internal/process/promises.js:245:33)',
' at processTicksAndRejections (internal/process/task_queues.js:96:32)',
],
}
Shadab
03/21/2022, 5:00 PMthdxr
03/21/2022, 5:35 PMShadab
03/21/2022, 5:56 PMapollo-lambada-server
version of graphql is conflicting,Shadab
03/21/2022, 5:57 PMthdxr
03/21/2022, 6:06 PMthdxr
03/21/2022, 6:06 PMShadab
03/21/2022, 6:13 PMthdxr
03/21/2022, 6:14 PM