-
Notifications
You must be signed in to change notification settings - Fork 97
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
Standalone build #257
Standalone build #257
Conversation
This works as standalone now when using it with a bundler like Rollup. But it doesn't work yet for a true browser import because there's a |
@dummdidumm Can this get merged (once conflicts are resolved)? |
@@ -3,6 +3,7 @@ | |||
## 2.5.0 (Unreleased) | |||
|
|||
* (feat) Support `bracketSameLine` option and deprecate `svelteBracketNewLine` ([#251](https://github.com/sveltejs/prettier-plugin-svelte/pull/251)) | |||
* (feat) Add a CJS/ESM standalone build, enables usage inside the browser ([#69](https://github.com/sveltejs/prettier-plugin-svelte/pull/69)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should possibly be a breaking change since you're adding exports
? could be better to make it part of 3.0
"import": "./esm/standalone.mjs", | ||
"default": "./standalone.js" | ||
}, | ||
"./package.json": "./package.json" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we updated rollup-plugin-svelte
, so there's no reason to export this anymore
@@ -1,14 +1,63 @@ | |||
import resolve from '@rollup/plugin-node-resolve'; | |||
import commonjs from '@rollup/plugin-commonjs'; | |||
import typescript from 'rollup-plugin-typescript'; | |||
import alias from '@rollup/plugin-alias'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should probably go before the others to be alphabetized?
@@ -1,14 +1,63 @@ | |||
import resolve from '@rollup/plugin-node-resolve'; | |||
import commonjs from '@rollup/plugin-commonjs'; | |||
import typescript from 'rollup-plugin-typescript'; | |||
import alias from '@rollup/plugin-alias'; | |||
import path from 'path'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import path from 'path'; | |
import path from 'node:path'; |
file: 'plugin.js', | ||
format: 'cjs', | ||
sourcemap: true, | ||
const srcDir = path.resolve(__dirname, 'src'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we want to use svelte naming convetions?
const srcDir = path.resolve(__dirname, 'src'); | |
const src_dir = path.resolve(__dirname, 'src'); |
@@ -25,7 +26,8 @@ export const parsers: Record<string, Parser> = { | |||
svelte: { | |||
parse: (text) => { | |||
try { | |||
return <ASTNode>{ ...require(`svelte/compiler`).parse(text), __isRoot: true }; | |||
// @ts-ignore |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should add a comment why this is necessary. if unfixable should use @ts-expect-error
See also #417 |
See #239 for more