Parcel doesn't seem to know that async_hooks is a Node.js builtin when bundling with --target node.
parcel build src/index.js --target node --bundle-node-modules
A require('async_hooks') should be left as-is.
An error is thrown.
馃毃 /app/node_modules/cls-hooked/context.js:7:28: Cannot resolve dependency 'async_hooks'
5 | const assert = require('assert');
6 | const wrapEmitter = require('emitter-listener');
> 7 | const async_hooks = require('async_hooks');
| ^
8 |
9 | const CONTEXTS_SYMBOL = 'cls@contexts';
10 | const ERROR_SYMBOL = 'error@context';
Add it to node-libs-browser?
require('async_hooks');
| Software | Version(s) |
| ---------------- | ---------- |
| Parcel | 1.12.3
| Node | 12.1.0 alpine
| npm/Yarn | [email protected]
| Operating System | Linux 1e250ea9327f 4.9.125-linuxkit
I'm going to merge this with #2921, where http2 was also reported to be missing in node-libs-browser. It looks like we'll have to create our own version of that package because was actually deprecated a few days ago.
http2 might be fixed by #2921 -> #3620 but does it fix async_hooks? I can't get v2 (where the PR went) to test it and the current version does not work still; therefore this issue should not really be closed until it is actually fixed and available to the public (either as release or beta) imho.
That PR fixes uses the list from Node's native require("module").builtinModules in addition to the list from node-libs-browser. So that includes async_hooks.
This is released in 2.0.0-alpha.2.1, so you get the fix via the published parcel@next.
(And I would argue that the issue tracker exists primarily to track existing bugs that need to be fixed)
@mischnic My apologies, I did check npm for a v2 tag/release but could not see one and therefore thought that it was not available. Now that you have stated it can be retrieved by using parcel@next then it is available to the public now and I'd absolutely agree this should no longer be a bug and rightly so should be closed.
This keeps failing with --bundle-node-modules. When i try to
yarn add bluebird
yarn parcel build src/index.js --target node --bundle-node-modules
Error:
node_modules/bluebird/js/release/promise.js:34:12: Cannot resolve dependency 'async_hooks'
32 | };
33 | var AsyncResource = util.isNode && util.nodeSupportsAsyncResource ?
> 34 | require("async_hooks").AsyncResource : null;
| ^
35 | var getContextAsyncHooks = function() {
36 | return {
37 | domain: getDomain(),
This is only fixed in Parcel 2, not in Parcel 1.x.
Is there any possible workaround for the 1.x branch - I'm stuck with parcel 1.x, because it is a dependency of @aws-cdk/aws-lambda-nodejs ?
Most helpful comment
Is there any possible workaround for the 1.x branch - I'm stuck with parcel 1.x, because it is a dependency of @aws-cdk/aws-lambda-nodejs ?