diff --git a/package.json b/package.json index 83d505f..3583c09 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/post-build.js b/scripts/post-build.js new file mode 100644 index 0000000..995cb40 --- /dev/null +++ b/scripts/post-build.js @@ -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));