From 7345769cd3756b0f7eb9797d94b5eb87f6238a78 Mon Sep 17 00:00:00 2001 From: Charlie Greenman Date: Sun, 16 Jul 2023 00:13:14 +0300 Subject: [PATCH] ZETA-6125: Benchmarl progress towards building esm module. --- "\\" | 6 ------ package-lock.json | 33 +++++++++++++++++++++++++++++++++ package.json | 25 +++++++++++++++++++++---- tsconfig.base.json | 26 +++++++++++--------------- tsconfig.cjs.json | 11 +++++++++++ tsconfig.esm.json | 11 +++++++++++ 6 files changed, 87 insertions(+), 25 deletions(-) delete mode 100644 "\\" create mode 100644 tsconfig.cjs.json create mode 100644 tsconfig.esm.json diff --git "a/\\" "b/\\" deleted file mode 100644 index f849175..0000000 --- "a/\\" +++ /dev/null @@ -1,6 +0,0 @@ -Merge branch 'main' of github.com:razroo/razzle -# Please enter a commit message to explain why this merge is necessary, -# especially if it merges an updated upstream into a topic branch. -# -# Lines starting with '#' will be ignored, and an empty message aborts -# the commit. diff --git a/package-lock.json b/package-lock.json index f790686..5db0e30 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,6 +57,7 @@ "@angular/router": "^13.0.0", "@angular/service-worker": "^13.0.0", "@angular/upgrade": "^13.0.0", + "@types/glob": "^8.1.0", "@types/jest": "^27.5.2", "@types/lodash": "^4.14.192", "@types/resolve": "^1.20.2", @@ -4525,6 +4526,16 @@ "@types/range-parser": "*" } }, + "node_modules/@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "dependencies": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "node_modules/@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", @@ -4604,6 +4615,12 @@ "dev": true, "peer": true }, + "node_modules/@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true + }, "node_modules/@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", @@ -22644,6 +22661,16 @@ "@types/range-parser": "*" } }, + "@types/glob": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/@types/glob/-/glob-8.1.0.tgz", + "integrity": "sha512-IO+MJPVhoqz+28h1qLAcBEH2+xHMK6MTyHJc7MTnnYb6wsoLR29POVGJ7LycmVXIqyy/4/2ShP5sUwTXuOwb/w==", + "dev": true, + "requires": { + "@types/minimatch": "^5.1.2", + "@types/node": "*" + } + }, "@types/graceful-fs": { "version": "4.1.6", "resolved": "https://registry.npmjs.org/@types/graceful-fs/-/graceful-fs-4.1.6.tgz", @@ -22723,6 +22750,12 @@ "dev": true, "peer": true }, + "@types/minimatch": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/@types/minimatch/-/minimatch-5.1.2.tgz", + "integrity": "sha512-K0VQKziLUWkVKiRVrx4a40iPaxTUefQmjtkQofBkYRcoaaL/8rhwDWww9qWbrgicNOgnpIsMxyNIUM4+n6dUIA==", + "dev": true + }, "@types/node": { "version": "18.14.1", "resolved": "https://registry.npmjs.org/@types/node/-/node-18.14.1.tgz", diff --git a/package.json b/package.json index c5a4e1c..2e80e80 100644 --- a/package.json +++ b/package.json @@ -5,10 +5,14 @@ ], "version": "1.2.2", "description": "Code Morph is an extensible, easy to understand, easy contribute, easy to use Codemod library.", - "main": "./dist/index.js", - "types": "./dist/index.d.ts", + "types": "./lib/cjs/types/index.d.ts", + "main": "./lib/cjs/index.js", "scripts": { - "build": "tsc", + "clean": "rm -rf ./lib", + "build": "npm run clean && npm run build:esm && npm run build:cjs", + "build:esm": "tsc -p ./tsconfig.esm.json && mv lib/esm/index.js lib/esm/index.mjs", + "build:cjs": "tsc -p ./tsconfig.cjs.json", + "prepack": "npm run build", "format": "prettier --write \"src/**/*.(js|ts)\"", "lint": "eslint src --ext .js,.ts", "lint:fix": "eslint src --fix --ext .js,.ts", @@ -56,6 +60,7 @@ "@angular/router": "^13.0.0", "@angular/service-worker": "^13.0.0", "@angular/upgrade": "^13.0.0", + "@types/glob": "^8.1.0", "@types/jest": "^27.5.2", "@types/lodash": "^4.14.192", "@types/resolve": "^1.20.2", @@ -98,7 +103,19 @@ "unist-util-visit": "2.0.3", "unist-util-visit-parents": "3.1.1" }, + "exports": { + ".": { + "import": { + "types": "./lib/esm/types/index.d.ts", + "default": "./lib/esm/index.mjs" + }, + "require": { + "types": "./lib/cjs/types/index.d.ts", + "default": "./lib/cjs/index.js" + } + } + }, "files": [ - "dist/**/*" + "lib/**/*" ] } diff --git a/tsconfig.base.json b/tsconfig.base.json index 05e2ed5..455ebed 100644 --- a/tsconfig.base.json +++ b/tsconfig.base.json @@ -1,19 +1,15 @@ { "compilerOptions": { - "target": "es2015", - "sourceMap": true, - "importHelpers": true, - "module": "esnext", - "moduleResolution": "node", - "outDir": "build", - "experimentalDecorators": true, - "emitDecoratorMetadata": true, + "strict": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": false, "skipLibCheck": true, - "types": ["node", "jest"], - "lib": ["es2021"], + "checkJs": true, + "allowJs": true, "declaration": true, - "resolveJsonModule": true, - "baseUrl": ".", - "rootDir": "." - } -} + "declarationMap": true, + "types": ["node", "jest"], + "allowSyntheticDefaultImports": true + }, + "files": ["./src/index.ts"] +} \ No newline at end of file diff --git a/tsconfig.cjs.json b/tsconfig.cjs.json new file mode 100644 index 0000000..3a7943f --- /dev/null +++ b/tsconfig.cjs.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": ["ES6", "DOM"], + "target": "ES6", + "module": "CommonJS", + "moduleResolution": "Node", + "outDir": "./lib/cjs", + "declarationDir": "./lib/cjs/types" + } +} \ No newline at end of file diff --git a/tsconfig.esm.json b/tsconfig.esm.json new file mode 100644 index 0000000..71eca35 --- /dev/null +++ b/tsconfig.esm.json @@ -0,0 +1,11 @@ +{ + "extends": "./tsconfig.base.json", + "compilerOptions": { + "lib": ["ES2021", "DOM"], + "target": "ES2021", + "module": "ESNext", + "moduleResolution": "node", + "outDir": "./lib/esm", + "declarationDir": "./lib/esm/types" + } +} \ No newline at end of file