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

:js-provider :external should support :modules #1162

Open
thheller opened this issue Nov 16, 2023 · 0 comments
Open

:js-provider :external should support :modules #1162

thheller opened this issue Nov 16, 2023 · 0 comments

Comments

@thheller
Copy link
Owner

thheller commented Nov 16, 2023

Currently :external only supports creating a singular output, which in a multi :modules builds prevents webpack from doing any code splitting at all. It should be possible to bridge webpack type code splitting with the :modules system.

The attempt I made was emitting something like

//ext-index.js

// regular code to import JS packages used by base module
// must use ESM import, otherwise webpack doesn't split at all
import * as esm_import$thing from "thing";

shadow$bridge["thing"] = esm_import$thing;

// helper function to let webpack split out imports
shadow$bridge["module:mod"] = function() {
   return import("./ext-mod.js");
}

// ext-mod.js
// only imports required by this module here
import * as esm_import$other from "other";
shadow$bridge["other"] = esm_import$other;

And then ensuring that the loader first executes the generated loader function and awaits the promise, before trying to load the actual CLJS modules.

I failed at getting this to work with the goog.module.ModuleLoader based impl. Given that the Closure Library is being deprecated it might be time to implement this entirely in shadow-cljs, which could then account for this.

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

1 participant