From a63e4225c3911445289d6be9696df879fab944b6 Mon Sep 17 00:00:00 2001 From: Shiv Jha-Mathur Date: Wed, 24 Apr 2024 01:04:30 +0530 Subject: [PATCH] build!: provide separate CJS and ESM builds --- packages/micromark-extension-kbd-nested/package.json | 9 ++++++--- .../tsconfig.build.cjs.json | 7 +++++++ .../micromark-extension-kbd-nested/tsconfig.build.json | 4 ++-- packages/remark-kbd-nested/package.json | 9 ++++++--- packages/remark-kbd-nested/tsconfig.build.cjs.json | 7 +++++++ packages/remark-kbd-nested/tsconfig.build.json | 4 ++-- 6 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 packages/micromark-extension-kbd-nested/tsconfig.build.cjs.json create mode 100644 packages/remark-kbd-nested/tsconfig.build.cjs.json diff --git a/packages/micromark-extension-kbd-nested/package.json b/packages/micromark-extension-kbd-nested/package.json index 359317f..c66e092 100644 --- a/packages/micromark-extension-kbd-nested/package.json +++ b/packages/micromark-extension-kbd-nested/package.json @@ -20,9 +20,11 @@ "url": "https://github.com/shivjm/remark-extensions.git" }, "scripts": { - "build": "rimraf lib && tsc -p tsconfig.build.json", + "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json", + "build:clean": "rimraf lib && npm run build", "lint": "eslint src/**/*.ts", - "test": "mocha tests/**/*.ts" + "test": "mocha tests/**/*.ts", + "prepublish": "npm run build" }, "dependencies": { "micromark-util-character": "^1.1.0", @@ -53,7 +55,8 @@ }, "type": "module", "publishConfig": { - "main": "lib/index.js", + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", "typings": "index.d.ts" }, "files": [ diff --git a/packages/micromark-extension-kbd-nested/tsconfig.build.cjs.json b/packages/micromark-extension-kbd-nested/tsconfig.build.cjs.json new file mode 100644 index 0000000..db5ee93 --- /dev/null +++ b/packages/micromark-extension-kbd-nested/tsconfig.build.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "lib/cjs" + } +} diff --git a/packages/micromark-extension-kbd-nested/tsconfig.build.json b/packages/micromark-extension-kbd-nested/tsconfig.build.json index a1d104f..7875b6e 100644 --- a/packages/micromark-extension-kbd-nested/tsconfig.build.json +++ b/packages/micromark-extension-kbd-nested/tsconfig.build.json @@ -3,8 +3,8 @@ "include": ["src"], "exclude": ["node_modules", "tests"], "compilerOptions": { - "outDir": "lib", + "outDir": "lib/esm", "declaration": true, - "declarationDir": "lib" + "declarationDir": "lib/esm" } } diff --git a/packages/remark-kbd-nested/package.json b/packages/remark-kbd-nested/package.json index 94cba66..8e58859 100644 --- a/packages/remark-kbd-nested/package.json +++ b/packages/remark-kbd-nested/package.json @@ -4,9 +4,11 @@ "description": "remark plugin to add support for `kbd` element syntax with configurable delimiters, escaping, and arbitrary nesting", "main": "src/index.ts", "scripts": { - "build": "rimraf lib && tsc -p tsconfig.build.json", + "build": "tsc -p tsconfig.build.json && tsc -p tsconfig.build.cjs.json", + "build:clean": "rimraf lib && npm run build", "lint": "eslint src/**/*.ts", - "test": "mocha tests/**/*.ts" + "test": "mocha tests/**/*.ts", + "prepublish": "npm run build" }, "repository": { "type": "git", @@ -31,7 +33,8 @@ }, "type": "module", "publishConfig": { - "main": "lib/index.js", + "main": "./lib/cjs/index.js", + "module": "./lib/esm/index.js", "typings": "index.d.ts" }, "devDependencies": { diff --git a/packages/remark-kbd-nested/tsconfig.build.cjs.json b/packages/remark-kbd-nested/tsconfig.build.cjs.json new file mode 100644 index 0000000..db5ee93 --- /dev/null +++ b/packages/remark-kbd-nested/tsconfig.build.cjs.json @@ -0,0 +1,7 @@ +{ + "extends": "./tsconfig.build.json", + "compilerOptions": { + "module": "commonjs", + "outDir": "lib/cjs" + } +} diff --git a/packages/remark-kbd-nested/tsconfig.build.json b/packages/remark-kbd-nested/tsconfig.build.json index a1d104f..7875b6e 100644 --- a/packages/remark-kbd-nested/tsconfig.build.json +++ b/packages/remark-kbd-nested/tsconfig.build.json @@ -3,8 +3,8 @@ "include": ["src"], "exclude": ["node_modules", "tests"], "compilerOptions": { - "outDir": "lib", + "outDir": "lib/esm", "declaration": true, - "declarationDir": "lib" + "declarationDir": "lib/esm" } }