Description
Describe the bug
zipFunction w/ esbuild (nodeBundler) does not bundle npm library @aws-sdk/client-s3
.
instead, it just includes the import statement in the output bundle file:
also adding @aws-sdk/client-s3 to the externalNodeModules option does not include the node_module in the output folder.
Steps to reproduce
-
create new folder and npm init, change to "type": "module" in package.json.
-
install @aws-sdk/client-s3, and @netlify/zip-it-and-ship-it
-
create simple index.js file that imports and logs @aws-sdk/client-s3
import sdk from '@aws-sdk/client-s3'; const a = () => { console.log('sdk', sdk) } export default a;
-
create zipit.js file that calls zipFunction with zipConfig
import { zipFunction } from '@netlify/zip-it-and-ship-it'; const zipConfig = { nodeBundler: 'esbuild', externalNodeModules: ['@aws-sdk/client-s3'] }; zipFunction('index.js', 'zip-out', { archiveFormat: 'none', config: { '*': zipConfig, }, }); };
5. open output file zip-out/index/index.mjs
`
import {createRequire as ___nfyCreateRequire} from "module";
import {fileURLToPath as ___nfyFileURLToPath} from "url";
import {dirname as ___nfyPathDirname} from "path";
let __filename=___nfyFileURLToPath(import.meta.url);
let __dirname=___nfyPathDirname(___nfyFileURLToPath(import.meta.url));
let require=___nfyCreateRequire(import.meta.url);
// index.js
import sdk from "@aws-sdk/client-s3";
var a = () => {
console.log("sdk", sdk);
};
var testy_default = a;
export {
testy_default as default
};
`
Result: The @aws-sdk/client-s3 is not bundled, nor is it included in any parallel node_modules in the zip-out
folder.
CLI command and flags
node zipit.js
Configuration
No response
CLI output
this is the output of the zipFunction // zip-out/index/index.mjs
`
import {createRequire as ___nfyCreateRequire} from "module";
import {fileURLToPath as ___nfyFileURLToPath} from "url";
import {dirname as ___nfyPathDirname} from "path";
let __filename=___nfyFileURLToPath(import.meta.url);
let __dirname=___nfyPathDirname(___nfyFileURLToPath(import.meta.url));
let require=___nfyCreateRequire(import.meta.url);
// index.js
import sdk from "@aws-sdk/client-s3";
var a = () => {
console.log("sdk", sdk);
};
var testy_default = a;
export {
testy_default as default
};
`
Environment
System:
OS: macOS 14.2.1
CPU: (16) x64 Intel(R) Core(TM) i9-9980HK CPU @ 2.40GHz
Memory: 773.20 MB / 32.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.17.0 - ~/.nvm/versions/node/v18.17.0/bin/node
npm: 9.6.7 - ~/.nvm/versions/node/v18.17.0/bin/npm
pnpm: 8.6.12 - ~/Library/pnpm/pnpm
bun: 1.0.6 - ~/.bun/bin/bun