Skip to content

Commit

Permalink
fix: Node 22.12 error with cjs imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Lyle-Anthony Aigbedion authored and JeremyRH committed Dec 13, 2024
1 parent 93eb1b4 commit 6c8719c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
"getStaticDirs.d.ts"
],
"scripts": {
"build": "node scripts/rm.js dist && tsc --outDir dist/es && babel src --out-dir dist/cjs --extensions '.ts,.tsx' && node scripts/npmPackDev.js",
"build": "node scripts/rm.js dist && tsc --outDir dist/es && babel src --out-dir dist/cjs --extensions '.ts,.tsx' && node scripts/npmPackDev.js && node scripts/post-build.js",
"format": "prettier src example/src --write",
"start:example": "npm run build && cd example && npm i ../storybook-addon-code-editor-0.0.0.tgz && npm run storybook:dev",
"build:example": "npm run build && cd example && npm i ../storybook-addon-code-editor-0.0.0.tgz && npm run storybook:build",
Expand Down
10 changes: 10 additions & 0 deletions scripts/post-build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { writeFileSync } from 'fs';
import { join } from 'path';

const cjsDir = join(process.cwd(), 'dist', 'cjs');

const packageJsonContent = {
type: 'commonjs',
};

writeFileSync(join(cjsDir, 'package.json'), JSON.stringify(packageJsonContent, null, 2));

0 comments on commit 6c8719c

Please sign in to comment.