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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic imports #140

Open
ajbouh opened this issue Aug 28, 2020 · 7 comments
Open

Dynamic imports #140

ajbouh opened this issue Aug 28, 2020 · 7 comments

Comments

@ajbouh
Copy link

ajbouh commented Aug 28, 2020

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?

@PepsRyuu
Copy link
Owner

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? 🙂

@ajbouh
Copy link
Author

ajbouh commented Aug 28, 2020

This is an example of a use of ModuleInfo.dynamicallyImportedIds.

metered/sapper@15cde73#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.

@PepsRyuu
Copy link
Owner

Great! I'll hopefully have something for this soon over the next few days!

@PepsRyuu
Copy link
Owner

PepsRyuu commented Sep 1, 2020

#142 Does this help to address the use case? :)

@PepsRyuu
Copy link
Owner

@ajbouh Any update on this?

@ajbouh
Copy link
Author

ajbouh commented Oct 3, 2020

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)

@ajbouh
Copy link
Author

ajbouh commented Oct 3, 2020

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?

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

No branches or pull requests

2 participants