Skip to content

Commit

Permalink
Merge pull request #22 from Seojunhwan/refactor/module
Browse files Browse the repository at this point in the history
  • Loading branch information
Seojunhwan authored Sep 17, 2024
2 parents 169b222 + 6c96835 commit 4fae5ea
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 22 deletions.
5 changes: 5 additions & 0 deletions .changeset/perfect-bats-run.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"esbuild-plugin-preserve-directives": patch
---

fix type
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
"author": "seojunhwan <[email protected]>",
"license": "MIT",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"exports": {
".": {
"require": {
Expand All @@ -13,7 +15,7 @@
},
"import": {
"default": "./dist/index.mjs",
"types": "./dist/index.d.ts"
"types": "./dist/index.d.mts"
}
}
},
Expand All @@ -23,7 +25,7 @@
"scripts": {
"clean": "rm -rf dist",
"build": "pnpm run clean && node scripts/build.cjs && pnpm run build:types",
"build:types": "tsc --project tsconfig.json --outDir dist",
"build:types": "tsc --project tsconfig.json --outDir dist --declaration --emitDeclarationOnly && cp dist/index.d.ts dist/index.d.mts",
"prepublishOnly": "pnpm run build",
"release": "npx changeset publish",
"version": "npx changeset version"
Expand All @@ -45,6 +47,7 @@
"@changesets/cli": "^2.27.7",
"@types/node": "^20.14.10",
"esbuild": "^0.23.0",
"prettier": "^3.3.3",
"typescript": "^5.5.3"
},
"peerDependencies": {
Expand Down
10 changes: 10 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions scripts/build.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,26 @@ const esbuild = require('esbuild');

async function build() {
try {
await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.js',
platform: 'node',
target: 'node18',
format: 'cjs',
sourcemap: true,
});

await esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.mjs',
platform: 'node',
target: 'node18',
format: 'esm',
sourcemap: true,
});

Promise.all([
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.js',
platform: 'node',
target: 'node18',
format: 'cjs',
sourcemap: true,
}),
esbuild.build({
entryPoints: ['src/index.ts'],
bundle: true,
outfile: 'dist/index.mjs',
platform: 'node',
target: 'node18',
format: 'esm',
sourcemap: true,
}),
]);
console.log('Build success');
} catch (error) {
console.error('Build failed:', error);
Expand Down

0 comments on commit 4fae5ea

Please sign in to comment.