Skip to content

Commit 86883ed

Browse files
committed
Improve exports in package.json
1 parent 8cd0f65 commit 86883ed

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@ node_modules
33
.history
44
plugin.js
55
plugin.js.map
6-
standalone
6+
standalone.js
7+
standalone.js.map
8+
esm

package.json

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,25 @@
33
"version": "2.3.1",
44
"description": "Svelte plugin for prettier",
55
"main": "plugin.js",
6-
"browser": {
7-
"./plugin.js": "./standalone/index.js",
8-
"./plugin.mjs": "./standalone/index.mjs"
6+
"module": "esm/plugin.mjs",
7+
"exports": {
8+
".": {
9+
"browser": {
10+
"import": "./esm/standalone.mjs",
11+
"default": "./standalone.js"
12+
},
13+
"default": "./plugin.js"
14+
},
15+
"./standalone": {
16+
"import": "./esm/standalone.mjs",
17+
"default": "./standalone.js"
18+
}
919
},
1020
"files": [
1121
"plugin.js",
1222
"plugin.js.map",
13-
"standalone/index.js",
14-
"standalone/index.js.map",
15-
"standalone/index.mjs",
16-
"standalone/index.mjs.map"
23+
"esm/**/*.mjs",
24+
"esm/**/*.mjs.map"
1725
],
1826
"scripts": {
1927
"build": "rollup -c && rollup -c rollup.standalone.cjs.config.js && rollup -c rollup.standalone.esm.config.js",

rollup.standalone.cjs.config.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import commonjs from '@rollup/plugin-commonjs';
33
import typescript from 'rollup-plugin-typescript';
44
import inject from '@rollup/plugin-inject';
55
import alias from '@rollup/plugin-alias';
6-
import path from 'path';
76

87
export default {
98
input: 'src/index.ts',
@@ -23,7 +22,7 @@ export default {
2322
],
2423
external: ['prettier/standalone', 'svelte'],
2524
output: {
26-
file: 'standalone/index.js',
25+
file: 'standalone.js',
2726
format: 'cjs',
2827
sourcemap: true,
2928
},

rollup.standalone.esm.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export default {
2424
],
2525
external: ['prettier/esm/standalone', 'svelte'],
2626
output: {
27-
file: 'standalone/index.mjs',
27+
file: 'esm/standalone.mjs',
2828
format: 'esm',
2929
sourcemap: true,
3030
},

0 commit comments

Comments
 (0)