Skip to content

Commit

Permalink
feat: build esm node and browser versions
Browse files Browse the repository at this point in the history
  • Loading branch information
Loïc Mangeonjean committed Apr 15, 2024
1 parent 1be1a2b commit f80b173
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"bin": {
"vscode-languagedetection": "cli/index.js"
},
"module": "dist/lib/index.js",
"types": "dist/lib/index.d.ts",
"module": "dist/lib/index.esm.js",
"browser": "dist/lib/index.web.js",
"types": "dist/lib/index.node.d.ts",
"scripts": {
"pretest": "npm run clean && tsc --build ./test",
"prepublishOnly": "npm test && npm run compile",
Expand Down
49 changes: 49 additions & 0 deletions rollup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,53 @@ export default rollup.defineConfig([{
ecma: 2015
})
]
}, {
input: {
index: './lib/index.node.ts'
},
output: [{
sourcemap: true,
format: 'esm',
dir: 'dist/lib',
entryFileNames: '[name].esm.js'
}],
plugins: [
nodeResolve({
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
browser: false,
preferBuiltins: true
}),
typescript({
sourceMap: true,
noEmitOnError: true,
tsconfig: TSCONFIG
}),
commonjs(),
json()
]
}, {
cache: false,
input: {
index: './lib/index.ts'
},
output: [{
sourcemap: true,
format: 'esm',
dir: 'dist/lib',
entryFileNames: '[name].web.js'
}],
plugins: [
nodeResolve({
extensions: ['.ts', '.tsx', '.js', '.jsx', '.json'],
browser: true,
preferBuiltins: true
}),
typescript({
sourceMap: true,
noEmitOnError: true,
tsconfig: TSCONFIG
}),
commonjs(),
json()
]
}])

0 comments on commit f80b173

Please sign in to comment.