Skip to content

Fix code-split alias modules and dynamic CSS imports#10

Open
flowerornament wants to merge 1 commit intoelixir-volt:masterfrom
flowerornament:fix-code-split-dynamic-imports
Open

Fix code-split alias modules and dynamic CSS imports#10
flowerornament wants to merge 1 commit intoelixir-volt:masterfrom
flowerornament:fix-code-split-dynamic-imports

Conversation

@flowerornament
Copy link
Copy Markdown

Summary

Closes #9.

This fixes two production code-splitting edge cases:

  • alias-resolved modules outside the entry root can be assigned collector labels such as _external/*; chunk output selection was matching by path suffix, so those modules could be omitted from the emitted chunk;
  • dynamic CSS imports such as import("./theme.css") should not survive as browser-runtime imports of CSS/data modules when Volt already owns stylesheet output.

The patch keeps Volt's existing chunk-graph approach, but makes three targeted changes:

  • select chunk files through the collector's original module path to label map;
  • protect dynamic import(...) before per-chunk OXC bundling, then restore it before Volt rewrites chunk URLs;
  • rewrite dynamic CSS import expressions to an already-resolved no-op promise. Static CSS imports continue to use the existing no-op JS-module path.

Repro

The public issue has the reduced cases and expected output: #9.

This PR adds tests for both cases:

  • code splitting includes alias modules outside the entry root
  • dynamic CSS imports become inert browser-loadable modules

Validation

  • mix format --check-formatted
  • mix test test/builder_test.exs --seed 0

AI disclosure

I used OpenAI Codex as a coding assistant to help reduce the repros and draft the candidate patch. I reviewed the diff and ran the validations above locally.

@flowerornament
Copy link
Copy Markdown
Author

This resolves my specific issue, but you may want to review for generality

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

Successfully merging this pull request may close these issues.

Code splitting can omit alias modules and mishandle dynamic CSS imports

1 participant