Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/fix-standalone-prettier-import.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/prettier-plugin-liquid': patch
---

Fix standalone build importing `prettier` instead of `prettier/standalone`, which caused browser bundlers (webpack, rollup, vite) consuming `standalone.js` to try to resolve Node builtins (`module`, `url`, `path`) from prettier's main entry
13 changes: 11 additions & 2 deletions packages/prettier-plugin-liquid/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,18 @@ module.exports = {
},
},
externals: {
// The standalone bundle is browser-only. Downstream bundlers that consume
// standalone.js (webpack, rollup, vite) see a UMD wrapper whose `commonjs`
// and `commonjs2` branches `require('prettier')`. That import resolves to
// prettier's Node-flavored main entry, which pulls in `module`, `url`, and
// `path` and breaks browser builds. Route those branches to
// `prettier/standalone` so downstream bundlers land on prettier's
// browser-safe entry. `root: 'prettier'` is kept so <script>-tag loading
// still works against the global `window.prettier` populated by
// `prettier/standalone.js` on the page.
prettier: {
commonjs: 'prettier',
commonjs2: 'prettier',
commonjs: 'prettier/standalone',
commonjs2: 'prettier/standalone',
amd: 'prettier/standalone',
root: 'prettier',
},
Expand Down
Loading