From 7b1401a3cacc015efc5b52f0c5de0e7f393d833a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20B=C3=B6hm?= <188768+fb55@users.noreply.github.com> Date: Tue, 12 Apr 2022 13:33:59 +0100 Subject: [PATCH] feat(htmlparser2-adapter): Add CJS build (#496) --- package.json | 3 +-- packages/parse5-htmlparser2-tree-adapter/package.json | 10 ++++++++-- packages/parse5/package.json | 9 +++++---- packages/parse5/tsconfig.cjs.json | 8 -------- 4 files changed, 14 insertions(+), 16 deletions(-) delete mode 100644 packages/parse5/tsconfig.cjs.json diff --git a/package.json b/package.json index dd9930ab6..f3ccc0730 100644 --- a/package.json +++ b/package.json @@ -25,9 +25,8 @@ "typescript": "^4.6.3" }, "scripts": { - "build": "npm run build:esm && npm run build:cjs", + "build": "npm run build:esm && npm run build:cjs --workspaces --if-present", "build:esm": "tsc --build packages/* test", - "build:cjs": "tsc -p packages/parse5/tsconfig.cjs.json && echo '{\"type\":\"commonjs\"}' > packages/parse5/dist/cjs/package.json", "build:docs": "node --max-old-space-size=8192 node_modules/.bin/typedoc .", "prettier": "prettier '**/*.{js,ts,md,json,yml}' --loglevel warn", "format": "npm run format:es && npm run format:prettier", diff --git a/packages/parse5-htmlparser2-tree-adapter/package.json b/packages/parse5-htmlparser2-tree-adapter/package.json index 8d86c29ee..2e35f8bfe 100644 --- a/packages/parse5-htmlparser2-tree-adapter/package.json +++ b/packages/parse5-htmlparser2-tree-adapter/package.json @@ -14,14 +14,20 @@ "htmlparser2" ], "license": "MIT", - "main": "dist/index.js", + "main": "dist/cjs/index.js", "module": "dist/index.js", "types": "dist/index.d.ts", - "exports": "./dist/index.js", + "exports": { + "import": "./dist/index.js", + "require": "./dist/cjs/index.js" + }, "dependencies": { "domhandler": "^4.3.1", "parse5": "^6.0.1" }, + "scripts": { + "build:cjs": "tsc --module CommonJS --target ES6 --outDir dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json" + }, "repository": { "type": "git", "url": "git://github.com/inikulin/parse5.git" diff --git a/packages/parse5/package.json b/packages/parse5/package.json index 8d149914c..a77b7153c 100644 --- a/packages/parse5/package.json +++ b/packages/parse5/package.json @@ -32,10 +32,11 @@ "module": "dist/index.js", "types": "dist/index.d.ts", "exports": { - ".": { - "import": "./dist/index.js", - "require": "./dist/cjs/index.js" - } + "import": "./dist/index.js", + "require": "./dist/cjs/index.js" + }, + "scripts": { + "build:cjs": "tsc --module CommonJS --target ES6 --outDir dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json" }, "repository": { "type": "git", diff --git a/packages/parse5/tsconfig.cjs.json b/packages/parse5/tsconfig.cjs.json deleted file mode 100644 index 760382867..000000000 --- a/packages/parse5/tsconfig.cjs.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "CommonJS", - "target": "ES6", - "outDir": "dist/cjs" - } -}