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

Imports order using code splitting #417

Closed
elv1n opened this issue Sep 28, 2020 · 1 comment
Closed

Imports order using code splitting #417

elv1n opened this issue Sep 28, 2020 · 1 comment

Comments

@elv1n
Copy link

elv1n commented Sep 28, 2020

The example I'm providing is not actually accurate in how modules should be imported but I think it could point on a defect that can cause issues.

Let's say we have the next structure

// index.ts
import { Import1 } from './components'
import { Import2 } from './base'


export const getChunk = () => import('./chunk')
export {
    Import1,
    Import2,
}

// chunk.ts
import { Import1 } from './components'
import { Import2 } from './base'

export const Ui = {
    Import1,
    Import2,
}

In the output bundled chunk, the second import declared first

// base/index.ts
const Import2 = 22;

// /components/index.ts
const Import1 = 1;

export {
  Import2,
  Import1
};

In all other cases, like leaving imports only in chunk or in the entry file imports will be ordered as declared.
After renaming directories order changed

@evanw
Copy link
Owner

evanw commented Sep 28, 2020

Closing as a duplicate of #399. This issue arose from a misunderstanding of mine about the ordering constraints of ES6 import statements. I believe it only happens when code splitting is enabled. Fixing this means coming up with a new algorithm instead of simply fixing a bug, so it's not something I can quickly release a patch for unfortunately.

@evanw evanw closed this as completed Sep 28, 2020
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