Skip to content

Commit

Permalink
chore: copy dist file in JS (#275)
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed Apr 4, 2024
1 parent a1b857c commit 1422741
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -29,7 +29,7 @@
"README.md"
],
"scripts": {
"build": "rollup -c && cp ./src/index.d.ts ./dist/magic-string.es.d.mts && cp ./src/index.d.ts ./dist/magic-string.cjs.d.ts",
"build": "rollup -c",
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
"format": "prettier --single-quote --print-width 100 --use-tabs --write src/*.js src/**/*.js",
"lint": "eslint src test && publint",
Expand Down
14 changes: 13 additions & 1 deletion rollup.config.mjs
@@ -1,5 +1,7 @@
import nodeResolve from '@rollup/plugin-node-resolve';
import replace from '@rollup/plugin-replace';
import fs from 'node:fs';
import path from 'node:path';

const plugins = [
nodeResolve(),
Expand All @@ -11,7 +13,17 @@ export default [
{
input: 'src/index.js',
external: ['@jridgewell/sourcemap-codec'],
plugins,
plugins: [
...plugins,
{
name: 'copy-typescript-files',
closeBundle() {
const base = path.resolve('./src/index.d.ts');
fs.copyFileSync(base, path.resolve('./dist/magic-string.es.d.mts'));
fs.copyFileSync(base, path.resolve('./dist/magic-string.cjs.d.ts'));
}
}
],
output: {
file: 'dist/magic-string.es.mjs',
format: 'es',
Expand Down

0 comments on commit 1422741

Please sign in to comment.