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

Incorrect order of imports in the chunk when using dynamic imports and code splitting #3585

Open
web-padawan opened this issue Jan 11, 2024 · 0 comments

Comments

@web-padawan
Copy link

web-padawan commented Jan 11, 2024

Potentially related to #399 or #2983 - if so, feel free to close as duplicate.

Here is the reproduction. Run npm i && npm run build && npm start and check the console.

The issue manifests when having two dynamic imports in src/app-element.js (with static imports, everything works fine).

Content of imported files
import './theme/lumo/vaadin-checkbox.js';
export * from './src/vaadin-checkbox.js';
import './vaadin-checkbox-styles.js'; // order of these two imports matters
import '../../src/vaadin-checkbox.js';
import './theme/lumo/vaadin-checkbox-group.js';
export * from './src/vaadin-checkbox-group.js';
import '@vaadin/checkbox/theme/lumo/vaadin-checkbox.js';
import './vaadin-checkbox-group-styles.js';
import '../../src/vaadin-checkbox-group.js';

The underlying logic used by these web components assumes that theme files end up in the bundle before src files.
When using static imports, this works as expected and the output of files in the bundle matches the order of imports:

// node_modules/@vaadin/checkbox/theme/lumo/vaadin-checkbox-styles.js
// node_modules/@vaadin/checkbox/src/vaadin-checkbox-mixin.js
// node_modules/@vaadin/checkbox/src/vaadin-checkbox-styles.js
// node_modules/@vaadin/checkbox/src/vaadin-checkbox.js

However, when using dynamic imports and code splitting, file from theme folder is bundled after the src files:

// node_modules/@vaadin/checkbox/src/vaadin-checkbox-mixin.js
// node_modules/@vaadin/checkbox/src/vaadin-checkbox-styles.js
// node_modules/@vaadin/checkbox/src/vaadin-checkbox.js
// node_modules/@vaadin/checkbox/theme/lumo/vaadin-checkbox-styles.js
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