-
Notifications
You must be signed in to change notification settings - Fork 6
Description
ππ½ Hi!
I'd like to consume a module β specifically @hotwired/turbo-rails β which dynamically imports another module (see https://github.com/hotwired/turbo-rails/blob/acbb9250cf97cbf9f00570cbfbdeeffc815003b8/app/javascript/turbo/cable.js#L11-L14).
rollup seems to automatically enable code splitting for the bundle, which causes faucet-pipeline-js to complain (see
faucet-pipeline-js/lib/bundle/bundler.js
Lines 17 to 19 in b90282c
| if(output.length !== 1) { // just to be safe | |
| throw new Error("unexpected chunking"); | |
| } |
I could work around the issue by patching lib/bundle/bundler.js to inline the dynamic import:
diff --git a/lib/bundle/bundler.js b/lib/bundle/bundler.js
index f0fb301..3f2ffe1 100644
--- a/lib/bundle/bundler.js
+++ b/lib/bundle/bundler.js
@@ -11,6 +11,7 @@ module.exports = function generateBundle(entryPoint, config, cache) {
return rollup.rollup(options).
then(bundle => {
cache = bundle;
+ writeConfig.inlineDynamicImports = true;
return bundle.generate(writeConfig);
}).
then(({ output }) => {β¦ and now I got some questions and hope you can help me understanding the situation.
I understand that rollup does this automatic code splitting when detecting dynamic imports for some optimization (or whatever good reason they have :)).
I also understand that faucet-pipeline-js currently does not support a chunked result from rollup.
Given that these statements are correct, I understand that one could configure rollup to disable the dynamic import optimization but inlining the import, which would resolve my issue.
If this sounds reasonable: Would you be open for a PR that would allow passing such a configuration option directly to rollup?