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

Error happens when outputOptions includes inlineDynamicImports: true then inlineDynamicImports: false #4586

Closed
sapphi-red opened this issue Jul 23, 2022 · 1 comment · Fixed by #4589

Comments

@sapphi-red
Copy link
Contributor

sapphi-red commented Jul 23, 2022

Rollup Version

2.77.0

Operating System (or Browser)

Windows

Node Version (if applicable)

No response

Link To Reproduction

https://stackblitz.com/edit/rollup-template-vavvjo?file=rollup.config.js

Expected Behaviour

No error happens.

Actual Behaviour

The error below happens.

src/main.js → dist/iife, dist/es...
[!] Error: Cannot split a chunk that has already been edited (0:7 – "import('./foobar')")
Error: Cannot split a chunk that has already been edited (0:7 – "import('./foobar')")
    at MagicString._splitChunk (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:1689:10)
    at MagicString._split (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:1679:43)
    at MagicString.overwrite (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:1462:8)
    at ImportExpression.renderFinalResolution (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:10381:14)
    at Chunk.finaliseDynamicImports (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:15140:22)
    at Chunk.render (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:14939:14)
    at eval (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:16119:52)
    at Array.map (<anonymous>)
    at Bundle.addFinalizedChunksToBundle (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:16117:34)
    at Bundle.generate (/home/projects/rollup-template-vavvjo/node_modules/rollup/dist/shared/rollup.js:16097:24)

Note that this does not happen if output is like below. (when inlineDynamicImports: false comes first)

    {
      dir: 'dist/es',
      format: 'esm',
      exports: 'auto',
    },
    {
      dir: 'dist/iife',
      format: 'iife',
      inlineDynamicImports: true,
    },

refs vitejs/vite#9310

@lukastaegert
Copy link
Member

Thanks a lot, this was the missing puzzle piece. Fix at #4589.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants