- Rename CommonJS build output from .js to .cjs extensions - Add .js extensions to ESM imports (required by Node.js) - Add .cjs extensions to CommonJS requires - Add post-build scripts for both ESM and CommonJS builds - Update package.json exports to reference .cjs files for require() Fixes: ReferenceError: exports is not defined in ES module scope Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
26 lines
798 B
JSON
26 lines
798 B
JSON
{
|
|
"name": "@stockhome/shared",
|
|
"private": true,
|
|
"version": "1.0.0",
|
|
"type": "module",
|
|
"scripts": {
|
|
"prebuild": "barrelsby --directory src --delete --single",
|
|
"build:esm": "tsc -p tsconfig.esm.json && node scripts/postbuild-esm.cjs",
|
|
"build:cjs": "tsc -p tsconfig.cjs.json && find dist/cjs -name \"*.js\" -type f -exec sh -c 'mv \"$1\" \"${1%.js}.cjs\"' _ {} \\; && node scripts/postbuild.cjs",
|
|
"build": "npm run prebuild && npm run build:esm && npm run build:cjs",
|
|
"lint": "eslint ."
|
|
},
|
|
"exports": {
|
|
".": {
|
|
"types": "./dist/types/index.d.ts",
|
|
"import": "./dist/esm/index.js",
|
|
"require": "./dist/cjs/index.cjs"
|
|
}
|
|
},
|
|
"types": "./dist/types/index.d.ts",
|
|
"devDependencies": {
|
|
"barrelsby": "^2.8.1",
|
|
"typescript": "~6.0.2"
|
|
}
|
|
}
|