Skip to content
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鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'depAssets' of undefined #2300

Closed
rambo-panda opened this issue Nov 19, 2018 · 2 comments 路 Fixed by #2712
Closed

Cannot read property 'depAssets' of undefined #2300

rambo-panda opened this issue Nov 19, 2018 · 2 comments 路 Fixed by #2712

Comments

@rambo-panda
Copy link

rambo-panda commented Nov 19, 2018

馃悰 bug report

command: npx parcel build --experimental-scope-hoisting parcel/main.js

馃敠 Context

debug info _bundle_loader not found

[12:31:06]: 馃毃  Cannot read property 'depAssets' of undefined 
[12:31:06]:     at JSConcatPackager.resolveModule (<work_space>/node_modules/parcel-bundler/src/packagers/JSConcatPackager.js:551:19)
    at CallExpression (<work_space>/node_modules/parcel-bundler/src/scope-hoisting/concat.js:152:28)
    at NodePath._call (<work_space>/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (<work_space>/node_modules/@babel/traverse/lib/path/context.js:40:17)
    at NodePath.visit (<work_space>/node_modules/@babel/traverse/lib/path/context.js:88:12)
    at TraversalContext.visitQueue (<work_space>/node_modules/@babel/traverse/lib/context.js:118:16)
    at TraversalContext.visitSingle (<work_space>/node_modules/@babel/traverse/lib/context.js:90:19)
    at TraversalContext.visit (<work_space>/node_modules/@babel/traverse/lib/context.js:146:19)
    at Function.traverse.node (<work_space>/node_modules/@babel/traverse/lib/index.js:94:17)
    at NodePath.visit (<work_space>/node_modules/@babel/traverse/lib/path/context.js:95:18)

馃捇 Code Sample

// main.js
const main = async () => {
    const x = await import("./a.js");

	console.log(x);
};
main();

// a.js
console.log('1');

const b = () => import('./b.js');   // b.js is an empty file.   It is precisely because of this problem. 
// import b from 'b.js' // If it's synchronized, it's okay.

export const y = 1;

馃實 Your Environment

Software Version(s)
Parcel 1.10.3
Node 10
npm/Yarn
Operating System
@mischnic
Copy link
Member

Tree shaking doesn't seem to work when dynamically imported bundles use dynamic imports themselves.

JSConcatPackage#resolveModule gets called with name: "./bundle-url".

@garthenweb
Copy link
Contributor

Is there any progress on this issue? This is still an issue for the current master branch.

I tried to have a look but didn't found the root cause of it. All I found out is:

  • the ./bundle-url import comes from builtins/bundle-loader.js. Inlining the content of that file makes the build pass and also the execution works fine, but this does not look like a great solution to me.
  • It looks like the import is not added to the child bundles, maybe the dependencies for _bundle_loader are not collected anymore because its already in the main bundle? I could ensure that its correclty added for all assets from builtins/bundle-loader.js
  • when adding all dependencies from the entryAsset to the assets map in the packager/JSConcatPackager.js the build passes but it failes when executing the JavaScript with module not found errors: for (let [, mod] of this.bundle.entryAsset.depAssets) { this.assets.set(mod.id, mod); }

Maybe this is helpful to someone else how likes to have a look. Would love to see this fixed!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants