Last active
December 1, 2020 03:10
Revisions
-
thumphries revised this gist
Dec 1, 2020 . 1 changed file with 40 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -2,7 +2,19 @@ Repro attempt for https://github.com/apollographql/federation/issues/211 ## Summary ``` @apollo/gateway -> @apollo-server-lambda -> serverless-webpack ``` Expecting a single .js bundle that works when required from Node 12.x. Getting a single .js bundle that contains some busted webpacky bits: - requiring util (?) - reading local .wasm files at runtime ## Usage ```sh npm install @@ -18,3 +30,30 @@ Should spit out a module resolution error, like: Thrown: Error: Cannot find module 'util' ``` ## Getting past the require('util') error If you poke `node_modules/@apollo/query-planner-wasm/`, changing line 4: ``` const { TextDecoder } = require(String.raw`util`); ``` ... replacing with: ``` const { TextDecoder } = require('util'); ``` ... and rebuild, unzip, run again, you get the desired error: ``` ``` ## Guessing about wasm-pack It seems like this package is bundled with `wasm-pack -t nodejs`. This use case might expect `-t bundler` and some kind of `.wasm$` webpack loader? -
thumphries revised this gist
Dec 1, 2020 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,2 @@ build/ node_modules/ -
thumphries revised this gist
Dec 1, 2020 . 6 changed files with 8714 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1 +1,20 @@ # `@apollographql/federation#211` Repro attempt for https://github.com/apollographql/federation/issues/211 Usage: ```sh npm install npm run package cd build unzip lambda.zip node -e "require('.').main()" ``` Should spit out a module resolution error, like: ``` Thrown: Error: Cannot find module 'util' ``` This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,18 @@ import { ApolloGateway } from '@apollo/gateway'; import { ApolloServer } from 'apollo-server-lambda'; const gateway = new ApolloGateway({ serviceList: [{name: 'accounts', url: 'https://accounts.fake.com'}], }); const server = new ApolloServer({ gateway, subscriptions: false, }); const handler = server.createHandler(); export const main = async (event, context) => { return handler(event, context); }; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,21 @@ { "name": "gateway", "version": "0.0.0", "engines": { "node": ">=12.0.0" }, "devDependencies": { "serverless": "^2.13.0", "serverless-webpack": "^5.3.5", "webpack": "^5.6.0", "webpack-cli": "^4.2.0" }, "dependencies": { "@apollo/gateway": "^0.21.3", "apollo-server": "^2.19.0", "apollo-server-lambda": "^2.19.0" }, "scripts": { "package": "serverless package -v --package ./build" } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ service: lambda provider: name: aws region: us-west-2 runtime: nodejs12.x environment: LAMBDA_TASK_ROOT: true custom: webpack: webpackConfig: webpack.config.js plugins: - serverless-webpack functions: main: handler: index.main This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,16 @@ const path = require ('path'); const slsw = require ('serverless-webpack'); module.exports = { mode: 'production', entry: slsw.lib.entries, target: 'node', node: { __dirname: false, }, experiments: { asyncWebAssembly: true, }, }; -
thumphries created this gist
Dec 1, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ #