-
Notifications
You must be signed in to change notification settings - Fork 7
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
Bundling with pkg #104
Comments
using $ esbuild bin.js --platform=node --outfile=esbin.cjs --bundle
▲ [WARNING] "import.meta" is not available with the "cjs" output format and will be empty [empty-import-meta]
lib.js:27:62:
27 │ return JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url)))
╵ ~~~~~~~~~~~
You need to set the output format to "esm" for "import.meta" to work correctly.
1 warning
esbin.cjs 1.7mb ⚠️
⚡ Done in 68ms
$ node esbin.cjs
node:internal/modules/cjs/loader:1080
throw err;
^
Error: Cannot find module './fetch.node'
Require stack:
- /Users/oli/Code/web3-storage/w3cli/esbin.cjs
at Module._resolveFilename (node:internal/modules/cjs/loader:1077:15)
at Module._load (node:internal/modules/cjs/loader:922:27)
at Module.require (node:internal/modules/cjs/loader:1143:19)
at require (node:internal/modules/cjs/helpers:119:18)
at node_modules/ipfs-utils/src/http/fetch.js (/Users/oli/Code/web3-storage/w3cli/esbin.cjs:15766:18)
at __require (/Users/oli/Code/web3-storage/w3cli/esbin.cjs:10:51)
at Object.<anonymous> (/Users/oli/Code/web3-storage/w3cli/esbin.cjs:45202:28)
at Module._compile (node:internal/modules/cjs/loader:1256:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
at Module.load (node:internal/modules/cjs/loader:1119:32) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/Users/oli/Code/web3-storage/w3cli/esbin.cjs' ]
}
Node.js v18.18.0 but of note, pkg much happier to compile it (notice the different node version in the error, such magic) $ pkg esbin.cjs
> [email protected]
> Targets not specified. Assuming:
node18-linux-arm64, node18-macos-arm64, node18-win-arm64
> Warning Cannot resolve 'implName'
/Users/oli/Code/web3-storage/w3cli/esbin.cjs
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
❯ ./esbin-macos
pkg/prelude/bootstrap.js:1872
throw error;
^
Error: Cannot find module './fetch.node'
Require stack:
- /snapshot/w3cli/esbin.cjs
1) If you want to compile the package/file into executable, please pay attention to compilation warnings and specify a literal in 'require' call. 2) If you don't want to compile the package/file into executable and want to 'require' it from filesystem (likely plugin), specify an absolute path in 'require' call using process.cwd() or process.execPath.
at Module._resolveFilename (node:internal/modules/cjs/loader:946:15)
at Function._resolveFilename (pkg/prelude/bootstrap.js:1951:46)
at Module._load (node:internal/modules/cjs/loader:787:27)
at Module.require (node:internal/modules/cjs/loader:1012:19)
at Module.require (pkg/prelude/bootstrap.js:1851:31)
at require (node:internal/modules/cjs/helpers:102:18)
at node_modules/ipfs-utils/src/http/fetch.js (/snapshot/w3cli/esbin.cjs)
at __require (/snapshot/w3cli/esbin.cjs)
at Object.<anonymous> (/snapshot/w3cli/esbin.cjs)
at Module._compile (pkg/prelude/bootstrap.js:1926:22) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/snapshot/w3cli/esbin.cjs' ],
pkg: true
}
Node.js v18.5.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
pkg
fails to bundlew3cli
.I'm using this issue to track
pkg
specific bundling issues, and will use #82 to track the more general bundling planThe text was updated successfully, but these errors were encountered: