sveltejs/sapper

chunk.imports is not iterable

multipliedtwice opened this issue · 7 comments

After bumping to 0.28.9 I've got a compilation error which says:

chunk.imports is not iterable

internal/modules/cjs/loader.js:895
  throw err;
  ^

Error: Cannot find module '\client\__sapper__\dev\server\server.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:892:15)    at Function.Module._load (internal/modules/cjs/loader.js:742:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

How can I solve this? The error doesn't show any clue how to solve this.

There's not enough.info here to reproduce this problem. Can you provide a sample project that reproduces?

I have the same problem - After cloning smelte and updating sapper (0.27.1 worked, after updating to 0.28.10 I can't compile)

Update:
I tested few versions. 0.27.16 (Last in 0.27) works perfectly. 0.28.0 shows errors of layout not exporting preload, but compiles and works anyway. 0.28.1 - 0.28.2 shows undefined is not iterable (cannot read property Symbol(Symbol.iterator)) with no stack trace.
0.28.3 fixes that and works same as 0.28 (again, the non-fatal warning preload is not exported). That persists to 0.28.6.
This issue happens in versions (all tested) 0.28.7 - 0.28.10. It also shows the non-fatal preload warning, but then crashes on chunk.imports is not iterable.

Can you provide a sample project that reproduces this?

Again, I cloned smelte and updated sapper (via npm i sapper@latest). Then also installed @babel/plugin-syntax-import-meta and added to rollup config to fix an error. Then, when running via npm run dev the server crashes.

You get more details if you run npx sapper build. The line it's failing on is:

https://github.com/domingues/rollup-plugin-css-chunks/blob/c90514fecd8624953baa5001b35c8f2d8ad86f5b/index.ts#L107

For some reason chunk.imports is undefined which is causing that error. The chunk it's failing on is {"fileName":"../../../static/global.css","isAsset":true}. It shouldn't have gotten that far because that rollup plugin tries to filter out asset chunks:

https://github.com/domingues/rollup-plugin-css-chunks/blob/c90514fecd8624953baa5001b35c8f2d8ad86f5b/index.ts#L102

So I guess the question is why is that css chunk not being filtered out. My guess would be that it's because Smelte is using Rollup 1.0. Can you try upgrading it to the latest version of Rollup and upgrading all the Rollup plugins to their latest versions as well?

I'm going to close this as being an issue in Smelte. If Smelte upgrades to Rollup 2 and it still doesn't work then we can reopen