Skip to content

Fix webpack, Rspack and Turbopack builds that pull in all of dist - #4170

Merged
DmitrySharabin merged 1 commit into
v2from
bundler-runtime-imports
Oct 15, 2026
Merged

DmitrySharabin merged 1 commit into
v2from
bundler-runtime-imports

Conversation

@DmitrySharabin

Copy link
Copy Markdown
Member

Mark the three runtime import() calls with /* webpackIgnore: true */ /* @vite-ignore */, and keep those comments through terser.

import(/* webpackIgnore: true */ /* @vite-ignore */ this.path + id + ".js"); // ComponentRegistry#load()
import(/* webpackIgnore: true */ /* @vite-ignore */ file); // loadLanguages()
import(/* webpackIgnore: true */ /* @vite-ignore */ path); // Autoloader

import "prismjs"; from an npm pack tarball of v2:

Before After
webpack 5.111, development 735 JS files, 5 "Critical dependency" warnings, 1 error 1 file, 45 KB
webpack 5.111, production Fails: Can't resolve 'url' 1 file, 28 KB
Rspack 2.2, production Fails 1 file
Next.js 16.4 (Turbopack) Fails: Can't resolve <dynamic> Builds
Vite 8.3 dev, Prism symlinked 6 "cannot be analyzed" warnings No warnings
  • Rollup 4.64, Rolldown 1.2, esbuild 0.28, Parcel 2.16 and Bun 1.4 already leave these calls as they are. Their output does not change.
  • @vite-ignore matters only when Prism sits outside node_modules, as in a monorepo or with npm link. Vite never warns about files in node_modules.
  • In all eight bundlers, loadLanguages(Prism, "css", url) still loads the language at runtime.

Closes #4165

🤖 Generated with Claude Code

Closes #4165

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@netlify

netlify Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for dev-prismjs-com ready!

Name Link
🔨 Latest commit 3e32a96
🔍 Latest deploy log https://app.netlify.com/projects/dev-prismjs-com/deploys/6ad0ac60482ae6116a93ec2c
😎 Deploy Preview https://deploy-preview-4170--dev-prismjs-com.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

@DmitrySharabin
DmitrySharabin merged commit d98c81c into v2 Oct 15, 2026
12 checks passed
@DmitrySharabin
DmitrySharabin deleted the bundler-runtime-imports branch October 15, 2026 10:59
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.

Importing prismjs/core.js with webpack bundles the whole package

1 participant