Skip to content

Fix require("prismjs") in webpack, Rspack, esbuild and Parcel bundles - #4172

Merged
DmitrySharabin merged 1 commit into
v2from
cjs-import-meta-url
Oct 15, 2026
Merged

DmitrySharabin merged 1 commit into
v2from
cjs-import-meta-url

Conversation

@DmitrySharabin

@DmitrySharabin DmitrySharabin commented Oct 15, 2026 •

Copy link
Copy Markdown
Member

Compile import.meta.url to undefined in the CJS build, so dist/cjs no longer calls require("url").

Rollup's CJS output for import.meta.url calls require('u' + 'rl'), Node's url module. Browser bundlers resolve it even split like that. Rollup also put the core's resolveAlias into the same chunk, so require("prismjs") itself, not only the Autoloader, pulled in url.

require("prismjs") from an npm pack tarball of v2:

Before After
webpack 5.111, Rspack 2.2 Fails: Can't resolve 'url' Builds
esbuild 0.28 Fails: Could not resolve "url" Builds
Parcel 2.16 Fails: Failed to resolve 'url' Builds
Vite 8.3 Module "url" has been externalized Builds
Rollup 4.64, Bun 1.4 Builds Builds
  • Code that reads import.meta.url gets undefined in the CJS build. The Autoloader handles it and falls back to ./.

🤖 Generated with Claude Code

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 19252ad
🔍 Latest deploy log https://app.netlify.com/projects/dev-prismjs-com/deploys/6ad0c88d44d609ce12648d72
😎 Deploy Preview https://deploy-preview-4172--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 7e435fd into v2 Oct 15, 2026
12 checks passed
@DmitrySharabin
DmitrySharabin deleted the cjs-import-meta-url branch October 15, 2026 12:36
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.

1 participant