nollup
nollup copied to clipboard
Dynamic imports
Hi, I tried implementing a fast development loop for sapper using nollup but it seems that support for dynamic imports is not (yet?) present in nollup.
A few specific observations:
- OutputChunk.dynamicImports is missing
- ModuleInfo.dynamicallyImportedIds is missing
- modules referenced by dynamic imports themselves don't seem to be included in any of the output chunks
Is this something that should be present or is there a fundamental reason it's incompatible with the nollup philosophy?
Not everything has been implemented, but can't see any reason why those can't be added. Any code snippets you can share for context on what you're trying to do? 🙂
This is an example of a use of ModuleInfo.dynamicallyImportedIds
.
https://github.com/metered/sapper/commit/15cde73df542a1bbf5524e71325df51521fe7e34#diff-9a33240426fe04fe7d015c7ec8e07c63R137
It's a rollup plugin port of sapper's sapper build
command. In this case it's trying to generate a proper list of css stylesheets referenced by a particular javascript chunk.
I have another iteration of this rollup plugin that hasn't been pushed yet that expands on this functionality.
Great! I'll hopefully have something for this soon over the next few days!
https://github.com/PepsRyuu/nollup/pull/142 Does this help to address the use case? :)
@ajbouh Any update on this?
Hi @PepsRyuu, just circled back to this. Doing an install directly from that PR gives me the following error:
ParseError: /node_modules/@apollo/client/core/ApolloClient.js
TypeError: Cannot read property 'length' of undefined
at .../node_modules/nollup/lib/impl/utils.js:56:61
at Array.forEach (<anonymous>)
at prepareSourceMapChain (.../node_modules/nollup/lib/impl/utils.js:51:18)
at combineSourceMapChainFast (.../node_modules/nollup/lib/impl/utils.js:96:34)
at Object.transform (.../node_modules/nollup/lib/impl/PluginLifecycle.js:211:25)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at compileModule (.../node_modules/nollup/lib/impl/NollupCompiler.js:58:27)
at compileModule (.../node_modules/nollup/lib/impl/NollupCompiler.js:120:13)
at compileModule (.../node_modules/nollup/lib/impl/NollupCompiler.js:120:13)
at compileModule (.../node_modules/nollup/lib/impl/NollupCompiler.js:120:13)
at compileModule (.../node_modules/nollup/lib/impl/NollupCompiler.js:122:19)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Here's a gist with the contents of ApolloClient.js
: https://gist.github.com/ajbouh/749dc1bcc0f66a974381b85ec2830b77
Perhaps it's because this is using import
syntax even though it's a .js
file?