-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: semi-standalone browser build (#430)
Adds a semi-standalone browser build under prettier-plugin-svelte/browser. part of #69 (full fix would mean import maps work, which they don't because you need svelte/compiler.cjs which has the wrong mime type on package CDNs - this isn't fixable within this package, rather needs a different file type upstream) closes #239 closes #257 closes #417 --------- Co-authored-by: Curran <curran.kelleher@gmail.com>
- Loading branch information
1 parent
288d915
commit d89241e
Showing
7 changed files
with
77 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ node_modules | |
.history | ||
plugin.js | ||
plugin.js.map | ||
browser.js |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
import alias from '@rollup/plugin-alias'; | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from 'rollup-plugin-typescript'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
plugins: [resolve(), commonjs(), typescript()], | ||
external: ['prettier', 'svelte'], | ||
output: { | ||
file: 'plugin.js', | ||
format: 'cjs', | ||
sourcemap: true, | ||
export default [ | ||
// CommonJS build | ||
{ | ||
input: 'src/index.ts', | ||
plugins: [resolve(), commonjs(), typescript()], | ||
external: ['prettier', 'svelte/compiler'], | ||
output: { | ||
file: 'plugin.js', | ||
format: 'cjs', | ||
sourcemap: true, | ||
}, | ||
}, | ||
}; | ||
// Browser build | ||
// Supported use case: importing the plugin from a bundler like Vite or Webpack | ||
// Semi-supported use case: importing the plugin directly in the browser through using import maps. | ||
// (semi-supported because it requires a svelte/compiler.cjs import map and the .cjs ending has the wrong mime type on CDNs) | ||
{ | ||
input: 'src/index.ts', | ||
plugins: [ | ||
alias({ | ||
entries: [{ find: 'prettier', replacement: 'prettier/standalone' }], | ||
}), | ||
resolve(), | ||
commonjs(), | ||
typescript(), | ||
], | ||
external: ['prettier/standalone', 'prettier/plugins/babel', 'svelte/compiler'], | ||
output: { | ||
file: 'browser.js', | ||
format: 'esm', | ||
}, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters