generated from NaverPayDev2025/ts-monorepo-template
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[#43] ✨ Support esm/cjs dual packages
- Loading branch information
1 parent
cfdb279
commit d4d2158
Showing
9 changed files
with
171 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import path from 'path' | ||
import fs from 'fs' | ||
import builtins from 'builtin-modules' | ||
import json from '@rollup/plugin-json' | ||
|
||
/** | ||
* @type {import('rollup').RollupOptions} | ||
*/ | ||
export default ['esm', 'cjs'].map((module) => { | ||
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8')) | ||
|
||
return { | ||
input: 'index.js', | ||
output: { | ||
format: module, | ||
dir: 'dist/' + module, | ||
...(module === 'esm' | ||
? { | ||
entryFileNames: `[name]${path.extname('./dist/' + module + '/index.mjs')}`, | ||
preserveModulesRoot: path.dirname('index.js'), | ||
preserveModules: true, | ||
interop: 'esModule', | ||
} | ||
: { | ||
exports: 'auto', | ||
interop: 'auto', | ||
}), | ||
}, | ||
external: [...Object.keys(pkg?.dependencies || []), ...Object.keys(pkg?.peerDependencies || []), ...builtins], | ||
plugins: [json()], | ||
} | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import path from 'path' | ||
import fs from 'fs' | ||
import builtins from 'builtin-modules' | ||
import json from '@rollup/plugin-json' | ||
|
||
/** | ||
* @type {import('rollup').RollupOptions} | ||
*/ | ||
export default ['esm', 'cjs'].map((module) => { | ||
const pkg = JSON.parse(fs.readFileSync(new URL('./package.json', import.meta.url), 'utf8')) | ||
|
||
return { | ||
input: 'lib/index.js', | ||
output: { | ||
format: module, | ||
dir: 'dist/' + module, | ||
...(module === 'esm' | ||
? { | ||
entryFileNames: `[name]${path.extname('./dist/' + module + '/index.mjs')}`, | ||
preserveModulesRoot: path.dirname('lib/index.js'), | ||
preserveModules: true, | ||
interop: 'esModule', | ||
} | ||
: { | ||
exports: 'auto', | ||
interop: 'auto', | ||
}), | ||
}, | ||
external: [...Object.keys(pkg?.dependencies || []), ...Object.keys(pkg?.peerDependencies || []), ...builtins], | ||
plugins: [json()], | ||
} | ||
}) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters