Skip to content

added custom loader hook to resolve /opt/nodejs/ modules #1

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 13, 2020
Merged
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 v14.x/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM lambci/lambda-base:build

COPY bootstrap.c bootstrap.js package.json /opt/
COPY bootstrap.c bootstrap.js package.json esm-loader-hook.mjs /opt/

ARG NODE_VERSION

Expand Down
1 change: 1 addition & 0 deletions v14.x/bootstrap.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ int main(void) {

execv("/opt/bin/node", (char *[]){
"node",
"--experimental-loader=/opt/esm-loader-hook.mjs",
"--expose-gc",
max_semi_space_size,
max_old_space_size,
Expand Down
10 changes: 10 additions & 0 deletions v14.x/esm-loader-hook.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export async function resolve(specifier, context, defaultResolve) {
try {
return await defaultResolve(specifier, {
...context,
parentURL: 'file:///opt/nodejs/'
}, defaultResolve)
} catch (err) {
return await defaultResolve(specifier, context, defaultResolve)
}
}
Binary file modified v14.x/layer.zip
Binary file not shown.