Skip to content

Commit 03c4a62

Browse files
authored
resolves #134 publish a browser-compatible entry point (#171)
1 parent ad824c7 commit 03c4a62

File tree

4 files changed

+20408
-7
lines changed

4 files changed

+20408
-7
lines changed

package-lock.json

Lines changed: 41 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
},
2323
"type": "module",
2424
"main": "./src/index.cjs",
25+
"browser": "./src/index.mjs",
2526
"exports": {
2627
"import": "./src/index.js",
2728
"require": "./src/index.cjs"
@@ -51,6 +52,7 @@
5152
"eslint": "~8.22",
5253
"mocha": "~10.0",
5354
"rollup": "~3.20",
55+
"rollup-plugin-re": "^1.0.7",
5456
"standard": "~17.0"
5557
},
5658
"standard": {

rollup.config.js

Lines changed: 30 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,31 @@
1-
export default {
2-
input: 'src/index.js',
3-
output: {
4-
file: 'src/index.cjs',
5-
format: 'cjs',
1+
import replace from 'rollup-plugin-re'
2+
3+
export default [
4+
{
5+
input: 'src/index.js',
6+
output: {
7+
file: 'src/index.cjs',
8+
format: 'cjs',
9+
},
10+
external: ['fs', 'glob', 'os', 'path', 'unxhr', 'util']
611
},
7-
external: [ 'fs', 'glob', 'os', 'path', 'unxhr', 'util' ]
8-
}
12+
{
13+
input: 'src/index.js',
14+
output: {
15+
file: 'src/index.mjs',
16+
format: 'es',
17+
},
18+
plugins: [
19+
replace({
20+
patterns: [
21+
{
22+
// string or regexp
23+
test: 'import \'./nodejs.js\'',
24+
// string or function to replaced with
25+
replace: '',
26+
}
27+
]
28+
}),
29+
]
30+
}
31+
]

0 commit comments

Comments
 (0)