-
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
Add standalone build #239
Add standalone build #239
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,6 @@ node_modules | |
.history | ||
plugin.js | ||
plugin.js.map | ||
standalone.js | ||
standalone.js.map | ||
esm |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,12 +3,28 @@ | |
"version": "2.3.1", | ||
"description": "Svelte plugin for prettier", | ||
"main": "plugin.js", | ||
"module": "esm/plugin.mjs", | ||
"exports": { | ||
".": { | ||
"browser": { | ||
"import": "./esm/standalone.mjs", | ||
"default": "./standalone.js" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For even more compatibility, add |
||
}, | ||
"default": "./plugin.js" | ||
}, | ||
"./standalone": { | ||
"import": "./esm/standalone.mjs", | ||
"default": "./standalone.js" | ||
} | ||
}, | ||
"files": [ | ||
"plugin.js", | ||
"plugin.js.map" | ||
"plugin.js.map", | ||
"esm/**/*.mjs", | ||
"esm/**/*.mjs.map" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. To save some bytes when publishing: Could we only publish the plugin map, not the standalone map? |
||
], | ||
"scripts": { | ||
"build": "rollup -c", | ||
"build": "rollup -c && rollup -c rollup.standalone.cjs.config.js && rollup -c rollup.standalone.esm.config.js", | ||
"test": "ava", | ||
cfraz89 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
"prepare": "npm run build", | ||
"prepublishOnly": "npm test" | ||
|
@@ -28,6 +44,8 @@ | |
}, | ||
"homepage": "https://github.com/sveltejs/prettier-plugin-svelte#readme", | ||
"devDependencies": { | ||
"@rollup/plugin-alias": "^3.1.4", | ||
"@rollup/plugin-inject": "^4.0.2", | ||
"@types/node": "^10.12.18", | ||
"@types/prettier": "^2.1.6", | ||
"ava": "3.15.0", | ||
|
@@ -44,5 +62,8 @@ | |
"peerDependencies": { | ||
"prettier": "^1.16.4 || ^2.0.0", | ||
"svelte": "^3.2.0" | ||
}, | ||
"dependencies": { | ||
"buffer": "^5.7.1" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Instead of adding a dependency on
and use that file in the appropriate places? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Agree that the |
||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from 'rollup-plugin-typescript'; | ||
import inject from '@rollup/plugin-inject'; | ||
import alias from '@rollup/plugin-alias'; | ||
|
||
export default { | ||
input: 'src/index.ts', | ||
plugins: [ | ||
alias({ | ||
entries: [{ find: /^prettier$/gm, replacement: `prettier/standalone` }], | ||
}), | ||
resolve({ | ||
preferBuiltins: false, | ||
browser: true, | ||
}), | ||
commonjs(), | ||
typescript({}), | ||
inject({ | ||
Buffer: ['buffer', 'Buffer'], | ||
}), | ||
], | ||
external: ['prettier/standalone', 'svelte/compiler'], | ||
output: { | ||
file: 'standalone.js', | ||
format: 'cjs', | ||
sourcemap: true, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import resolve from '@rollup/plugin-node-resolve'; | ||
import commonjs from '@rollup/plugin-commonjs'; | ||
import typescript from 'rollup-plugin-typescript'; | ||
import inject from '@rollup/plugin-inject'; | ||
import alias from '@rollup/plugin-alias'; | ||
import path from 'path'; | ||
|
||
const srcDir = path.resolve(__dirname, 'src'); | ||
export default { | ||
input: 'src/index.ts', | ||
plugins: [ | ||
alias({ | ||
entries: [{ find: /^prettier$/gm, replacement: `${srcDir}/standalone-shim` }], | ||
}), | ||
resolve({ | ||
preferBuiltins: false, | ||
browser: true, | ||
}), | ||
commonjs(), | ||
typescript({}), | ||
inject({ | ||
Buffer: ['buffer', 'Buffer'], | ||
}), | ||
], | ||
external: ['prettier/esm/standalone', 'svelte/compiler'], | ||
output: { | ||
file: 'esm/standalone.mjs', | ||
format: 'esm', | ||
sourcemap: true, | ||
}, | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import prettier from 'prettier/esm/standalone'; | ||
export const doc = prettier.doc; |
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 don't see this file generated anywhere according to the rollup configs. Oversight?