From 25dcef405b274e97650a41881e0b2b13cf25f109 Mon Sep 17 00:00:00 2001 From: 1aron Date: Tue, 20 Feb 2024 18:25:00 +0800 Subject: [PATCH] New: Rollup-based JavaScript builder and bundler --- package.json | 11 +- .../package.json | 7 +- .../rollup.config.mjs | 8 + .../src/changelog.ts | 9 +- .../src/index.ts | 15 +- .../src/parser-opts.ts | 2 +- .../src/recommended-bump.ts | 8 +- .../src/writer-opts.ts | 14 +- .../tests/test.ts | 5 +- packages/conventional-commits/package.json | 1 - packages/cross-import/package.json | 11 +- packages/cross-import/rollup.config.mjs | 6 + packages/cross-import/src/index.ts | 2 +- .../cross-import/tests/{real.ts => real.mjs} | 6 +- packages/explore-config/jest.config.ts | 3 +- packages/explore-config/package.json | 11 +- packages/explore-config/rollup.config.mjs | 6 + packages/explore-config/tests/test.ts | 5 + packages/extend/package.json | 9 +- packages/extend/rollup.config.mjs | 6 + packages/extend/src/index.ts | 4 +- packages/fs/package.json | 9 +- packages/fs/rollup.config.mjs | 6 + packages/glob/package.json | 9 +- packages/glob/rollup.config.mjs | 6 + packages/is-plain-obj/package.json | 9 +- packages/is-plain-obj/rollup.config.mjs | 6 + packages/is-plain-obj/src/index.ts | 4 +- packages/jest/jest-preset.js | 10 +- packages/log/package.json | 9 +- packages/log/rollup.config.mjs | 6 + packages/log/src/error.ts | 2 +- packages/log/src/index.ts | 35 - packages/log/src/log.ts | 31 +- packages/log/src/utils/parse-error.ts | 26 +- packages/npm/package.json | 9 +- packages/npm/rollup.config.mjs | 6 + packages/semantic-release-config/configure.js | 4 +- packages/techor/{pack.md => build.md} | 128 +-- packages/techor/package.json | 46 +- packages/techor/rollup.config.mjs | 18 + packages/techor/src/bin/index.ts | 15 +- packages/techor/src/commands/build.ts | 375 +++++++ packages/techor/src/commands/pack.ts | 420 -------- packages/techor/src/commands/version.ts | 12 +- packages/techor/src/config.ts | 62 ++ packages/techor/src/index.ts | 6 + .../plugins/esbuild-plugin-autofill-mjs.ts | 57 -- ...d-remove-import-svelte-module-extension.ts | 27 - .../techor/src/plugins/esbuild-transform.ts | 43 + packages/techor/src/plugins/esm-shim.ts | 36 + packages/techor/src/plugins/raw-loader.ts | 21 + packages/techor/src/plugins/shakable-lib.ts | 21 - .../techor/src/utils/esbuild-option-names.ts | 68 -- .../techor/src/utils/get-wide-external.ts | 4 + packages/techor/src/utils/log-rollup-error.ts | 28 + .../techor/tests/args-externals/src/index.ts | 6 +- packages/techor/tests/args-externals/test.ts | 6 +- packages/techor/tests/auto/package.json | 11 + packages/techor/tests/auto/src/index.ts | 5 + packages/techor/tests/auto/test.ts | 22 + .../{specified-ext => auto}/tsconfig.json | 4 +- packages/techor/tests/css-args/pack.test.ts | 7 - packages/techor/tests/css-args/package.json | 10 - packages/techor/tests/css-args/src/float.css | 13 - packages/techor/tests/css-args/src/heart.css | 21 - packages/techor/tests/css-args/src/index.css | 2 - packages/techor/tests/css-bundle/package.json | 10 - .../techor/tests/css-bundle/src/float.css | 13 - .../techor/tests/css-bundle/src/heart.css | 21 - .../techor/tests/css-bundle/src/index.css | 2 - packages/techor/tests/css-bundle/test.ts | 7 - packages/techor/tests/css/package.json | 10 - packages/techor/tests/css/src/float.css | 13 - packages/techor/tests/css/src/heart.css | 21 - packages/techor/tests/css/src/index.css | 2 - packages/techor/tests/css/test.ts | 9 - .../techor/tests/entry-names/package.json | 11 - packages/techor/tests/entry-names/src/a.ts | 4 +- packages/techor/tests/entry-names/src/b.ts | 4 +- .../techor/tests/entry-names/src/c/index.ts | 3 + .../techor/tests/entry-names/src/index.ts | 7 +- packages/techor/tests/entry-names/test.ts | 6 +- packages/techor/tests/esm-bin/test.ts | 4 +- packages/techor/tests/exports/pack.test.ts | 4 +- packages/techor/tests/exports/package.json | 6 +- packages/techor/tests/exports/src/index.ts | 4 +- packages/techor/tests/external/package.json | 7 +- packages/techor/tests/external/src/index.ts | 13 +- packages/techor/tests/external/test.ts | 30 +- packages/techor/tests/global/package.json | 13 + .../techor/tests/global/src/global.min.ts | 1 + packages/techor/tests/global/src/global.ts | 17 + packages/techor/tests/global/test.ts | 20 + .../tests/{mjs => global}/tsconfig.json | 6 +- .../sources/packages/react/package.json | 1 - packages/techor/tests/master/test.ts | 2 +- packages/techor/tests/minify/package.json | 10 + packages/techor/tests/minify/src/index.ts | 5 + packages/techor/tests/minify/test.ts | 8 + packages/techor/tests/minify/tsconfig.json | 13 + packages/techor/tests/mjs/package.json | 19 - .../techor/tests/mjs/src/components/AAA.ts | 11 - .../techor/tests/mjs/src/components/BBB.ts | 3 - .../techor/tests/mjs/src/components/index.ts | 2 - packages/techor/tests/mjs/src/index.ts | 14 - packages/techor/tests/mjs/src/tree-shaking.ts | 3 - packages/techor/tests/mjs/src/utils/a-util.ts | 3 - packages/techor/tests/mjs/test.ts | 33 - .../techor/tests/multi-exports/pack.test.ts | 17 +- .../techor/tests/multi-exports/package.json | 25 +- packages/techor/tests/multi-exports/src/a.ts | 1 + packages/techor/tests/multi-exports/src/b.ts | 3 + .../tests/multi-exports/src/browser/index.ts | 2 + .../tests/multi-exports/src/index.browser.ts | 2 - .../tests/multi-exports/src/index.default.ts | 2 - .../techor/tests/multi-exports/src/index.ts | 5 +- .../techor/tests/multi-exports/src/options.ts | 3 - .../techor/tests/multi-exports/tsconfig.json | 2 +- packages/techor/tests/pnpm-lock.yaml | 31 +- .../techor/tests/raw-loader/declarations.d.ts | 4 + packages/techor/tests/raw-loader/package.json | 9 + packages/techor/tests/raw-loader/src/a.txt | 1 + packages/techor/tests/raw-loader/src/index.ts | 3 + .../techor/tests/raw-loader/techor.config.ts | 11 + packages/techor/tests/raw-loader/test.ts | 11 + .../techor/tests/raw-loader/tsconfig.json | 14 + packages/techor/tests/shim/package.json | 10 + packages/techor/tests/shim/src/a.ts | 1 + packages/techor/tests/shim/src/index.ts | 4 + packages/techor/tests/shim/test.ts | 22 + packages/techor/tests/shim/tsconfig.json | 13 + .../techor/tests/specified-ext/pack.test.ts | 7 - .../techor/tests/specified-ext/package.json | 14 - .../techor/tests/specified-ext/src/index.ts | 1 - packages/techor/tests/specified/package.json | 1 - packages/techor/tests/specified/src/index.ts | 2 +- packages/techor/tests/specified/test.ts | 6 +- packages/techor/tests/src/a.txt | 1 + packages/techor/tests/standard/package.json | 8 +- .../tests/standard/src/options/index.ts | 4 +- packages/techor/tests/standard/test.ts | 48 +- packages/techor/tests/tsx/test.ts | 2 +- packages/techor/tests/type/package.json | 3 +- packages/techor/tests/type/src/foo/index.ts | 3 + packages/techor/tests/type/src/index.ts | 7 +- packages/techor/tests/type/test.ts | 8 +- packages/techor/tsconfig.json | 2 +- pnpm-lock.yaml | 968 ++++++++++++++++-- rollup.config.mjs | 91 ++ tsconfig.json | 3 + 151 files changed, 2201 insertions(+), 1399 deletions(-) create mode 100644 packages/conventional-changelog-config/rollup.config.mjs create mode 100644 packages/cross-import/rollup.config.mjs rename packages/cross-import/tests/{real.ts => real.mjs} (85%) create mode 100644 packages/explore-config/rollup.config.mjs create mode 100644 packages/extend/rollup.config.mjs create mode 100644 packages/fs/rollup.config.mjs create mode 100644 packages/glob/rollup.config.mjs create mode 100644 packages/is-plain-obj/rollup.config.mjs create mode 100644 packages/log/rollup.config.mjs create mode 100644 packages/npm/rollup.config.mjs rename packages/techor/{pack.md => build.md} (65%) create mode 100644 packages/techor/rollup.config.mjs create mode 100644 packages/techor/src/commands/build.ts delete mode 100644 packages/techor/src/commands/pack.ts create mode 100644 packages/techor/src/config.ts create mode 100644 packages/techor/src/index.ts delete mode 100644 packages/techor/src/plugins/esbuild-plugin-autofill-mjs.ts delete mode 100644 packages/techor/src/plugins/esbuild-remove-import-svelte-module-extension.ts create mode 100644 packages/techor/src/plugins/esbuild-transform.ts create mode 100644 packages/techor/src/plugins/esm-shim.ts create mode 100644 packages/techor/src/plugins/raw-loader.ts delete mode 100644 packages/techor/src/plugins/shakable-lib.ts delete mode 100644 packages/techor/src/utils/esbuild-option-names.ts create mode 100644 packages/techor/src/utils/get-wide-external.ts create mode 100644 packages/techor/src/utils/log-rollup-error.ts create mode 100644 packages/techor/tests/auto/package.json create mode 100644 packages/techor/tests/auto/src/index.ts create mode 100644 packages/techor/tests/auto/test.ts rename packages/techor/tests/{specified-ext => auto}/tsconfig.json (74%) delete mode 100644 packages/techor/tests/css-args/pack.test.ts delete mode 100644 packages/techor/tests/css-args/package.json delete mode 100644 packages/techor/tests/css-args/src/float.css delete mode 100644 packages/techor/tests/css-args/src/heart.css delete mode 100644 packages/techor/tests/css-args/src/index.css delete mode 100644 packages/techor/tests/css-bundle/package.json delete mode 100644 packages/techor/tests/css-bundle/src/float.css delete mode 100644 packages/techor/tests/css-bundle/src/heart.css delete mode 100644 packages/techor/tests/css-bundle/src/index.css delete mode 100644 packages/techor/tests/css-bundle/test.ts delete mode 100644 packages/techor/tests/css/package.json delete mode 100644 packages/techor/tests/css/src/float.css delete mode 100644 packages/techor/tests/css/src/heart.css delete mode 100644 packages/techor/tests/css/src/index.css delete mode 100644 packages/techor/tests/css/test.ts delete mode 100644 packages/techor/tests/entry-names/package.json create mode 100644 packages/techor/tests/entry-names/src/c/index.ts create mode 100644 packages/techor/tests/global/package.json create mode 100644 packages/techor/tests/global/src/global.min.ts create mode 100644 packages/techor/tests/global/src/global.ts create mode 100644 packages/techor/tests/global/test.ts rename packages/techor/tests/{mjs => global}/tsconfig.json (64%) create mode 100644 packages/techor/tests/minify/package.json create mode 100644 packages/techor/tests/minify/src/index.ts create mode 100644 packages/techor/tests/minify/test.ts create mode 100644 packages/techor/tests/minify/tsconfig.json delete mode 100644 packages/techor/tests/mjs/package.json delete mode 100644 packages/techor/tests/mjs/src/components/AAA.ts delete mode 100644 packages/techor/tests/mjs/src/components/BBB.ts delete mode 100644 packages/techor/tests/mjs/src/components/index.ts delete mode 100644 packages/techor/tests/mjs/src/index.ts delete mode 100644 packages/techor/tests/mjs/src/tree-shaking.ts delete mode 100644 packages/techor/tests/mjs/src/utils/a-util.ts delete mode 100644 packages/techor/tests/mjs/test.ts create mode 100644 packages/techor/tests/multi-exports/src/a.ts create mode 100644 packages/techor/tests/multi-exports/src/b.ts create mode 100644 packages/techor/tests/multi-exports/src/browser/index.ts delete mode 100644 packages/techor/tests/multi-exports/src/index.browser.ts delete mode 100644 packages/techor/tests/multi-exports/src/index.default.ts delete mode 100644 packages/techor/tests/multi-exports/src/options.ts create mode 100644 packages/techor/tests/raw-loader/declarations.d.ts create mode 100644 packages/techor/tests/raw-loader/package.json create mode 100644 packages/techor/tests/raw-loader/src/a.txt create mode 100644 packages/techor/tests/raw-loader/src/index.ts create mode 100644 packages/techor/tests/raw-loader/techor.config.ts create mode 100644 packages/techor/tests/raw-loader/test.ts create mode 100644 packages/techor/tests/raw-loader/tsconfig.json create mode 100644 packages/techor/tests/shim/package.json create mode 100644 packages/techor/tests/shim/src/a.ts create mode 100644 packages/techor/tests/shim/src/index.ts create mode 100644 packages/techor/tests/shim/test.ts create mode 100644 packages/techor/tests/shim/tsconfig.json delete mode 100644 packages/techor/tests/specified-ext/pack.test.ts delete mode 100644 packages/techor/tests/specified-ext/package.json delete mode 100644 packages/techor/tests/specified-ext/src/index.ts create mode 100644 packages/techor/tests/src/a.txt create mode 100644 packages/techor/tests/type/src/foo/index.ts create mode 100644 rollup.config.mjs diff --git a/package.json b/package.json index f3e4d97..6f3abe9 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ }, "devDependencies": { "@techor/jest": "workspace:^", + "@techor/jest-dom": "workspace:^", "@types/fs-extra": "^9.0.13", "@types/node": "^20.11.0", "commitlint-config-techor": "workspace:^", @@ -36,14 +37,20 @@ "jest-puppeteer": "^6.1.1", "parent-module": "^3.0.0", "puppeteer": "^21.0.1", + "rollup": "^4.11.0", "semantic-release-config-techor": "workspace:^", "strip-ansi": "^7.0.1", - "sucrase": "^3.32.0", "tmp": "^0.2.1", "ts-dedent": "^2.2.0", - "tsx": "^3.12.6" + "tsx": "^4.7.1", + "typescript": "^5.3.3" }, "dependencies": { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-swc": "^0.3.0", + "@rollup/plugin-typescript": "^11.1.6", + "@rollup/pluginutils": "^5.1.0", "cross-env": "^7.0.3", "turbo": "^1.11.2" }, diff --git a/packages/conventional-changelog-config/package.json b/packages/conventional-changelog-config/package.json index 0419eec..8c88ccb 100644 --- a/packages/conventional-changelog-config/package.json +++ b/packages/conventional-changelog-config/package.json @@ -1,8 +1,10 @@ { "name": "conventional-changelog-techor", "scripts": { - "build": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --loader:.hbs=file --asset-names=[dir]/[name] --platform=node --external:esbuild --external:fast-glob --external:require-from-string --external:@techor/extend --external:@techor/fs --external:upath", - "dev": "pnpm build --watch", + "build:main": "rollup --config rollup.config.mjs", + "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", + "build": "pnpm run \"/^build:.*/\"", + "dev": "pnpm run \"/^build:.*/\" --watch", "test": "pnpm build && jest", "type-check": "tsc --noEmit", "lint": "eslint src" @@ -34,6 +36,7 @@ "preset" ], "main": "./dist/index.js", + "types": "./dist/index.d.ts", "files": [ "dist" ], diff --git a/packages/conventional-changelog-config/rollup.config.mjs b/packages/conventional-changelog-config/rollup.config.mjs new file mode 100644 index 0000000..51109a8 --- /dev/null +++ b/packages/conventional-changelog-config/rollup.config.mjs @@ -0,0 +1,8 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions, + input: 'src/index.ts', + output: { file: 'dist/index.js', format: 'cjs' }, +} \ No newline at end of file diff --git a/packages/conventional-changelog-config/src/changelog.ts b/packages/conventional-changelog-config/src/changelog.ts index c095268..75bebf5 100644 --- a/packages/conventional-changelog-config/src/changelog.ts +++ b/packages/conventional-changelog-config/src/changelog.ts @@ -1,4 +1,7 @@ -module.exports = { - parserOpts: require('./parser-opts'), - writerOpts: require('./writer-opts') +import parserOpts from './parser-opts' +import writerOpts from './writer-opts' + +export default { + parserOpts, + writerOpts } diff --git a/packages/conventional-changelog-config/src/index.ts b/packages/conventional-changelog-config/src/index.ts index ed877e3..b1996dc 100644 --- a/packages/conventional-changelog-config/src/index.ts +++ b/packages/conventional-changelog-config/src/index.ts @@ -1,6 +1,11 @@ -module.exports = async () => ({ - conventionalChangelog: require('./changelog'), - parserOpts: require('./parser-opts'), - recommendedBumpOpts: require('./recommended-bump'), - writerOpts: require('./writer-opts') +import conventionalChangelog from './changelog' +import parserOpts from './parser-opts' +import recommendedBumpOpts from './recommended-bump' +import writerOpts from './writer-opts' + +export default async () => ({ + conventionalChangelog, + parserOpts, + recommendedBumpOpts, + writerOpts }) \ No newline at end of file diff --git a/packages/conventional-changelog-config/src/parser-opts.ts b/packages/conventional-changelog-config/src/parser-opts.ts index 450cc28..f4c551e 100644 --- a/packages/conventional-changelog-config/src/parser-opts.ts +++ b/packages/conventional-changelog-config/src/parser-opts.ts @@ -1,4 +1,4 @@ -module.exports = { +export default { headerPattern: /^([A-Z]\w*)(?:\(([0-9A-Z`_#~].*)\))?: ([0-9A-Z`_#~].*)$/, headerCorrespondence: [ 'type', diff --git a/packages/conventional-changelog-config/src/recommended-bump.ts b/packages/conventional-changelog-config/src/recommended-bump.ts index c173b31..05ef05e 100644 --- a/packages/conventional-changelog-config/src/recommended-bump.ts +++ b/packages/conventional-changelog-config/src/recommended-bump.ts @@ -1,7 +1,7 @@ -const parserOpts = require('./parser-opts') -const { commits: aronCommits } = require('techor-conventional-commits') +import parserOpts from './parser-opts' +import { commits as techorCommits } from 'techor-conventional-commits' -module.exports = { +export default { parserOpts, whatBump: (commits) => { let level = null @@ -9,7 +9,7 @@ module.exports = { let MinorCount = 0 let patchCount = 0 commits.forEach(({ type }) => { - const conventionalCommit = aronCommits.find(({ type: eachType }) => eachType === type) + const conventionalCommit = techorCommits.find(({ type: eachType }) => eachType === type) if (conventionalCommit) { switch (conventionalCommit.release) { case 'major': diff --git a/packages/conventional-changelog-config/src/writer-opts.ts b/packages/conventional-changelog-config/src/writer-opts.ts index 0a4d47b..6906f5d 100644 --- a/packages/conventional-changelog-config/src/writer-opts.ts +++ b/packages/conventional-changelog-config/src/writer-opts.ts @@ -1,17 +1,11 @@ import compareFunc from 'compare-func' import { commits } from 'techor-conventional-commits' -import mainTemplatePath from './templates/template.hbs' -import footerPartialPath from './templates/footer.hbs' -import commitPartialPath from './templates/commit.hbs' -import { readFileSync } from 'fs' -import path from 'path' +import mainTemplate from './templates/template.hbs' +import footerPartial from './templates/footer.hbs' +import commitPartial from './templates/commit.hbs' import https from 'node:https' -const mainTemplate = readFileSync(path.resolve(__dirname, mainTemplatePath), 'utf-8') -const footerPartial = readFileSync(path.resolve(__dirname, footerPartialPath), 'utf-8') -const commitPartial = readFileSync(path.resolve(__dirname, commitPartialPath), 'utf-8') - -module.exports = { +export default { transform: async (commit, context) => { const issues = [] if (commit.header) { diff --git a/packages/conventional-changelog-config/tests/test.ts b/packages/conventional-changelog-config/tests/test.ts index b420778..dacf785 100644 --- a/packages/conventional-changelog-config/tests/test.ts +++ b/packages/conventional-changelog-config/tests/test.ts @@ -1,11 +1,10 @@ -import fs, { writeFile, writeFileSync } from 'fs' +import fs, { writeFileSync } from 'fs' import path, { resolve } from 'path' import exec from '../../../utils/exec' import commit from '../../../utils/commit' import initFakeGit from '../../../utils/init-fake-git' import dotenv from 'dotenv' - -const createPreset = require('../dist') +import createPreset from '../dist' const conventionalChangelogCore = require('conventional-changelog-core') dotenv.config({ path: path.resolve(__dirname, '../../../.env') }) diff --git a/packages/conventional-commits/package.json b/packages/conventional-commits/package.json index dfbcf80..9d7fbe4 100644 --- a/packages/conventional-commits/package.json +++ b/packages/conventional-commits/package.json @@ -40,7 +40,6 @@ "preset" ], "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/packages/cross-import/package.json b/packages/cross-import/package.json index 7b7c61c..cf3f64e 100644 --- a/packages/cross-import/package.json +++ b/packages/cross-import/package.json @@ -1,12 +1,12 @@ { "name": "cross-import", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", - "build:esm": "esbuild src/index.ts --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", - "test": "node -r sucrase/register ./tests/real && jest", + "test": "pnpm build:main && node ./tests/real.mjs && jest", "type-check": "tsc --noEmit", "lint": "eslint src" }, @@ -43,14 +43,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/cross-import/rollup.config.mjs b/packages/cross-import/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/cross-import/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/cross-import/src/index.ts b/packages/cross-import/src/index.ts index eb10b24..04c6382 100644 --- a/packages/cross-import/src/index.ts +++ b/packages/cross-import/src/index.ts @@ -1,4 +1,4 @@ -import jiti from 'jiti/dist/jiti' +import jiti from 'jiti' import { transform } from 'sucrase' export default function crossImport(modulePath: string): any { diff --git a/packages/cross-import/tests/real.ts b/packages/cross-import/tests/real.mjs similarity index 85% rename from packages/cross-import/tests/real.ts rename to packages/cross-import/tests/real.mjs index 53e9f31..f17685a 100644 --- a/packages/cross-import/tests/real.ts +++ b/packages/cross-import/tests/real.mjs @@ -1,6 +1,10 @@ -import crossImport from '../src' +import crossImport from '../dist/index.mjs' import fs from 'fs' import path from 'path' +import { fileURLToPath } from 'url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) /** * 測試 require cache 在真實 Node 環境運作時是否有被正確的清除 diff --git a/packages/explore-config/jest.config.ts b/packages/explore-config/jest.config.ts index 93ee4d5..52dac0a 100644 --- a/packages/explore-config/jest.config.ts +++ b/packages/explore-config/jest.config.ts @@ -1,4 +1,5 @@ /** @type {import('jest').Config} */ export default { - preset: '@techor/jest' + preset: '@techor/jest', + transformIgnorePatterns: ['node_modules/(?!callsites)/'] } diff --git a/packages/explore-config/package.json b/packages/explore-config/package.json index 75ce2f0..8c6cde5 100644 --- a/packages/explore-config/package.json +++ b/packages/explore-config/package.json @@ -1,12 +1,12 @@ { "name": "explore-config", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node --external:@techor/extend --external:@techor/log --external:@techor/log --external:@techor/glob --external:cross-import", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node --external:@techor/extend --external:@techor/log --external:@techor/log --external:@techor/glob --external:cross-import", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", - "test": "jest", + "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest", "type-check": "tsc --noEmit", "lint": "eslint src" }, @@ -37,14 +37,13 @@ "explore" ], "sideEffects": false, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/explore-config/rollup.config.mjs b/packages/explore-config/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/explore-config/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/explore-config/tests/test.ts b/packages/explore-config/tests/test.ts index e208a40..eeb0ec5 100644 --- a/packages/explore-config/tests/test.ts +++ b/packages/explore-config/tests/test.ts @@ -1,4 +1,9 @@ import exploreConfig from '../src' +import path from 'node:path' +import { fileURLToPath } from 'node:url' + +const __filename = fileURLToPath(import.meta.url) +const __dirname = path.dirname(__filename) it('read .js config', () => { const config = exploreConfig('master.css.js', { cwd: __dirname }) diff --git a/packages/extend/package.json b/packages/extend/package.json index 4f7474e..f440a4e 100644 --- a/packages/extend/package.json +++ b/packages/extend/package.json @@ -1,8 +1,8 @@ { "name": "@techor/extend", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -36,14 +36,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/extend/rollup.config.mjs b/packages/extend/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/extend/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/extend/src/index.ts b/packages/extend/src/index.ts index 28be0db..15dceec 100644 --- a/packages/extend/src/index.ts +++ b/packages/extend/src/index.ts @@ -107,6 +107,4 @@ export default function extend(...sources: any[]) { }) return target -} - -export { extend } \ No newline at end of file +} \ No newline at end of file diff --git a/packages/fs/package.json b/packages/fs/package.json index b5543b6..d2ff35a 100644 --- a/packages/fs/package.json +++ b/packages/fs/package.json @@ -1,8 +1,8 @@ { "name": "@techor/fs", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -42,14 +42,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/fs/rollup.config.mjs b/packages/fs/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/fs/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/glob/package.json b/packages/glob/package.json index 971e1e7..2cc869d 100644 --- a/packages/glob/package.json +++ b/packages/glob/package.json @@ -1,8 +1,8 @@ { "name": "@techor/glob", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node --external:fast-glob --external:upath", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node --external:fast-glob --external:upath", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -39,14 +39,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/glob/rollup.config.mjs b/packages/glob/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/glob/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/is-plain-obj/package.json b/packages/is-plain-obj/package.json index 6470bff..ff42407 100644 --- a/packages/is-plain-obj/package.json +++ b/packages/is-plain-obj/package.json @@ -1,8 +1,8 @@ { "name": "@techor/is-plain-obj", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -35,14 +35,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/is-plain-obj/rollup.config.mjs b/packages/is-plain-obj/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/is-plain-obj/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/is-plain-obj/src/index.ts b/packages/is-plain-obj/src/index.ts index 3ee2ca7..de823d1 100644 --- a/packages/is-plain-obj/src/index.ts +++ b/packages/is-plain-obj/src/index.ts @@ -2,6 +2,4 @@ export default function aPlainObj(target: any) { return target === null ? false : (target?.constructor?.name === 'Object' || typeof target === 'object' && !target?.__proto__) // for Object.create({}) -} - -export { aPlainObj } \ No newline at end of file +} \ No newline at end of file diff --git a/packages/jest/jest-preset.js b/packages/jest/jest-preset.js index f44ff67..fc60253 100644 --- a/packages/jest/jest-preset.js +++ b/packages/jest/jest-preset.js @@ -1,7 +1,15 @@ module.exports = { transform: { - '^.+\\.(t|j)sx?$': '@swc/jest' + '^.+\\.(t|j)sx?$': [ + '@swc/jest', + { + jsc: { + target: 'es2021', + }, + }, + ], }, + extensionsToTreatAsEsm: ['.ts', '.tsx'], globals: { 'ts-jest': { tsConfig: { diff --git a/packages/log/package.json b/packages/log/package.json index 054a924..b62109e 100644 --- a/packages/log/package.json +++ b/packages/log/package.json @@ -1,9 +1,9 @@ { "name": "@techor/log", + "type": "module", "license": "MIT", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -32,14 +32,13 @@ "chalk", "semantic" ], - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/log/rollup.config.mjs b/packages/log/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/log/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/log/src/error.ts b/packages/log/src/error.ts index b2e41a9..8f1fd73 100644 --- a/packages/log/src/error.ts +++ b/packages/log/src/error.ts @@ -2,7 +2,7 @@ import chalk from 'chalk' import processLog from './process-log' const error= (strings: TemplateStringsArray, ...slots: any[]) => { - const message = chalk.bgRed.bold.white(' 𝗫 ERROR ') + ' ' + processLog(strings, slots) + const message = chalk.bgRed.bold.white(' 𝗫 Error ') + ' ' + processLog(strings, slots) console.log(message) return message } diff --git a/packages/log/src/index.ts b/packages/log/src/index.ts index 707178c..bd62380 100644 --- a/packages/log/src/index.ts +++ b/packages/log/src/index.ts @@ -1,38 +1,3 @@ import { log } from './log' -import { add } from './add' -import { error } from './error' -import { conflict } from './conflict' -import { ok } from './ok' -import { del } from './del' -import { valid } from './valid' -import { invalid } from './invalid' -import { info } from './info' -import { success } from './success' -import { warn } from './warn' -import { pass } from './pass' -import { tree } from './tree' -import { fail } from './fail' -import { paint } from './paint' - -import chalk from 'chalk' - -export { - add as a, add, - del as d, del, - valid as o, valid, - invalid as x, invalid, - info as i, info, - success, - error as e, error, - fail, - warn, - pass, - conflict, - ok, - - tree, - paint, - chalk -} export default log \ No newline at end of file diff --git a/packages/log/src/log.ts b/packages/log/src/log.ts index 425df50..3cb9aa1 100644 --- a/packages/log/src/log.ts +++ b/packages/log/src/log.ts @@ -21,15 +21,25 @@ import chalk from 'chalk' // @ts-ignore const log: Log = ((strings, ...slots) => { if (strings instanceof Error) { - const { message, stackTree } = parseError(strings) + const error = strings + const { message, stackTree } = parseError(error) console.log('') - console.log(chalk.bgRed.bold.white(' 𝗫 ERROR ') + ' ' + chalk.bold.red(message)) - console.log(treeify(stackTree, { - spacerNeighbour: chalk.redBright.dim('│  '), - keyNoNeighbour: chalk.redBright.dim('└ '), - keyNeighbour: chalk.redBright.dim('├ '), - separator: chalk.redBright.dim(': ') - })) + console.log(chalk.bgRed.bold.white(` 𝗫 ${error.name || error['code'] || 'Error'} `) + ' ' + chalk.bold.red(message)) + if (stackTree) { + console.log(treeify(stackTree, { + spacerNeighbour: chalk.redBright.dim('│  '), + keyNoNeighbour: chalk.redBright.dim('└ '), + keyNeighbour: chalk.redBright.dim('├ '), + separator: chalk.redBright.dim(': ') + })) + } else { + console.log('') + console.log({ ...error }) + } + if (error.cause) { + console.log('') + console.log(chalk.redBright('Caused by:') + ' ' + error.cause) + } console.log('') return message } else { @@ -54,7 +64,8 @@ Object.assign(log, { conflict, ok, tree, - paint + paint, + chalk }) export { log } @@ -76,4 +87,6 @@ export interface Log { a: Log, add: Log // load: (event: string, message: string, options: any) => any tree: (object: object | JSON) => void + paint: typeof paint + chalk: typeof chalk } \ No newline at end of file diff --git a/packages/log/src/utils/parse-error.ts b/packages/log/src/utils/parse-error.ts index fcab87e..79b4c22 100644 --- a/packages/log/src/utils/parse-error.ts +++ b/packages/log/src/utils/parse-error.ts @@ -1,8 +1,8 @@ import dedent from 'dedent' import chalk from 'chalk' -export function parseError(error: any) { - const { message, stack } = typeof error === 'string' ? new Error(error as any) : error +export function parseError(error: Error) { + const { message, stack } = error const stackTree = {} dedent(stack .replace(message, '') @@ -10,21 +10,21 @@ export function parseError(error: any) { ) .split('\n') .forEach((line: string) => { - stackTree[ - line - .split(' ') - .map((eachSplit) => eachSplit - .replace(/^\((.+)\)$/, `${chalk.cyan('$1')}`) - .replace(/\./g, `${chalk.dim('.')}`) - .replace(/^at$/, m => chalk.dim(m)) - ) - .join(' ') - ] = null + const text = line + .split(' ') + .map((eachSplit) => eachSplit + .replace(/^\((.+)\)$/, `${chalk.gray('$1')}`) + .replace(/\./g, `${chalk.dim('.')}`) + .replace(/^at$/, m => chalk.dim(m)) + ) + .join(' ') + if (text) + stackTree[text] = null }) return { message: message .trim() .replace(/Error: /g, ''), - stackTree + stackTree: Object.keys(stackTree).length ? stackTree : null } } \ No newline at end of file diff --git a/packages/npm/package.json b/packages/npm/package.json index e854874..98a4b1d 100644 --- a/packages/npm/package.json +++ b/packages/npm/package.json @@ -1,8 +1,8 @@ { "name": "@techor/npm", + "type": "module", "scripts": { - "build:cjs": "esbuild src/index.ts --bundle --outfile=dist/index.js --format=cjs --minify --sourcemap --platform=node --external:esbuild --external:@techor/glob --external:@techor/extend --external:@techor/fs --external:@techor/log --external:js-yaml", - "build:esm": "esbuild src/index.ts --bundle --outfile=dist/index.mjs --format=esm --minify --sourcemap --platform=node --external:esbuild --external:@techor/glob --external:@techor/extend --external:@techor/fs --external:@techor/log --external:js-yaml", + "build:main": "rollup --config rollup.config.mjs", "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", "build": "pnpm run \"/^build:.*/\"", "dev": "pnpm run \"/^build:.*/\" --watch", @@ -40,14 +40,13 @@ "publishConfig": { "access": "public" }, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", + "main": "./dist/index.cjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.js", + "require": "./dist/index.cjs", "import": "./dist/index.mjs", "types": "./dist/index.d.ts" } diff --git a/packages/npm/rollup.config.mjs b/packages/npm/rollup.config.mjs new file mode 100644 index 0000000..b6954e2 --- /dev/null +++ b/packages/npm/rollup.config.mjs @@ -0,0 +1,6 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default { + ...commonOptions +} \ No newline at end of file diff --git a/packages/semantic-release-config/configure.js b/packages/semantic-release-config/configure.js index 04342ce..ab76d50 100644 --- a/packages/semantic-release-config/configure.js +++ b/packages/semantic-release-config/configure.js @@ -1,9 +1,9 @@ const path = require('path') const releaseRules = require('./rules') -const extend = require('@techor/extend').default +const extend = require('@techor/extend') const { explorePackageManager, readPNPMWorkspaces, readWorkspaces, queryWorkspaces } = require('@techor/npm') const { readJSONFileSync } = require('@techor/fs') -const log = require('@techor/log').default +const log = require('@techor/log') const defaultConfig = { branches: [ diff --git a/packages/techor/pack.md b/packages/techor/build.md similarity index 65% rename from packages/techor/pack.md rename to packages/techor/build.md index 93cde5e..3c08b2c 100644 --- a/packages/techor/pack.md +++ b/packages/techor/build.md @@ -10,7 +10,7 @@

-

Bundling your TypeScript and CSS packages with zero configuration

+

Build a perfect JavaScript package with a one-liner command

@@ -20,11 +20,11 @@ NPM Version - + - - - NPM package ( download / month ) + + + NPM package ( download / month ) @@ -46,31 +46,28 @@ ## Features - -- An extremely fast bundler built on top of [esbuild](https://esbuild.github.io/) +- An extremely fast JavaScript bundler built on top of [Rollup](https://rollupjs.org/) and [SWC](https://swc.rs/) - Output or watch multiple formats in one-linear command - Support **ESM**, **CJS**, and **IIFE** JavaScript modules -- Support **CSS** bundle - Generate `.d.ts` type declarations - Extract options from `package.json` -- Prevent bundling `dependencies` and `peerDependencies` by `package.json` +- Prevent bundling `dependencies`, `peerDependencies`, `optionalDependencies` by `package.json`
## Getting Started ```bash -npm i @techor/pack +npm i techor ``` ## Usage ```bash -techor pack [entryPaths...] -techor-pack [entryPaths...] +techor build [entryPaths...] ``` [Check out the available options here for now](https://github.com/1aron/techor/blob/beta/packages/techo/src/bin/index.ts) -`techor pack` analyzes the `package.json` entry point relative to input sources in the `src` directory for builds. +`techor build` analyzes the `package.json` entry point relative to input sources in the `src` directory for builds. ### JavaScript packages @@ -81,12 +78,12 @@ techor-pack [entryPaths...] └─── a ├─── src │ ├─── index.ts - │ └─── index.browser.ts + │ └─── global.ts + ├─── dist + │ ├─── index.js + │ ├─── index.mjs + │ ├─── index.d.ts -+ │ └─── index.browser.ts ++ │ └─── global.ts └─── package.json ``` @@ -96,14 +93,13 @@ Simultaneously output `cjs`, `esm`, `iife`, `type declarations` respectively acc { "name": "a", "scripts": { - "build": "ts-node ../techor/src/bin pack", + "build": "ts-node ../techor/src/bin build", "dev": "pnpm run build --watch" }, "main": "dist/index.js", - "browser": "dist/index.browser.js", + "browser": "dist/global.js", "module": "dist/index.js", "types": "dist/index.d.ts", - "jsnext:main": "dist/index.js", "esnext": "dist/index.js", "exports": { ".": { @@ -117,7 +113,7 @@ Simultaneously output `cjs`, `esm`, `iife`, `type declarations` respectively acc ] } ``` -If you only want to pack specific javascript modules, remove the corresponding entry point from `package.json`. +If you only want to build specific javascript modules, remove the corresponding entry point from `package.json`. Run with the above configuration: @@ -125,7 +121,7 @@ Run with the above configuration: pnpm run build ``` -cjs-esm-iife-type-pack +cjs-esm-iife-type-build Now import the above package `a` in your project or publish it. @@ -133,54 +129,9 @@ Now import the above package `a` in your project or publish it. import 'a' ``` -### CSS packages - -```diff -. -├── package.json -└── packages - └─── b - ├─── src - │ └─── index.css -+ ├─── dist -+ │ └─── index.css - └─── package.json -``` - -Packaging CSS is more straightforward, configuring `style` and `main` entry points in `package.json`. - -```json -{ - "name": "b", - "scripts": { - "build": "ts-node ../techor/src/bin pack", - "dev": "pnpm run build --watch" - }, - "main": "./dist/index.css", - "style": "./dist/index.css", - "files": [ - "dist" - ] -} -``` - -Run with the above configuration: - -```bash -pnpm run build -``` - -css-pack - -Now import the above package `b` in your project or publish it. - -```css -@import 'b' -``` - ### Multiple entry points -`techor pack ` supports glob patterns that let you specify multiple entry points at once, including the output of nested directories. +`techor build ` supports glob patterns that let you specify multiple entry points at once, including the output of nested directories. Specifying an entry point will cause the JavaScript output `format` to be preset to `cjs,esm`. @@ -204,31 +155,9 @@ techor src/**/*.ts + │ └─── exec.mjs └─── package.json ``` -The same goes for multiple CSS entries: -``` -techor src/**/*.css -``` -```diff -. -├── package.json -└── packages - └─── a - ├─── src - │ ├─── index.css - │ └─── components - │ ├─── card.css - │ └─── button.css -+ ├─── dist -+ │ ├─── index.css -+ │ └─── components -+ │ ├─── card.css -+ │ └─── button.css - └─── package.json -``` -Usually, it would be best to bundle CSS packages through a main `index.css` and output other CSS files so developers can import on demand instead of the whole package. For example [@master/keyframes.css](https://www.npmjs.com/package/@master/keyframes.css) ### Exclude external dependencies -`techor pack` automatically excludes external dependencies to be bundled by the `.dependencies` and `peerDependencies` of `package.json` +`techor build` automatically excludes external dependencies to be bundled by the `.dependencies` and `peerDependencies` of `package.json` `src/index.ts` ```ts @@ -265,18 +194,18 @@ import '@master/style-element.react' Run with the above setup: ```bash -techor pack --platform node +techor build --platform node ``` -exclude-externals-pack +exclude-externals-build `@master/css.webpack` is bundled into `dist/index.js`, except for `@master/css` and `@master/style-element.react`. -So if there is an external package that needs to be bundled, you just install it to `devDependencies` via `npm i --save-dev`, then `techor pack` will not exclude it. +So if there is an external package that needs to be bundled, you just install it to `devDependencies` via `npm i --save-dev`, then `techor build` will not exclude it. ### Multiple outputs -`techor pack` defaults to pack multiple outputs with different formats and platforms according to `exports` `bin` in `package.json`. +`techor build` defaults to build multiple outputs with different formats and platforms according to `exports` `bin` in `package.json`. ```diff . @@ -311,19 +240,10 @@ So if there is an external package that needs to be bundled, you just install it } } ``` -Any nested conditions in `exports` like `node`, `browser`, `default`, `require`, and `import` will be mapped to ESBuild’s `format` and `platform` options. +Any nested conditions in `exports` like `node`, `browser`, `default`, `require`, and `import` will be mapped to Rollup's `format` and `platform` options. ## Options -### `mangleProps` -```bash -techor pack --mangle-props '^_' -``` -```diff -- module.exports._parse = parse; -- module.exports._enoent = enoent; -+ module.exports.b = parse; -+ module.exports.c = enoent; -``` +https://github.com/1aron/techor/tree/main/packages/techor/src/config.ts
diff --git a/packages/techor/package.json b/packages/techor/package.json index 6404142..e11d872 100644 --- a/packages/techor/package.json +++ b/packages/techor/package.json @@ -1,8 +1,10 @@ { "name": "techor", "scripts": { - "build": "tsx src/bin pack --platform node", - "dev": "pnpm run build --watch", + "build:main": "rollup --config rollup.config.mjs", + "build:type": "tsc --emitDeclarationOnly --preserveWatchOutput", + "build": "pnpm run \"/^build:.*/\"", + "dev": "pnpm run \"/^build:.*/\" --watch", "test": "cd tests && pnpm i && cd ../ && jest", "type-check": "tsc --noEmit", "lint": "eslint src" @@ -36,7 +38,6 @@ "tool", "software", "pack", - "esbuild", "version", "bump", "bundle", @@ -45,7 +46,18 @@ "esmodule" ], "bin": { - "techor": "./dist/bin/index.bundle.mjs" + "techor": "./dist/bin/index.mjs" + }, + "main": "./dist/index.cjs", + "esnext": "./dist/index.mjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "require": "./dist/index.cjs", + "import": "./dist/index.mjs", + "types": "./dist/index.d.ts" + } }, "files": [ "dist" @@ -55,21 +67,33 @@ "access": "public" }, "dependencies": { + "@rollup/plugin-commonjs": "^25.0.7", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-swc": "^0.3.0", + "@swc/core": "^1.3.106", + "@techor/extend": "workspace:^", "@techor/fs": "workspace:^", + "@techor/glob": "workspace:^", "@techor/log": "workspace:^", "@techor/npm": "workspace:^", - "commander": "^11.0.0", - "@techor/extend": "workspace:^", - "@techor/glob": "workspace:^", "clsx": "^2.0.0", - "esbuild": "^0.18.11", + "commander": "^11.0.0", + "esbuild": "^0.20.1", + "escodegen": "^2.1.0", + "execa": "^7.2.0", "explore-config": "workspace:^", + "hrtime": "^0.5.0", "lodash.isequal": "^4.5.0", - "upath": "^2.0.1", - "execa": "^7.1.1", + "magic-string": "^0.30.7", "pkg-types": "^1.0.1", "pretty-bytes": "^6.1.0", - "pretty-hrtime": "^1.0.3" + "pretty-hrtime": "^1.0.3", + "rollup": "^4.11.0", + "rollup-plugin-swc-minify": "^1.1.0", + "rollup-plugin-ts": "^3.4.5", + "trim-newlines": "^5.0.0", + "upath": "^2.0.1", + "wide-align": "^1.1.5" }, "devDependencies": { "dedent": "^0.7.0" diff --git a/packages/techor/rollup.config.mjs b/packages/techor/rollup.config.mjs new file mode 100644 index 0000000..5e9d6ab --- /dev/null +++ b/packages/techor/rollup.config.mjs @@ -0,0 +1,18 @@ +import commonOptions from '../../rollup.config.mjs' + +/** @type {import('rollup').RollupOptions} */ +export default [ + { + ...commonOptions, + input: 'src/bin/index.ts', + output: { file: 'dist/bin/index.mjs', format: 'esm' } + }, + { + ...commonOptions, + input: 'src/index.ts', + output: [ + { file: 'dist/index.cjs', format: 'cjs' }, + { file: 'dist/index.mjs', format: 'esm' } + ] + } +] \ No newline at end of file diff --git a/packages/techor/src/bin/index.ts b/packages/techor/src/bin/index.ts index 9cda3ad..6087f6f 100755 --- a/packages/techor/src/bin/index.ts +++ b/packages/techor/src/bin/index.ts @@ -2,15 +2,9 @@ import { Command } from 'commander' import { readJSONFileSync } from '@techor/fs' -import log from '@techor/log' -import path from 'path' -import { fileURLToPath } from 'url' -import { dirname } from 'path' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = dirname(__filename) +import { dirname, resolve } from 'path' -const { version, name, description } = readJSONFileSync(path.resolve(__dirname, '../../package.json')) +const { version, name, description } = readJSONFileSync(resolve(dirname(fileURLToPath(import.meta.url)), '../../package.json')) const program = new Command() program @@ -18,10 +12,11 @@ program .description(description) .version(version || '0.0.0') -import commandPack from '../commands/pack' +import commandBuild from '../commands/build' import commandVersion from '../commands/version' +import { fileURLToPath } from 'url' -commandPack(program) +commandBuild(program) commandVersion(program) program.parse() \ No newline at end of file diff --git a/packages/techor/src/commands/build.ts b/packages/techor/src/commands/build.ts new file mode 100644 index 0000000..1ba18e0 --- /dev/null +++ b/packages/techor/src/commands/build.ts @@ -0,0 +1,375 @@ +import { readJSONFileSync } from '@techor/fs' +import log from '@techor/log' +import type { Command } from 'commander' +import { existsSync, rmSync } from 'fs' +import type { PackageJson } from 'pkg-types' +import { OutputChunk as RollupOutputChunk, OutputOptions as RollupOutputOptions, OutputPlugin as RollupOutputPlugin, InputOptions as RollupInputOptions, RollupOutput, RollupError, rollup, OutputAsset as RollupOutputAsset, watch as rollupWatch, RollupBuild, InputPluginOption as RollupInputPluginOption } from 'rollup' +import extend from '@techor/extend' +import { explorePathsSync } from '@techor/glob' +import { basename, extname, join, normalize, relative } from 'path' +import upath from 'upath' +import prettyBytes from 'pretty-bytes' +import align from 'wide-align' +import prettyHartime from 'pretty-hrtime' +import logRollupError from '../utils/log-rollup-error' +import { execaCommand } from 'execa' +import clsx from 'clsx' +import getWideExternal from '../utils/get-wide-external' +import { BuildCommonOptions, Config, default as defaultConfig } from '../config' + +// core plugins +import esmShim from '../plugins/esm-shim' +import esbuildTransform from '../plugins/esbuild-transform' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import commonjs from '@rollup/plugin-commonjs' +import swc from '@rollup/plugin-swc' +import exploreConfig from 'explore-config' + +const FORMAT_OF_EXT = { + '.js': 'umd', + '.cjs': 'cjs', + '.mjs': 'esm', + '.ts': 'dts' +} + +const EXT_OF_FORMAT = { + esm: '.mjs', + es: '.mjs', + module: '.mjs', + cjs: '.cjs', + commongjs: '.cjs', + iife: '.js', + amd: '.js', + system: '.js', + systemjs: '.js' +} + +const SRCFILE_EXT = '.{js,ts,jsx,cjs,tsx,mjs,mts}' + +declare type OutputResults = (BuildOutputOptions & { artifact: (RollupOutputAsset | RollupOutputChunk) })[] +declare type BuildOutputOptions = BuildCommonOptions & { output: RollupOutputOptions } +declare type BuildOptions = { + rollupInput: RollupInputOptions, + outputOptionsList: BuildOutputOptions[] +} + +export default (program: Command) => program.command('build [entryPaths...]') + .alias('dev') + // https://rollupjs.org/configuration-options + .option('-f, --formats [formats...]') + .option('-w, --watch') + .option('-c, --clean') + .option('--src-dir ') + .option('--dir ') + .option('--minify') + .option('--declare') + .option('--no-external') + .option('--no-declare') + // rollup output options + .option('-o, --file ') + .option('-e, --external [packages...]', '', []) + .action(async function (commandInputs: string[], { file, external, ...commandBuildOptions }) { + try { + const useConfig = exploreConfig('techor.config.*') as Config + const config = extend(defaultConfig, useConfig, { build: commandBuildOptions }) as Config + + if (file !== undefined) config.build.output.file = file + if (external !== undefined) config.build.external = external + + if (process.env.DEBUG) console.log('[DEBUG] commandBuildOptions', commandBuildOptions) + const pkg: PackageJson = readJSONFileSync('package.json') || {} + const { dependencies, peerDependencies, optionalDependencies, types } = pkg + const buildMap = new Map() + + if (config.build.declare === undefined && types) config.build.declare = true + if (this.args[0] === 'dev') { + config.build.watch = true + } + + if (Array.isArray(config.build.external)) { + if (dependencies) config.build.external.push(...Object.keys(dependencies)) + if (peerDependencies) config.build.external.push(...Object.keys(peerDependencies)) + if (optionalDependencies) config.build.external.push(...Object.keys(optionalDependencies)) + } + + // remove output dir first + if (config.build.clean && existsSync(config.build.dir)) { + rmSync(config.build.dir, { force: true, recursive: true }) + log.i`Cleaned up **${config.build.dir}**` + } + + // eslint-disable-next-line no-inner-declarations + function addBuild(input: string, rollupOutputOptions: RollupOutputOptions) { + input = normalize(input) + if (!rollupOutputOptions.format) { + rollupOutputOptions.format = FORMAT_OF_EXT[extname(rollupOutputOptions.file)] + } + const fileBasenameSplits = basename(rollupOutputOptions.file).split('.') + const outputOptions = extend(config.build, { output: rollupOutputOptions }) as BuildOutputOptions + if (fileBasenameSplits.includes('min')) outputOptions.minify = true + const isGlobalFile = fileBasenameSplits.includes('global') + if (isGlobalFile || fileBasenameSplits.includes('iife')) outputOptions.output.format = 'iife' + for (const [eachInput, eachBuildOptions] of buildMap) { + for (const eachOutputOptions of eachBuildOptions.outputOptionsList) { + if (normalize(eachOutputOptions.output.file) === normalize(outputOptions.output.file)) { + if (process.env.DEBUG) console.log('[DEBUG] outputOptions', outputOptions) + return + } + } + } + if (config.build.esbuildTransform || outputOptions.minify) { + (outputOptions.output.plugins as RollupOutputOptions['plugins'][]).push(esbuildTransform()) + } + let buildOptions = buildMap.get(input) + if (buildOptions) { + // 合併同一個 input 來源並對應多個 RollupOutputOptions 避免重新 parse 相同的 input + (buildOptions.outputOptionsList).push(outputOptions) + } else { + buildOptions = { + rollupInput: config.build.input, + outputOptionsList: [outputOptions] + } as BuildOptions + buildOptions.rollupInput.input = input + buildOptions.rollupInput.external = (config.build.external && !isGlobalFile) && getWideExternal(config.build.external || []); + (buildOptions.rollupInput.plugins as RollupInputPluginOption[]).unshift( + ...[ + config.build.swc && swc(config.build.swc), + config.build.commonjs && commonjs(config.build.commonjs), + config.build.nodeResolve && nodeResolve(config.build.nodeResolve), + config.build.esmShim && esmShim(), + ] + .filter((existence) => existence) + ) + if (process.env.DEBUG) console.log('[DEBUG] buildOptions', buildOptions) + buildMap.set(input, buildOptions) + } + } + + if (commandInputs.length) { + const foundEntries = explorePathsSync(commandInputs) + for (const eachEntry of foundEntries) { + config.build.formats.map((eachFormat) => { + addBuild(eachEntry, { + format: eachFormat, + file: config.build.output.file || join(config.build.dir, relative(config.build.srcDir, upath.changeExt(eachEntry, EXT_OF_FORMAT[eachFormat]))) + }) + }) + } + } else { + log.i`Detected entries (package.json)` + + const exploreMapptedEntry = (filePath: string, targetExt: string) => { + const subFilePath = upath.relative(config.build.dir, filePath) + const srcFilePath = upath.join(config.build.srcDir, subFilePath) + const pattern = upath.changeExt(srcFilePath, targetExt) + const foundEntries = explorePathsSync(pattern) + if (!foundEntries.length) { + throw new Error(`Cannot find the entry file **${pattern}**`) + } + return foundEntries[0] + } + + if (pkg.exports) { + (function handleExports(eachExports: any, eachFormat?: RollupOutputOptions['format']) { + if (typeof eachExports === 'string') { + addBuild(exploreMapptedEntry(eachExports, SRCFILE_EXT), { + format: eachFormat, + file: eachExports + }) + } else { + for (const eachExportKey in eachExports) { + const eachUnknowExports = eachExports[eachExportKey] + if (eachExportKey.startsWith('.')) { + handleExports(eachUnknowExports, eachFormat) + } else { + switch (eachExportKey) { + case 'node': + handleExports(eachUnknowExports, eachFormat) + break + case 'browser': + handleExports(eachUnknowExports, eachFormat) + break + case 'default': + handleExports(eachUnknowExports, eachFormat) + break + case 'require': + handleExports(eachUnknowExports, 'cjs') + break + case 'import': + handleExports(eachUnknowExports, 'esm') + break + } + } + } + } + })(pkg.exports) + } + + if (pkg.main) { + addBuild(exploreMapptedEntry(pkg.main, SRCFILE_EXT), { file: pkg.main }) + } + + if (pkg.module) { + addBuild(exploreMapptedEntry(pkg.module, SRCFILE_EXT), { format: 'esm', file: pkg.module }) + } + + if (pkg.browser) { + addBuild(exploreMapptedEntry(pkg.browser, SRCFILE_EXT), { format: 'iife', file: pkg.browser }) + } + + if (pkg.bin) { + if (typeof pkg.bin === 'string') { + addBuild(exploreMapptedEntry(pkg.bin, SRCFILE_EXT), { file: pkg.bin }) + } else { + for (const eachCommandName in pkg.bin) { + const eachCommandFile = pkg.bin[eachCommandName] + addBuild(exploreMapptedEntry(eachCommandFile, SRCFILE_EXT), { file: eachCommandFile }) + } + } + } + } + + if (buildMap.size === 0) { + log.x`No build tasks created` + log.i`Please check your **package.json** or specify **entries**` + return + } + + log.i`Start watching for file changes...` + const outputResults: OutputResults = [] + const printOutputResults = (eachOutputResults: OutputResults, eachBuildStartTime: [number, number]) => { + const buildTime = process.hrtime(eachBuildStartTime) + const colSizes: Record = {} + const chunks: RollupOutputChunk[] = [] + + for (const eachOutputResult of eachOutputResults) { + switch (eachOutputResult.artifact.type) { + case 'asset': + // colSizes[1] = Math.max(colSizes[1] || 0, output.fileName.length) + // colSizes[2] = Math.max(colSizes[2] || 0, FORMAT_OF_EXT[extname(output.fileName)].length) + // colSizes[3] = Math.max(colSizes[3] || 0, prettyBytes(output.source.length, { space: false }).length) + throw new Error('Not implemented for assets.') + case 'chunk': + chunks.push(eachOutputResult.artifact) + // eslint-disable-next-line no-case-declarations + colSizes[1] = Math.max(colSizes[1] || 0, (relative(eachOutputResult.dir, eachOutputResult.output.file)).length) + colSizes[2] = Math.max(colSizes[2] || 0, eachOutputResult.output.format.length) + colSizes[3] = Math.max(colSizes[3] || 0, prettyBytes(eachOutputResult.artifact.code.length, { space: false }).length) + break + } + } + + console.log('') + eachOutputResults + .sort((a, b) => a.output.file.length - b.output.file.length || a.output.file.localeCompare(b.output.file)) + .forEach((eachOutputResult) => { + let fileName, format, codeLength + switch (eachOutputResult.artifact.type) { + case 'asset': + // fileName = align.left('**' + output.fileName + '**', colSizes[1] + 6) + // format = align.right(FORMAT_OF_EXT[extname(output.fileName)], colSizes[2] + 2) + // codeLength = align.right(prettyBytes(output.source.length, { space: false }), colSizes[3] + 2) + throw new Error('Not implemented for assets.') + case 'chunk': + fileName = align.left('**' + relative(config.build.dir, eachOutputResult.output.file) + '**', colSizes[1] + 6) + format = align.right(eachOutputResult.output.format, colSizes[2] + 2) + codeLength = align.right(prettyBytes(eachOutputResult.artifact.code.length, { space: false }), colSizes[3] + 2) + break + } + log.o(`${fileName} ${format} ${codeLength} ${eachOutputResult.minify && '(minified)' || ''}`) + }) + console.log('') + + log.ok(clsx(`Built **${chunks.length}** chunks`, config.build.declare && `and types`, `in ${prettyHartime(buildTime).replace(' ', '')}`)) + } + const buildStartTime = process.hrtime() + const buildingInputs = [] + await Promise.all( + [ + ...Array.from(buildMap.entries()) + .map(async ([input, eachBuildOptions]) => { + buildingInputs.push(input) + const output = async (rollupBuild: RollupBuild, outputResults: OutputResults) => { + await Promise.all( + eachBuildOptions.outputOptionsList.map(async (eachOutputOptions) => { + const result = await rollupBuild.generate(eachOutputOptions.output) + result.output = result.output + .filter((chunkOrAsset) => { + outputResults.push({ + ...eachOutputOptions, + artifact: chunkOrAsset + }) + return true + }) as RollupOutput['output'] + if (result.output.length) { + await rollupBuild.write(eachOutputOptions.output) + } + }) + ) + } + if (config.build.watch) { + const watcher = rollupWatch({ + ...eachBuildOptions.rollupInput, + watch: { + skipWrite: true + } + }) + let buildStartTime + watcher + .on('event', async (event) => { + if (event.code === 'BUNDLE_START') { + buildStartTime = process.hrtime() + } + if (event.code === 'BUNDLE_END') { + const eachOutputResults = [] + await output(event.result, eachOutputResults) + printOutputResults(eachOutputResults, buildStartTime) + if (config.build.declare) console.log('') + } + if (event.code === 'ERROR') { + console.error(event.error) + } + }) + watcher.on('change', (id, { event }) => { + console.log('') + log`[${event.toUpperCase()}] ${relative(process.cwd(), id)}` + }) + } else { + const rollupBuild = await rollup(eachBuildOptions.rollupInput) + await output(rollupBuild, outputResults) + if (rollupBuild) { + // closes the rollupBuild + await rollupBuild.close() + } + } + }), + config.build.declare && new Promise((resolve) => { + execaCommand(clsx( + 'npx tsc --emitDeclarationOnly --preserveWatchOutput --declaration', + config.build.dir && '--outDir ' + config.build.dir, + config.build.watch && '--watch' + ), { + stdio: 'inherit', + stripFinalNewline: false, + cwd: process.cwd() + }) + .catch(() => { + process.exit() + }) + .finally(resolve) + }) + ] + ) + if (!config.build.watch) { + printOutputResults(outputResults, buildStartTime) + } + + } catch (error) { + if (error.name === 'RollupError') { + logRollupError(error as RollupError) + } else { + log(error) + } + process.exit(1) + } + }) \ No newline at end of file diff --git a/packages/techor/src/commands/pack.ts b/packages/techor/src/commands/pack.ts deleted file mode 100644 index 85bb884..0000000 --- a/packages/techor/src/commands/pack.ts +++ /dev/null @@ -1,420 +0,0 @@ -import type { Command } from 'commander' -import { type BuildOptions, context, Metafile, build } from 'esbuild' -import log from '@techor/log' -import upath from 'upath' -import type { PackageJson } from 'pkg-types' -import prettyBytes from 'pretty-bytes' -import fs from 'fs' -import isEqual from 'lodash.isequal' -import { esbuildOptionNames } from '../utils/esbuild-option-names' -import { createAutofillMjsPlugin } from '../plugins/esbuild-plugin-autofill-mjs' -import extend from '@techor/extend' -import exploreConfig from 'explore-config' -import { execaCommand } from 'execa' -import prettyHartime from 'pretty-hrtime' -import { readJSONFileSync } from '@techor/fs' -import { explorePathsSync } from '@techor/glob' -import clsx from 'clsx' -import { extname } from 'path' -import { fileURLToPath } from 'node:url' -import { dirname } from 'node:path' - -const __filename = fileURLToPath(import.meta.url) -const __dirname = dirname(__filename) - -declare type BuildTask = { options?: BuildOptions, metafile?: Metafile, run: () => Promise } - -const FORMAT_OF_EXT = { - 'js': 'cjs', - 'cjs': 'cjs', - 'mjs': 'esm' -} - -export default (program: Command) => program.command('pack [entryPaths...]') - .option('-f, --format [formats...]', 'The output format for the generated JavaScript files `iife`, `cjs`, `esm`', ['cjs', 'esm']) - .option('-w, --watch', 'Rebuild whenever a file changes', false) - .option('-s, --sourcemap', 'Emit a source map', process.env.NODE_ENV === 'production') - .option('-p, --platform ', 'Platform target', 'browser') - .option('-o, --outfile ', 'The output file', '') - .option('-o, --outdir

', 'The output directory for the build operation', 'dist') - .option('--serve', 'Serve mode starts a web server that serves your code to your browser on your device', false) - .option('--bundle', 'Inline any imported dependencies into the file itself', false) - .option('-e, --external ', 'External packages to exclude from the build', []) - .option('-re, --resolve-extensions [extensions...]', 'The resolution algorithm used by node supports implicit file extensions', ['.tsx', '.ts', '.jsx', '.js', '.css', '.json']) - .option('-kn, --keep-names', 'Keep JavaScript function/class names', false) - .option('--cjs-ext ', 'Specify CommonJS default file extension', '.js') - .option('--iife-ext ', 'Specify CommonJS default file extension', '.js') - .option('--esm-ext ', 'Specify CommonJS default file extension', '.mjs') - .option('--srcdir ', 'The source directory', 'src') - .option('--target [targets...]', 'This sets the target environment for the generated JavaScript and/or CSS code.') - .option('--mangle-props ', 'Pass a regular expression to esbuild to tell esbuild to automatically rename all properties that match this regular expression') - .option('--entry-names <[dir]/[name]>', 'Pass a regular expression to esbuild to tell esbuild to automatically rename all properties that match this regular expression') - .option('--declare', 'Emit typescript declarations') - .option('--no-minify', 'OFF: Minify the generated code') - .option('--no-clean', 'OFF: Clean up the previous output directory before the build starts') - .option('--no-external', 'OFF: No external packages') - .action(async function (specifiedEntries, options) { - // if (!specifiedEntries.length) { - // specifiedEntries = [path.join(options.srcdir, '**/*.{js,ts,jsx,tsx,mjs,mts,css}')] - // } - const pkg: PackageJson = readJSONFileSync(upath.resolve('./package.json')) - const { dependencies, peerDependencies } = pkg - /** Extract external dependencies to prevent bundling */ - const externalDependencies = [] - dependencies && externalDependencies.push(...Object.keys(dependencies)) - peerDependencies && externalDependencies.push(...Object.keys(peerDependencies)) - if (options.srcdir) upath.normalize(options.srcdir) - if (options.clean && fs.existsSync(options.outdir)) { - fs.rmSync(options.outdir, { force: true, recursive: true }) - log.i`**${options.outdir}** output cleaned up` - } - const extByFormat = { cjs: options.cjsExt, esm: options.esmExt, iife: options.iifeExt } - const useConfig = exploreConfig('techor.*') - const buildTasks: BuildTask[] = [] - - const exploreMapptedEntry = (filePath: string, targetExt: string) => { - const subFilePath = upath.relative(options.outdir, filePath.replace('.bundle', '')) - const srcFilePath = upath.join(options.srcdir, subFilePath) - const pattern = upath.changeExt(srcFilePath, targetExt) - const foundEntries = explorePathsSync(pattern) - if (!foundEntries.length) { - throw new Error(`Cannot find the entry file **${pattern}**`) - } - return foundEntries[0] - } - const outputFilePaths = [] - const addBuildTask = async (eachEntries: string[], eachOptions: { - format?: string, - bundle?: boolean, - ext?: string, - platform?: string, - outdir?: string, - outfile?: string - } = {}) => { - let eachOutExt = eachOptions.ext || eachOptions.outfile && upath.extname(eachOptions.outfile) || undefined - const outExtension = { '.css': '.css' } - const external = options.external === false ? [] : [ - ...externalDependencies, - ...options.external - ] - if (!eachOutExt) { - eachOutExt = extByFormat[eachOptions.format] - } - if (eachOutExt) { - outExtension['.js'] = eachOutExt - } - if (eachOptions.outdir) eachOptions.outdir = upath.normalize(eachOptions.outdir) - if (eachOptions.bundle === undefined) eachOptions.bundle = options.bundle - if (eachOptions.outfile) { - eachOptions.outfile = upath.normalize(eachOptions.outfile) - if (outputFilePaths.includes(eachOptions.outfile)) { - return - } - outputFilePaths.push(eachOptions.outfile) - } - if (!eachOptions.outfile && !eachOptions.bundle) { - eachEntries = eachEntries.filter((eachEntry) => { - const eachOutputFilePath = upath.changeExt(upath.join(options.outdir, upath.relative(options.srcdir, eachEntry)), eachOutExt) - if (outputFilePaths.includes(eachOutputFilePath)) { - return false - } else { - outputFilePaths.push(eachOutputFilePath) - return true - } - }) - } - - const eachOutdir = eachOptions.outdir || options.outdir - - /** - * Keep original directory output and prevent bundling - * @example $ esbuild entry.js a.js b.js external.j --format=esm --outdir=dist --bundle --external:./a --external:./b - * @example https://esbuild.github.io/try/#YgAwLjE4LjExAGVudHJ5LmpzIGEuanMgYi5qcyBleHRlcm5hbC5qIC0tZm9ybWF0PWVzbSAtLW91dGRpcj1kaXN0IC0tYnVuZGxlIC0tZXh0ZXJuYWw6Li9hIC0tZXh0ZXJuYWw6Li9iAABlbnRyeS5qcwBleHBvcnQgKiBmcm9tICcuL2EnCmV4cG9ydCAqIGZyb20gJy4vYicKZXhwb3J0ICogZnJvbSAnLi9leHRlcm5hbCcAAGEuanMAZXhwb3J0IGNvbnN0IGEgPSAnYScAAGIuanMAZXhwb3J0IGNvbnN0IGIgPSAnYicAAGV4dGVybmFsLmpzAGV4cG9ydCBjb25zdCBleHRlcm5hbCA9ICdleHRlcm5hbCc - * */ - // if (!eachOptions.bundle) { - // external.push( - // ...(eachEntries.map((eachEntry) => './' + eachEntry)) - // ) - // } - - const buildOptions: BuildOptions = extend(options, { - outExtension, - logLevel: 'info', - outdir: eachOptions.outfile ? undefined : eachOutdir, - outfile: eachOptions.outfile, - outbase: options.srcdir, - platform: eachOptions.platform || options.platform, - metafile: true, - bundle: eachOptions.bundle, - entryNames: options.entryNames ? options.entryNames : '[dir]/[name]', - format: eachOptions.format, - keepNames: options.keepNames, - resolveExtensions: options.resolveExtensions, - mangleProps: options.mangleProps ? new RegExp(options.mangleProps) : undefined, - target: options.target, - sourcemap: options.sourcemap, - external, - plugins: [], - } as BuildOptions, useConfig?.pack) - - if (!buildOptions.target) { - delete buildOptions.target - } - - // Fixed: Cannot use "external" option with "bundle" option - if (!buildOptions.bundle) { - delete buildOptions.external - } - - if (!eachOptions.bundle && eachOptions.format === 'esm') { - buildOptions.plugins.push(createAutofillMjsPlugin(options.esmExt, options.srcdir)) - } - - // Fix ERROR: Invalid option in build() call - delete buildOptions['watch'] - delete buildOptions['serve'] - delete buildOptions['framework'] - - // 安全地同步選項給 esbuild - for (const eachBuildOptionName in buildOptions) { - if (!esbuildOptionNames.includes(eachBuildOptionName)) { - delete buildOptions[eachBuildOptionName] - } - } - - /** - * Repeated tasks will not be added anymore - */ - buildOptions.entryPoints = eachEntries.filter((eachEntryPoint) => - !buildTasks.find((eachBuildTask) => - (eachBuildTask.options.entryPoints as string[]).includes(eachEntryPoint) - && eachBuildTask.options.format === buildOptions.format - && isEqual(eachBuildTask.options.outExtension, buildOptions.outExtension) - && eachBuildTask.options.outdir === buildOptions.outdir - && eachBuildTask.options.outfile === buildOptions.outfile) - ) - - if (!buildOptions.entryPoints.length) { - return - } - - const eachBuildTask: BuildTask = { - options: buildOptions, - run: async () => { - const ctx = await context(buildOptions) - const { metafile } = await ctx.rebuild() - if (metafile) { - eachBuildTask.metafile = metafile - for (const outputFilePath in metafile.outputs) { - const eachOutput = metafile.outputs[outputFilePath] - eachOutput['format'] = buildOptions.format - } - } - if (options.watch) { - await ctx.watch() - } else { - await ctx.dispose() - } - if (options.serve) { - await ctx.serve() - } - } - } - buildTasks.push(eachBuildTask) - } - if (specifiedEntries.length) { - const foundEntries = explorePathsSync(specifiedEntries) - const foundCSSEntries = [] - const foundJSEntries = [] - for (const foundEntry of foundEntries) { - if (foundEntry.endsWith('.css')) { - foundCSSEntries.push(foundEntry) - } else { - foundJSEntries.push(foundEntry) - } - } - if (options.outfile && (foundCSSEntries.length > 1 || foundJSEntries.length > 1)) { - throw new Error('Cannot specify `outfile` option when multiple entries are specified') - } - if (foundCSSEntries.length) { - addBuildTask(foundCSSEntries, { outfile: options.outfile }) - } - if (foundJSEntries.length) { - options.format.forEach((eachFormat: string) => addBuildTask(foundJSEntries, { - format: eachFormat, - outfile: options.outfile - })) - } - } else { - if (options.outfile) { - throw new Error('Cannot specify `outfile` option when no entry is specified') - } - /* Read entries from `package.json` automatically */ - if (pkg.exports) { - (function handleExports(eachExports: any, eachParentKey: string, eachOptions?: { format?: string, outfile?: string, platform?: string }) { - if (typeof eachExports === 'string') { - const exportsExt = upath.extname(eachExports).slice(1) - addBuildTask([exploreMapptedEntry(eachExports, '.{js,ts,jsx,tsx,mjs,mts}')], { - format: FORMAT_OF_EXT[exportsExt], - outfile: options.outfile || eachExports, - platform: options.platform, - bundle: eachExports.includes('.bundle') || undefined - }) - } else { - for (const eachExportKey in eachExports) { - const eachUnknowExports = eachExports[eachExportKey] - let eachFormat: string - let eachPlatform: string - switch (eachParentKey) { - case 'node': - eachPlatform = 'node' - break - case 'browser': - eachPlatform = 'browser' - break - case 'require': - eachFormat = 'cjs' - break - case 'import': - eachFormat = 'esm' - break - } - if (eachExportKey.startsWith('.')) { - handleExports(eachUnknowExports, eachExportKey) - } else { - switch (eachExportKey) { - case 'node': - handleExports(eachUnknowExports, eachExportKey, { platform: 'node', format: eachFormat }) - break - case 'browser': - handleExports(eachUnknowExports, eachExportKey, { platform: 'browser', format: eachFormat }) - break - case 'default': - handleExports(eachUnknowExports, eachExportKey, { platform: eachPlatform, format: eachFormat }) - break - case 'require': - handleExports(eachUnknowExports, eachExportKey, { platform: eachPlatform, format: 'cjs' }) - break - case 'import': - handleExports(eachUnknowExports, eachExportKey, { platform: eachPlatform, format: 'esm' }) - break - } - } - } - } - })(pkg.exports, '') - } - if (pkg.style) { - addBuildTask([exploreMapptedEntry(pkg.style, '.css')], { outfile: pkg.style, bundle: pkg.main.includes('.bundle') || undefined }) - } - if (pkg.main && !pkg.main.endsWith('.css')) { - addBuildTask([exploreMapptedEntry(pkg.main, '.{js,ts,jsx,tsx,mjs,mts}')], { format: 'cjs', outfile: pkg.main, bundle: pkg.main.includes('.bundle') || undefined }) - } - if (pkg.module) { - addBuildTask([exploreMapptedEntry(pkg.module, '.{js,ts,jsx,tsx,mjs,mts}')], { format: 'esm', outfile: pkg.module, bundle: pkg.module.includes('.bundle') || undefined }) - } - if (pkg.browser) { - addBuildTask([exploreMapptedEntry(pkg.browser, '.{js,ts,jsx,tsx,mjs,mts}')], { format: 'iife', platform: 'browser', outfile: pkg.browser, bundle: pkg.browser.includes('.bundle') || undefined }) - } - if (pkg.bin) { - if (typeof pkg.bin === 'string') { - const ext = extname(pkg.bin).slice(1) - addBuildTask([exploreMapptedEntry(pkg.bin, '.{js,ts,jsx,tsx,mjs,mts}')], { format: FORMAT_OF_EXT[ext], platform: 'node', outfile: pkg.bin, bundle: pkg.bin.includes('.bundle') || undefined }) - } else { - for (const eachCommandName in pkg.bin) { - const eachCommandFile = pkg.bin[eachCommandName] - const ext = extname(eachCommandFile).slice(1) - addBuildTask([exploreMapptedEntry(eachCommandFile, '.{js,ts,jsx,tsx,mjs,mts}')], { format: FORMAT_OF_EXT[ext], platform: 'node', outfile: eachCommandFile, bundle: eachCommandFile.includes('.bundle') || undefined }) - } - } - } - } - - if (!buildTasks.length) { - throw new Error('No entry found') - } - - let typeBuildTask: any - if (options.declare) { - typeBuildTask = { - outfile: 'declarations', - options: { - platform: 'ts', - format: 'dts' - }, - run: () => new Promise((resolve) => { - const runTsc = () => { - execaCommand(clsx( - 'npx tsc --emitDeclarationOnly --preserveWatchOutput --declaration', - options.outdir && '--outDir ' + options.outdir, - options.outfile && '--outFile ' + options.outfile, - options.watch && '--watch --incremental' - ), { - stdio: 'inherit', - stripFinalNewline: false, - cwd: process.cwd() - }) - .catch((reason) => { - process.exit() - }) - .finally(resolve) - } - if (options.watch) { - setTimeout(runTsc, 100) - } else { - runTsc() - } - }) - } as any - if (!options.watch) { - buildTasks.push(typeBuildTask) - } - } - - const buildStartTime = process.hrtime() - await Promise.all(buildTasks.map(({ run }) => run())) - const buildEndTime = process.hrtime(buildStartTime) - - console.log('') - - if (options.watch && typeBuildTask) { - buildTasks.push(typeBuildTask) - } - - for (const eachBuildTask of buildTasks) { - if (eachBuildTask.metafile) { - Object.keys(eachBuildTask.metafile.outputs) - .forEach((outputFilePath) => { - const eachOutput = eachBuildTask.metafile.outputs[outputFilePath] - const outputSize = prettyBytes(eachOutput.bytes).replace(/ /g, '') - const eachOutputFormat = eachOutput['format'] - log.ok(clsx( - `[${eachBuildTask.options.platform}]`, - `**${outputFilePath}**`, - outputSize, - `(${eachOutputFormat})`, - eachBuildTask.options.bundle && '(bundle)', - eachBuildTask.options.minify && '(minify)', - `${Object.keys(eachOutput.inputs).length} inputs` - )) - }) - } else { - log.ok(clsx( - `[${eachBuildTask.options.platform}]`, - `**${eachBuildTask['outfile']}**`, - `(${eachBuildTask.options.format})` - )) - } - } - console.log('') - if (options.watch) { - log`Start watching ${buildTasks.length} build tasks $t` - } else { - log.success`${buildTasks.length} build tasks $t in ${prettyHartime(buildEndTime).replace(' ', '')}` - } - console.log('') - - if (options.watch && typeBuildTask) { - await typeBuildTask.run() - } - }) \ No newline at end of file diff --git a/packages/techor/src/commands/version.ts b/packages/techor/src/commands/version.ts index 1caad0d..f0dfce6 100644 --- a/packages/techor/src/commands/version.ts +++ b/packages/techor/src/commands/version.ts @@ -1,9 +1,9 @@ import type { Command } from 'commander' import { explorePathsSync } from '@techor/glob' +import { readPNPMWorkspaces, readWorkspaces, explorePackageManager } from '@techor/npm' import path from 'path' -import log, { paint } from '@techor/log' +import log from '@techor/log' import { readJSONFileSync, writeFileSync } from '@techor/fs' -import { readPNPMWorkspaces, readWorkspaces, explorePackageManager } from '@techor/npm' export default (program: Command) => program.command('version ') .description('Bump to specific version for workspace\'s packages') @@ -71,14 +71,14 @@ export default (program: Command) => program.command('version ') const workspaceDepsTree = {} for (const name in packagesOfName) { const { dependencies, peerDependencies, devDependencies } = packagesOfName[name] - const workspacePackage: any = workspaceDepsTree[paint('**' + name + '**')] = {} + const workspacePackage: any = workspaceDepsTree[log.paint('**' + name + '**')] = {} const analyzeDeps = (eachDeps, key: string) => { if (eachDeps) { workspacePackage[key] = {} for (const dependencyName in eachDeps) { if (dependencyName in packagesOfName) { const eachDependencyVersion = eachDeps[dependencyName] - workspacePackage[key][paint('**' + dependencyName + '**')] = eachDependencyVersion || null + workspacePackage[key][log.paint('**' + dependencyName + '**')] = eachDependencyVersion || null } } } @@ -87,8 +87,8 @@ export default (program: Command) => program.command('version ') analyzeDeps(peerDependencies, 'peerDependencies') analyzeDeps(devDependencies, 'devDependencies') /* 防止沒有印出空 {} 的項目 */ - if (!Object.keys(workspaceDepsTree[paint('**' + name + '**')]).length) { - workspaceDepsTree[paint('**' + name + '**')] = null + if (!Object.keys(workspaceDepsTree[log.paint('**' + name + '**')]).length) { + workspaceDepsTree[log.paint('**' + name + '**')] = null } } log`📦` diff --git a/packages/techor/src/config.ts b/packages/techor/src/config.ts new file mode 100644 index 0000000..f42abb7 --- /dev/null +++ b/packages/techor/src/config.ts @@ -0,0 +1,62 @@ +import { InputOptions as RollupInputOptions, OutputOptions as RollupOutputOptions } from 'rollup' +import { TransformOptions as ESBuildTransformOptions } from 'esbuild' +import { Options as SWCOptions } from '@swc/core' +import { RollupNodeResolveOptions } from '@rollup/plugin-node-resolve' +import { RollupCommonJSOptions } from '@rollup/plugin-commonjs' + +const config: Config = { + build: { + dir: 'dist', + srcDir: 'src', + formats: ['cjs', 'esm'], + clean: true, + input: { + plugins: [], + external: [] + }, + output: { + plugins: [] + }, + nodeResolve: { + extensions: ['.ts', '.tsx', '.mjs', '.cjs', '.js', '.jsx', '.json'], + exportConditions: ['node', 'import', 'require', 'default'] + }, + commonjs: { extensions: ['.js', '.ts'] }, + swc: {}, + esmShim: true + } +} + +export default config + +export interface Config { + build: BuildOptions +} + +export interface BuildCommonOptions { + srcDir?: string + dir?: string + clean?: boolean + watch?: boolean + minify?: boolean + declare?: boolean + external?: string[] + formats?: RollupOutputOptions['format'][] +} + +export interface BuildOptions extends BuildCommonOptions { + // https://rollupjs.org/javascript-api/#inputoptions-object + input?: RollupInputOptions + // https://rollupjs.org/javascript-api/#outputoptions-object + output?: RollupOutputOptions + // https://swc.rs/docs/configuration/compilation + swc?: SWCOptions | false + // https://github.com/rollup/plugins/tree/master/packages/node-resolve#options + nodeResolve?: RollupNodeResolveOptions | false; + // https://esbuild.github.io/api/#transform + esbuildTransform?: ESBuildTransformOptions | false + // We made `techor-esm-shim` because `@rollup/plugin-esm-shim` breaks the source code. + esmShim?: boolean + // https://github.com/rollup/plugins/tree/master/packages/commonjs#options + commonjs?: RollupCommonJSOptions | false +} \ No newline at end of file diff --git a/packages/techor/src/index.ts b/packages/techor/src/index.ts new file mode 100644 index 0000000..4ec68cd --- /dev/null +++ b/packages/techor/src/index.ts @@ -0,0 +1,6 @@ +export { default as esmShim } from './plugins/esm-shim' +export { default as esbuildTransform } from './plugins/esbuild-transform' +export { default as rawLoader } from './plugins/raw-loader' +export { default as config } from './config' + +export type * from './config' \ No newline at end of file diff --git a/packages/techor/src/plugins/esbuild-plugin-autofill-mjs.ts b/packages/techor/src/plugins/esbuild-plugin-autofill-mjs.ts deleted file mode 100644 index 1d6eb4d..0000000 --- a/packages/techor/src/plugins/esbuild-plugin-autofill-mjs.ts +++ /dev/null @@ -1,57 +0,0 @@ -import type { Plugin } from 'esbuild' -import fs from 'fs' -import upath from 'upath' -import path from 'path' -import { explorePathSync } from '@techor/glob' - -export function createAutofillMjsPlugin(outext = '.js', srcdir = 'src'): Plugin { - const resolvedOutdir = path.resolve(srcdir) - return { - name: 'autofill-mjs', - setup(build) { - const started: any = {} - started.promise = new Promise(resolve => { - started.resolve = resolve - }) - build.onStart(() => { - started.resolve(true) - }) - build.onLoad({ filter: /\.(?:ts|tsx|js|jsx|mjs|mts)$/ }, async (args) => { - if (await started.promise === true) { - const content = await fs.promises.readFile(args.path, { encoding: 'utf8' }) - const currentDirPath = path.dirname(args.path) - return { - contents: content - .replace(/((?:(?:import|export)(?:.*from | ))|(?:(?:import|require))\()'((\.(?:\.)?\/.*)|\.)'/gmi, - (...matches) => { - const modulePath: string = matches[2] - const parsedModulePath = path.parse(modulePath) - if (parsedModulePath.ext) { - return matches[0] - } - const targetDir = path.resolve(currentDirPath, modulePath) - const foundModuleSourcePath = explorePathSync([ - targetDir + '.{ts,js,mjs,jsx,tsx,mjs,mts}', - upath.join(targetDir, 'index.{ts,js,mjs,jsx,tsx,mjs,mts}') - ]) - if (!foundModuleSourcePath) { - return matches[0] - } - let targetModulePath = path.relative(resolvedOutdir, upath.changeExt(foundModuleSourcePath, outext)) - const parsedTargetModulePath = path.parse(targetModulePath) - if (modulePath === '.' || modulePath === './') { - targetModulePath = './index' + outext - } else if (parsedTargetModulePath.name === parsedModulePath.name) { - targetModulePath = modulePath + outext - } else { - targetModulePath = modulePath + '/index' + outext - } - return `${matches[1]}'${targetModulePath}'` - }), - loader: 'tsx', - } - } - }) - } - } -} \ No newline at end of file diff --git a/packages/techor/src/plugins/esbuild-remove-import-svelte-module-extension.ts b/packages/techor/src/plugins/esbuild-remove-import-svelte-module-extension.ts deleted file mode 100644 index 6cd2117..0000000 --- a/packages/techor/src/plugins/esbuild-remove-import-svelte-module-extension.ts +++ /dev/null @@ -1,27 +0,0 @@ -import type { Plugin } from 'esbuild' -import fs from 'fs' - -export const removeImportSvelteModuleExtensionPlugin: Plugin = { - name: 'remove-import-svelte-module-extension', - setup(build) { - const started: any = {} - started.promise = new Promise(resolve => { - started.resolve = resolve - }) - build.onStart(() => { - started.resolve(true) - }) - build.onLoad({ filter: /\.(?:ts|tsx|js|jsx|mjs|mts)$/ }, async (args) => { - if (await started.promise === true) { - const content = await fs.promises.readFile(args.path, { encoding: 'utf8' }) - return { - contents: content - .replace(/((?:(?:import|export)(?:.*from | ))|(?:(?:import))\()(')(\.(?:\.)?\/.*)(\.svelte)(')/gmi, (...matches) => { - return matches[1] + matches[2] + matches[3] + matches[5] - }), - loader: 'ts', - } - } - }) - } -} \ No newline at end of file diff --git a/packages/techor/src/plugins/esbuild-transform.ts b/packages/techor/src/plugins/esbuild-transform.ts new file mode 100644 index 0000000..cf1ed96 --- /dev/null +++ b/packages/techor/src/plugins/esbuild-transform.ts @@ -0,0 +1,43 @@ +import type { Plugin } from 'rollup' +import { transform, CommonOptions, TransformOptions } from 'esbuild' + +export default function esbuildTransform(options?: TransformOptions): Plugin { + return { + name: 'techor-esbuild-transform', + async renderChunk(code, _, normalizedOutputOptions) { + let sourcemap: CommonOptions['sourcemap'] + let format: CommonOptions['format'] + switch (normalizedOutputOptions.format) { + case 'es': + format = 'esm' + break + case 'iife': + format = 'iife' + break + default: + format = 'cjs' + } + switch (normalizedOutputOptions.sourcemap) { + case 'inline': + sourcemap = 'inline' + break + case true: + sourcemap = 'external' + break + case false: + sourcemap = false + break + default: + sourcemap = true + + } + return await transform(code, { + format, + loader: 'js', + minify: true, + sourcemap, + ...options, + }) + } + } +} \ No newline at end of file diff --git a/packages/techor/src/plugins/esm-shim.ts b/packages/techor/src/plugins/esm-shim.ts new file mode 100644 index 0000000..ff955fe --- /dev/null +++ b/packages/techor/src/plugins/esm-shim.ts @@ -0,0 +1,36 @@ +import type { Plugin } from 'rollup' +import MagicString from 'magic-string' + +export const ESM_SHIM_CODE = ` +/* Techor ESM Shim */ +import __url_for_shim from 'url'; +import __path_for_shim from 'path'; +import __mod_for_shim from 'module'; +const __filename = __url_for_shim.fileURLToPath(import.meta.url); +const __dirname = __path_for_shim.dirname(__filename); +const require = __mod_for_shim.createRequire(import.meta.url);\n +` + +export default function esmShim(): Plugin { + return { + name: 'techor-esm-shim', + renderChunk(code, chunk, options) { + if (options.format === 'es' && !code.includes(ESM_SHIM_CODE) && /__filename|__dirname|require\(|require\.resolve\(/.test(code)) { + const str = new MagicString(code) + /* insert ESM_SHIM_CODE after the something like: + * #!/usr/bin/env node + */ + if (code.startsWith('#!')) { + str.prependRight(code.indexOf('\n') + 1, ESM_SHIM_CODE) + } else { + str.prepend(ESM_SHIM_CODE) + } + return { + code: str.toString(), + map: str.generateMap() + } + } + return null + }, + } as Plugin +} \ No newline at end of file diff --git a/packages/techor/src/plugins/raw-loader.ts b/packages/techor/src/plugins/raw-loader.ts new file mode 100644 index 0000000..f8c54bf --- /dev/null +++ b/packages/techor/src/plugins/raw-loader.ts @@ -0,0 +1,21 @@ +import type { Plugin } from 'rollup' +import { FilterPattern, createFilter } from '@rollup/pluginutils' +import { readFileSync } from 'fs' + +export default function rawLoader(include?: FilterPattern, { exclude, resolve }: { + exclude?: FilterPattern, + resolve?: string | false | null +} = {}): Plugin { + const filter = createFilter(include, exclude, { resolve }) + return { + name: 'techor-raw-loader', + load(id) { + if (filter(id)) { + return { + code: `export default ${JSON.stringify(readFileSync(id, 'utf-8'))};`, + map: { mappings: '' } + } + } + } + } as Plugin +} \ No newline at end of file diff --git a/packages/techor/src/plugins/shakable-lib.ts b/packages/techor/src/plugins/shakable-lib.ts deleted file mode 100644 index 0f5f6b7..0000000 --- a/packages/techor/src/plugins/shakable-lib.ts +++ /dev/null @@ -1,21 +0,0 @@ -import type { Plugin } from 'esbuild' -import path from 'path' - -export const createShakableLibPlugin = ({ srcdir }: { srcdir: string }): Plugin => ({ - name: 'shakable-lib-plugin', - setup(build) { - const started: any = {} - started.promise = new Promise(resolve => { - started.resolve = resolve - }) - build.onStart(() => { - started.resolve(true) - }) - build.onResolve({ filter: /\.(?:ts|tsx|js|jsx|mjs|mts|css)$/ }, args => { - return { - path: path.join(args.resolveDir, args.path), - external: path.normalize(args.path).startsWith(srcdir) - } - }) - } -}) \ No newline at end of file diff --git a/packages/techor/src/utils/esbuild-option-names.ts b/packages/techor/src/utils/esbuild-option-names.ts deleted file mode 100644 index e7ec781..0000000 --- a/packages/techor/src/utils/esbuild-option-names.ts +++ /dev/null @@ -1,68 +0,0 @@ -export const esbuildOptionNames = [ - 'sourcemap', - 'legalComments', - 'sourceRoot', - 'sourcesContent', - 'format', - 'globalName', - 'target', - 'supported', - 'platform', - 'mangleProps', - 'reserveProps', - 'mangleQuoted', - 'mangleCache', - 'drop', - 'minify', - 'minifyWhitespace', - 'minifyIdentifiers', - 'minifySyntax', - 'charset', - 'treeShaking', - 'ignoreAnnotations', - 'jsx', - 'jsxFactory', - 'jsxFragment', - 'jsxImportSource', - 'jsxDev', - 'jsxSideEffects', - 'define', - 'pure', - 'keepNames', - 'color', - 'logLevel', - 'logLimit', - 'logOverride', - 'bundle', - 'splitting', - 'preserveSymlinks', - 'outfile', - 'metafile', - 'outdir', - 'outbase', - 'external', - 'packages', - 'alias', - 'loader', - 'resolveExtensions', - 'mainFields', - 'conditions', - 'write', - 'allowOverwrite', - 'tsconfig', - 'outExtension', - 'publicPath', - 'entryNames', - 'chunkNames', - 'assetNames', - 'inject', - 'banner', - 'footer', - 'incremental', - 'entryPoints', - 'stdin', - 'plugins', - 'absWorkingDir', - 'nodePaths', - 'watch', -] \ No newline at end of file diff --git a/packages/techor/src/utils/get-wide-external.ts b/packages/techor/src/utils/get-wide-external.ts new file mode 100644 index 0000000..28c542c --- /dev/null +++ b/packages/techor/src/utils/get-wide-external.ts @@ -0,0 +1,4 @@ +export default function getWideExternal(depNames: string[]) { + return depNames + .map((eachDepName) => new RegExp(`^${eachDepName}(?:/.+)?$`)) +} \ No newline at end of file diff --git a/packages/techor/src/utils/log-rollup-error.ts b/packages/techor/src/utils/log-rollup-error.ts new file mode 100644 index 0000000..b6c8263 --- /dev/null +++ b/packages/techor/src/utils/log-rollup-error.ts @@ -0,0 +1,28 @@ +import log from '@techor/log' +import { RollupError } from 'rollup' +import { trimNewlines } from 'trim-newlines' + +export default function logRollupError(error: RollupError) { + const formattedError = [] + console.log('') + if (error.frame) { + const frameLines = error.frame.split('\n') + const formattedFrame = frameLines.map((line, index) => { + if (error.loc.line - 1 === index) { + return log.chalk.white(line) + } + if (error.loc.line === index) { + // 如果错误行与当前行匹配,添加箭头指向错误列 + return line.replace('^', log.chalk.red('^')) + } + return log.chalk.dim(line) + }).join('\n') + formattedError.push(formattedFrame) + } + console.log(trimNewlines(formattedError.join('\n'))) + console.log('') + if (error.loc) { + console.log(`at ${log.chalk.cyan(`${error.loc.file}:${error.loc.line}:${error.loc.column}`)}`) + } + log(error as Error) +} \ No newline at end of file diff --git a/packages/techor/tests/args-externals/src/index.ts b/packages/techor/tests/args-externals/src/index.ts index d24c4bb..0637f36 100644 --- a/packages/techor/tests/args-externals/src/index.ts +++ b/packages/techor/tests/args-externals/src/index.ts @@ -1,2 +1,6 @@ import '@master/css' -import '@master/style-element.react' \ No newline at end of file +import '@master/style-element.react' + +export default function helloWorld() { + return 'helloWorld' +} \ No newline at end of file diff --git a/packages/techor/tests/args-externals/test.ts b/packages/techor/tests/args-externals/test.ts index 13b1b6a..8451e26 100644 --- a/packages/techor/tests/args-externals/test.ts +++ b/packages/techor/tests/args-externals/test.ts @@ -2,9 +2,9 @@ import { execSync } from 'node:child_process' import { expectFileIncludes } from '../../../../utils/expect-file-includes' test('prevent bundling external packages by args', () => { - execSync('tsx ../../src/bin pack --external @master/css @master/style-element.react --bundle', { cwd: __dirname, stdio: 'inherit' }) + execSync('tsx ../../src/bin build --external @master/css @master/style-element.react', { cwd: __dirname }) expectFileIncludes('dist/index.js', [ - 'require("@master/css")', - 'require("@master/style-element.react")' + 'require(\'@master/css\')', + 'require(\'@master/style-element.react\')' ], { cwd: __dirname }) }) \ No newline at end of file diff --git a/packages/techor/tests/auto/package.json b/packages/techor/tests/auto/package.json new file mode 100644 index 0000000..4387c39 --- /dev/null +++ b/packages/techor/tests/auto/package.json @@ -0,0 +1,11 @@ +{ + "name": "@test/basic-auto", + "version": "1.0.0", + "private": true, + "main": "dist/index.cjs", + "module": "dist/index.mjs", + "browser": "dist/index.js", + "files": [ + "dist" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/auto/src/index.ts b/packages/techor/tests/auto/src/index.ts new file mode 100644 index 0000000..b210e59 --- /dev/null +++ b/packages/techor/tests/auto/src/index.ts @@ -0,0 +1,5 @@ +export default function main() { + console.log('main') +} + +main() \ No newline at end of file diff --git a/packages/techor/tests/auto/test.ts b/packages/techor/tests/auto/test.ts new file mode 100644 index 0000000..c521e5f --- /dev/null +++ b/packages/techor/tests/auto/test.ts @@ -0,0 +1,22 @@ +import { execSync } from 'node:child_process' +import { existsSync, readFileSync } from 'node:fs' +import { join } from 'node:path' + +beforeAll(() => { + execSync('tsx ../../src/bin build', { cwd: __dirname }) +}) + +test('main', () => { + expect(existsSync(join(__dirname, './dist/index.cjs'))).toBe(true) + expect(readFileSync(join(__dirname, './dist/index.cjs'), 'utf-8')).toContain('module.exports = main;') +}) + +test('module', () => { + expect(existsSync(join(__dirname, './dist/index.mjs'))).toBe(true) + expect(readFileSync(join(__dirname, './dist/index.mjs'), 'utf-8')).toContain('export { main as default };') +}) + +test('browser', () => { + expect(existsSync(join(__dirname, './dist/index.js'))).toBe(true) + expect(readFileSync(join(__dirname, './dist/index.js'), 'utf-8')).toContain('(function () {') +}) \ No newline at end of file diff --git a/packages/techor/tests/specified-ext/tsconfig.json b/packages/techor/tests/auto/tsconfig.json similarity index 74% rename from packages/techor/tests/specified-ext/tsconfig.json rename to packages/techor/tests/auto/tsconfig.json index 25a1434..b94c20e 100644 --- a/packages/techor/tests/specified-ext/tsconfig.json +++ b/packages/techor/tests/auto/tsconfig.json @@ -5,9 +5,7 @@ "outDir": "dist", }, "include": [ - "src/**/*.ts", - "src/**/*.tsx", - "src/**/*.d.ts" + "src/**/*" ], "exclude": [ "src/**/*.test.ts" diff --git a/packages/techor/tests/css-args/pack.test.ts b/packages/techor/tests/css-args/pack.test.ts deleted file mode 100644 index 747d73b..0000000 --- a/packages/techor/tests/css-args/pack.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { execSync } from 'node:child_process' -import { expectExist } from '../../../../utils/expect-exist' - -test('specify css entries', () => { - execSync('tsx ../../src/bin pack src/*.css', { cwd: __dirname, stdio: 'pipe' }) - expectExist(['dist/index.css', 'dist/float.css', 'dist/heart.css']) -}) \ No newline at end of file diff --git a/packages/techor/tests/css-args/package.json b/packages/techor/tests/css-args/package.json deleted file mode 100644 index 25159af..0000000 --- a/packages/techor/tests/css-args/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@test/css-args", - "version": "1.0.0", - "private": true, - "main": "./dist/index.css", - "style": "./dist/index.css", - "files": [ - "dist" - ] -} \ No newline at end of file diff --git a/packages/techor/tests/css-args/src/float.css b/packages/techor/tests/css-args/src/float.css deleted file mode 100644 index e4964b4..0000000 --- a/packages/techor/tests/css-args/src/float.css +++ /dev/null @@ -1,13 +0,0 @@ -@keyframes float { - 0% { - transform: none; - } - - 50% { - transform: translateY(-1.25rem); - } - - 100% { - transform: none; - } -} \ No newline at end of file diff --git a/packages/techor/tests/css-args/src/heart.css b/packages/techor/tests/css-args/src/heart.css deleted file mode 100644 index 40ebff3..0000000 --- a/packages/techor/tests/css-args/src/heart.css +++ /dev/null @@ -1,21 +0,0 @@ -@keyframes heart { - 0% { - transform: scale(1); - } - - 14% { - transform: scale(1.3); - } - - 28% { - transform: scale(1); - } - - 42% { - transform: scale(1.3); - } - - 70% { - transform: scale(1); - } -} \ No newline at end of file diff --git a/packages/techor/tests/css-args/src/index.css b/packages/techor/tests/css-args/src/index.css deleted file mode 100644 index 60b666b..0000000 --- a/packages/techor/tests/css-args/src/index.css +++ /dev/null @@ -1,2 +0,0 @@ -@import 'heart'; -@import 'float'; \ No newline at end of file diff --git a/packages/techor/tests/css-bundle/package.json b/packages/techor/tests/css-bundle/package.json deleted file mode 100644 index 50d8af2..0000000 --- a/packages/techor/tests/css-bundle/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@test/css-bundle", - "version": "1.0.0", - "private": true, - "main": "./dist/index.bundle.css", - "style": "./dist/index.bundle.css", - "files": [ - "dist" - ] -} \ No newline at end of file diff --git a/packages/techor/tests/css-bundle/src/float.css b/packages/techor/tests/css-bundle/src/float.css deleted file mode 100644 index e4964b4..0000000 --- a/packages/techor/tests/css-bundle/src/float.css +++ /dev/null @@ -1,13 +0,0 @@ -@keyframes float { - 0% { - transform: none; - } - - 50% { - transform: translateY(-1.25rem); - } - - 100% { - transform: none; - } -} \ No newline at end of file diff --git a/packages/techor/tests/css-bundle/src/heart.css b/packages/techor/tests/css-bundle/src/heart.css deleted file mode 100644 index 40ebff3..0000000 --- a/packages/techor/tests/css-bundle/src/heart.css +++ /dev/null @@ -1,21 +0,0 @@ -@keyframes heart { - 0% { - transform: scale(1); - } - - 14% { - transform: scale(1.3); - } - - 28% { - transform: scale(1); - } - - 42% { - transform: scale(1.3); - } - - 70% { - transform: scale(1); - } -} \ No newline at end of file diff --git a/packages/techor/tests/css-bundle/src/index.css b/packages/techor/tests/css-bundle/src/index.css deleted file mode 100644 index 60b666b..0000000 --- a/packages/techor/tests/css-bundle/src/index.css +++ /dev/null @@ -1,2 +0,0 @@ -@import 'heart'; -@import 'float'; \ No newline at end of file diff --git a/packages/techor/tests/css-bundle/test.ts b/packages/techor/tests/css-bundle/test.ts deleted file mode 100644 index cf85755..0000000 --- a/packages/techor/tests/css-bundle/test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { execSync } from 'node:child_process' -import { expectExist } from '../../../../utils/expect-exist' - -test('specify css entries', () => { - execSync('tsx ../../src/bin pack', { cwd: __dirname, stdio: 'pipe' }) - expectExist(['dist/index.bundle.css']) -}) \ No newline at end of file diff --git a/packages/techor/tests/css/package.json b/packages/techor/tests/css/package.json deleted file mode 100644 index 45b9add..0000000 --- a/packages/techor/tests/css/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "@test/css", - "version": "1.0.0", - "private": true, - "main": "./dist/index.css", - "style": "./dist/index.css", - "files": [ - "dist" - ] -} \ No newline at end of file diff --git a/packages/techor/tests/css/src/float.css b/packages/techor/tests/css/src/float.css deleted file mode 100644 index e4964b4..0000000 --- a/packages/techor/tests/css/src/float.css +++ /dev/null @@ -1,13 +0,0 @@ -@keyframes float { - 0% { - transform: none; - } - - 50% { - transform: translateY(-1.25rem); - } - - 100% { - transform: none; - } -} \ No newline at end of file diff --git a/packages/techor/tests/css/src/heart.css b/packages/techor/tests/css/src/heart.css deleted file mode 100644 index 40ebff3..0000000 --- a/packages/techor/tests/css/src/heart.css +++ /dev/null @@ -1,21 +0,0 @@ -@keyframes heart { - 0% { - transform: scale(1); - } - - 14% { - transform: scale(1.3); - } - - 28% { - transform: scale(1); - } - - 42% { - transform: scale(1.3); - } - - 70% { - transform: scale(1); - } -} \ No newline at end of file diff --git a/packages/techor/tests/css/src/index.css b/packages/techor/tests/css/src/index.css deleted file mode 100644 index 60b666b..0000000 --- a/packages/techor/tests/css/src/index.css +++ /dev/null @@ -1,2 +0,0 @@ -@import 'heart'; -@import 'float'; \ No newline at end of file diff --git a/packages/techor/tests/css/test.ts b/packages/techor/tests/css/test.ts deleted file mode 100644 index 51e467a..0000000 --- a/packages/techor/tests/css/test.ts +++ /dev/null @@ -1,9 +0,0 @@ -import { expectFileIncludes } from '../../../../utils/expect-file-includes' -import { expectExist } from '../../../../utils/expect-exist' -import { execSync } from 'node:child_process' - -test('extract css entries from `package.json`', () => { - execSync(`tsx ../../src/bin pack "./src/**/*.css" --bundle`, { cwd: __dirname, stdio: 'inherit' }) - expectExist(['dist/index.css']) - expectFileIncludes('dist/index.css', ['@keyframes heart{0%{transform:scale(1)}14%{transform:scale(1.3)}28%{transform:scale(1)}42%{transform:scale(1.3)}70%{transform:scale(1)}}@keyframes float{0%{transform:none}50%{transform:translateY(-1.25rem)}to{transform:none}}'], { cwd: __dirname }) -}) \ No newline at end of file diff --git a/packages/techor/tests/entry-names/package.json b/packages/techor/tests/entry-names/package.json deleted file mode 100644 index c24add4..0000000 --- a/packages/techor/tests/entry-names/package.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "@test/entry-names", - "version": "1.0.0", - "private": true, - "sideEffects": false, - "main": "./dist/index.bundle.js", - "module": "./dist/index.bundle.mjs", - "files": [ - "dist" - ] -} \ No newline at end of file diff --git a/packages/techor/tests/entry-names/src/a.ts b/packages/techor/tests/entry-names/src/a.ts index c7e14ef..6187db8 100644 --- a/packages/techor/tests/entry-names/src/a.ts +++ b/packages/techor/tests/entry-names/src/a.ts @@ -1 +1,3 @@ -export const a = 'a' \ No newline at end of file +const a = 'a'; + +export { a }; diff --git a/packages/techor/tests/entry-names/src/b.ts b/packages/techor/tests/entry-names/src/b.ts index c998066..2148568 100644 --- a/packages/techor/tests/entry-names/src/b.ts +++ b/packages/techor/tests/entry-names/src/b.ts @@ -1 +1,3 @@ -export const b = 'b' \ No newline at end of file +const b = 'b'; + +export { b }; diff --git a/packages/techor/tests/entry-names/src/c/index.ts b/packages/techor/tests/entry-names/src/c/index.ts new file mode 100644 index 0000000..0e0a7e5 --- /dev/null +++ b/packages/techor/tests/entry-names/src/c/index.ts @@ -0,0 +1,3 @@ +const c = 'c'; + +export { c }; diff --git a/packages/techor/tests/entry-names/src/index.ts b/packages/techor/tests/entry-names/src/index.ts index fd4f2c4..29cf798 100644 --- a/packages/techor/tests/entry-names/src/index.ts +++ b/packages/techor/tests/entry-names/src/index.ts @@ -1,2 +1,5 @@ -export * from './a' -export * from './b' \ No newline at end of file +const a = 'a'; +const b = 'b'; +const c = 'c'; + +export { a, b, c }; diff --git a/packages/techor/tests/entry-names/test.ts b/packages/techor/tests/entry-names/test.ts index 1b445f3..6bad5c4 100644 --- a/packages/techor/tests/entry-names/test.ts +++ b/packages/techor/tests/entry-names/test.ts @@ -3,9 +3,11 @@ import path from 'path' import { existsSync } from 'fs' beforeAll(() => { - execSync(`tsx ../../src/bin pack "src/**/*.ts" --format esm --bundle`, { cwd: __dirname, stdio: 'inherit' }) + execSync(`tsx ../../src/bin build "src/**/*.ts" --formats esm`, { cwd: __dirname }) }) it('contains bundled files', () => { - expect(existsSync(path.join(__dirname, 'dist/index.bundle.mjs'))).toBeDefined() + expect(existsSync(path.join(__dirname, 'dist/a.mjs'))).toBeDefined() + expect(existsSync(path.join(__dirname, 'dist/b.mjs'))).toBeDefined() + expect(existsSync(path.join(__dirname, 'dist/index.mjs'))).toBeDefined() }) \ No newline at end of file diff --git a/packages/techor/tests/esm-bin/test.ts b/packages/techor/tests/esm-bin/test.ts index 1a641bf..691be82 100644 --- a/packages/techor/tests/esm-bin/test.ts +++ b/packages/techor/tests/esm-bin/test.ts @@ -2,6 +2,6 @@ import { execSync } from 'node:child_process' import { expectFileIncludes } from '../../../../utils/expect-file-includes' test('esm bin', () => { - execSync('tsx ../../src/bin pack', { cwd: __dirname, stdio: 'inherit' }) - expectFileIncludes('dist/bin/index.mjs', ['import n from"ora";'], { cwd: __dirname }) + execSync('tsx ../../src/bin build', { cwd: __dirname }) + expectFileIncludes('dist/bin/index.mjs', [`import ora from 'ora';`], { cwd: __dirname }) }) \ No newline at end of file diff --git a/packages/techor/tests/exports/pack.test.ts b/packages/techor/tests/exports/pack.test.ts index b4ffd1e..ada21b9 100644 --- a/packages/techor/tests/exports/pack.test.ts +++ b/packages/techor/tests/exports/pack.test.ts @@ -2,8 +2,8 @@ import { execSync } from 'node:child_process' import { expectExist } from '../../../../utils/expect-exist' it('exports', () => { - execSync('tsx ../../src/bin pack', { cwd: __dirname, stdio: 'pipe' }) + execSync('tsx ../../src/bin build', { cwd: __dirname, stdio: 'pipe' }) expectExist([ - 'dist/index.js', + 'dist/index.cjs', ]) }) \ No newline at end of file diff --git a/packages/techor/tests/exports/package.json b/packages/techor/tests/exports/package.json index c3a64c7..ae95965 100644 --- a/packages/techor/tests/exports/package.json +++ b/packages/techor/tests/exports/package.json @@ -2,10 +2,10 @@ "name": "@test/exports", "version": "1.0.0", "private": true, - "main": "./dist/index.js", - "types": "./dist/index.js", + "main": "./dist/index.cjs", + "types": "./dist/index.cjs", "exports": { - ".": "./dist/index.js" + ".": "./dist/index.cjs" }, "files": [ "dist" diff --git a/packages/techor/tests/exports/src/index.ts b/packages/techor/tests/exports/src/index.ts index fde0abd..9cfeb7d 100644 --- a/packages/techor/tests/exports/src/index.ts +++ b/packages/techor/tests/exports/src/index.ts @@ -1 +1,3 @@ -console.log('123') \ No newline at end of file +export default () => { + console.log('123') +} \ No newline at end of file diff --git a/packages/techor/tests/external/package.json b/packages/techor/tests/external/package.json index bfeb83d..4aa9071 100644 --- a/packages/techor/tests/external/package.json +++ b/packages/techor/tests/external/package.json @@ -2,12 +2,7 @@ "name": "@test/external", "version": "1.0.0", "private": true, - "main": "dist/index.bundle.js", - "exports": { - ".": { - "require": "./dist/index.bundle.js" - } - }, + "main": "dist/index.cjs", "files": [ "dist" ], diff --git a/packages/techor/tests/external/src/index.ts b/packages/techor/tests/external/src/index.ts index 5fe4afe..e3f151a 100644 --- a/packages/techor/tests/external/src/index.ts +++ b/packages/techor/tests/external/src/index.ts @@ -1,9 +1,10 @@ -import extend from '@techor/extend' -import log from '@techor/log' - -console.log(extend, log) +import extend from '@techor/extend' // deps +import log from '@techor/log' // peerDeps +import { del } from '@techor/log/dist' // wide module path // @ts-ignore -import 'fake-external-package' +import 'fake-external-package' // --external fake-external-package + +export * from './foo' -export * from './foo' \ No newline at end of file +console.log(extend, log, del) diff --git a/packages/techor/tests/external/test.ts b/packages/techor/tests/external/test.ts index d66d303..e17e9bc 100644 --- a/packages/techor/tests/external/test.ts +++ b/packages/techor/tests/external/test.ts @@ -1,27 +1,23 @@ import { execSync } from 'node:child_process' -import { readFileAsNormalizedStrSync } from '../../../fs/src' +import { readFileSync } from 'node:fs' import { join } from 'node:path' -import dedent from 'ts-dedent' beforeAll(() => { - execSync('tsx ../../src/bin pack --platform node --no-minify --external fake-external-package', { cwd: __dirname, stdio: 'inherit' }) + execSync('tsx ../../src/bin build --external fake-external-package', { cwd: __dirname }) }) -it('prevent bundling dependencies and peerDependencies', () => { - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.bundle.js'))).toContain('require("@techor/extend")') - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.bundle.js'))).toContain('require("@techor/log")') +it('prevent bundling dependencies', () => { + expect(readFileSync(join(__dirname, 'dist/index.cjs')).toString()).toContain(`require('@techor/extend')`) }) -it('prevent bundling specified externals', () => { - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.bundle.js'))).toContain('require("fake-external-package")') +it('prevent bundling peerDependencies', () => { + expect(readFileSync(join(__dirname, 'dist/index.cjs')).toString()).toContain(`require('@techor/log')`) +}) + +it('prevent bundling wide module path', () => { + expect(readFileSync(join(__dirname, 'dist/index.cjs')).toString()).toContain(`require('@techor/log/dist')`) }) -// it('should not bundle `src/**/*` modules', () => { -// expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.mjs'))).toContain('export * from "./foo.mjs";') -// expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/foo.mjs'))).toContain(dedent` -// var foo = "foo"; -// export { -// foo -// }; -// `) -// }) \ No newline at end of file +it('prevent bundling specified externals', () => { + expect(readFileSync(join(__dirname, 'dist/index.cjs')).toString()).toContain(`require('fake-external-package')`) +}) diff --git a/packages/techor/tests/global/package.json b/packages/techor/tests/global/package.json new file mode 100644 index 0000000..348a13d --- /dev/null +++ b/packages/techor/tests/global/package.json @@ -0,0 +1,13 @@ +{ + "name": "@test/global", + "version": "1.0.0", + "private": true, + "main": "dist/global.js", + "browser": "dist/global.min.js", + "files": [ + "dist" + ], + "dependencies": { + "is-obj": "^3.0.0" + } +} \ No newline at end of file diff --git a/packages/techor/tests/global/src/global.min.ts b/packages/techor/tests/global/src/global.min.ts new file mode 100644 index 0000000..aa59cac --- /dev/null +++ b/packages/techor/tests/global/src/global.min.ts @@ -0,0 +1 @@ +export * from './global' \ No newline at end of file diff --git a/packages/techor/tests/global/src/global.ts b/packages/techor/tests/global/src/global.ts new file mode 100644 index 0000000..52039ce --- /dev/null +++ b/packages/techor/tests/global/src/global.ts @@ -0,0 +1,17 @@ +import isObject from 'is-obj' + +console.log(isObject({ foo: 'bar' })) + +globalThis.effect1 = 'created' + +const includeEffect = false + +if (includeEffect) { + globalThis.effect1 = 'not created' +} + +function effect2() { + globalThis.effect2 = 'created' +} + +effect2() \ No newline at end of file diff --git a/packages/techor/tests/global/test.ts b/packages/techor/tests/global/test.ts new file mode 100644 index 0000000..c8b107f --- /dev/null +++ b/packages/techor/tests/global/test.ts @@ -0,0 +1,20 @@ +import { execSync } from 'node:child_process' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' + +beforeAll(() => { + execSync('tsx ../../src/bin build', { cwd: __dirname }) +}) + +it('generate iife format', () => { + expect(readFileSync(join(__dirname, './dist/global.js'), 'utf-8')).toContain('(function () {') +}) + +it('should bundle all deps', () => { + expect(readFileSync(join(__dirname, './dist/global.js'), 'utf-8')).toContain('function isObject(value)') +}) + +it('should be minifined', () => { + expect(readFileSync(join(__dirname, './dist/global.min.js'), 'utf-8')).toBe('(()=>{(function(){"use strict";function c(t){const e=typeof t;return t!==null&&(e==="object"||e==="function")}console.log(c({foo:"bar"})),globalThis.effect1="created";function o(){globalThis.effect2="created"}o()})();})();\n') +}) + diff --git a/packages/techor/tests/mjs/tsconfig.json b/packages/techor/tests/global/tsconfig.json similarity index 64% rename from packages/techor/tests/mjs/tsconfig.json rename to packages/techor/tests/global/tsconfig.json index 200db72..b94c20e 100644 --- a/packages/techor/tests/mjs/tsconfig.json +++ b/packages/techor/tests/global/tsconfig.json @@ -2,12 +2,10 @@ "extends": "../../../../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "outDir": "dist" + "outDir": "dist", }, "include": [ - "src/**/*.ts", - "src/**/*.mts", - "src/**/*.d.ts" + "src/**/*" ], "exclude": [ "src/**/*.test.ts" diff --git a/packages/techor/tests/master/sources/packages/react/package.json b/packages/techor/tests/master/sources/packages/react/package.json index a8f7dfd..01d373c 100644 --- a/packages/techor/tests/master/sources/packages/react/package.json +++ b/packages/techor/tests/master/sources/packages/react/package.json @@ -37,7 +37,6 @@ ], "sideEffects": false, "main": "./dist/index.js", - "jsnext:main": "./dist/index.mjs", "esnext": "./dist/index.mjs", "module": "./dist/index.mjs", "types": "./dist/index.d.ts", diff --git a/packages/techor/tests/master/test.ts b/packages/techor/tests/master/test.ts index f0c9ab8..9c8497a 100644 --- a/packages/techor/tests/master/test.ts +++ b/packages/techor/tests/master/test.ts @@ -14,7 +14,7 @@ beforeAll(() => { it('bump to specific version for all workspaces', () => { process.chdir(tmpDir) - execSync('tsx ../../../src/bin version 2.0.0-beta.200', { cwd: tmpDir, stdio: 'inherit' }) + execSync('tsx ../../../src/bin version 2.0.0-beta.200', { cwd: tmpDir, stdio: 'pipe' }) const workspacePackagePaths = readWorkspaces().map((eachWorkspace) => path.join(eachWorkspace, '*package.json')) for (const eachPackagePath of explorePathsSync(workspacePackagePaths)) { const eachPackageRaw = readFileSync(path.resolve(eachPackagePath), { encoding: 'utf8' }) diff --git a/packages/techor/tests/minify/package.json b/packages/techor/tests/minify/package.json new file mode 100644 index 0000000..f5934c1 --- /dev/null +++ b/packages/techor/tests/minify/package.json @@ -0,0 +1,10 @@ +{ + "name": "@test/minify", + "version": "1.0.0", + "private": true, + "type": "module", + "main": "dist/index.mjs", + "files": [ + "dist" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/minify/src/index.ts b/packages/techor/tests/minify/src/index.ts new file mode 100644 index 0000000..b210e59 --- /dev/null +++ b/packages/techor/tests/minify/src/index.ts @@ -0,0 +1,5 @@ +export default function main() { + console.log('main') +} + +main() \ No newline at end of file diff --git a/packages/techor/tests/minify/test.ts b/packages/techor/tests/minify/test.ts new file mode 100644 index 0000000..0eeff8b --- /dev/null +++ b/packages/techor/tests/minify/test.ts @@ -0,0 +1,8 @@ +import { execSync } from 'node:child_process' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' + +test('main', () => { + execSync('tsx ../../src/bin build --minify', { cwd: __dirname }) + expect(readFileSync(join(__dirname, './dist/index.mjs'), 'utf-8').toString()).toEqual('function n(){console.log("main")}n();export{n as default};\n') +}) \ No newline at end of file diff --git a/packages/techor/tests/minify/tsconfig.json b/packages/techor/tests/minify/tsconfig.json new file mode 100644 index 0000000..b94c20e --- /dev/null +++ b/packages/techor/tests/minify/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "outDir": "dist", + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "src/**/*.test.ts" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/mjs/package.json b/packages/techor/tests/mjs/package.json deleted file mode 100644 index e789d81..0000000 --- a/packages/techor/tests/mjs/package.json +++ /dev/null @@ -1,19 +0,0 @@ -{ - "name": "@test/options", - "version": "1.0.0", - "private": true, - "module": "./dist/index.bundle.mjs", - "exports": { - ".": { - "import": "./dist/index.bundle.mjs" - }, - "./tree-shaking": "./dist/tree-shaking.mjs" - }, - "sideEffects": false, - "files": [ - "dist" - ], - "dependencies": { - "server-only": "^0.0.1" - } -} \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/components/AAA.ts b/packages/techor/tests/mjs/src/components/AAA.ts deleted file mode 100644 index 653ac29..0000000 --- a/packages/techor/tests/mjs/src/components/AAA.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { aUtil } from '../utils/a-util' - -const hasFn = typeof Function !== 'undefined' - -export class AAA extends (hasFn ? Function : Object) { - _fullAAAMembership = 1 - constructor() { - super() - console.log(this._fullAAAMembership, aUtil()) - } -} \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/components/BBB.ts b/packages/techor/tests/mjs/src/components/BBB.ts deleted file mode 100644 index 9dc22ab..0000000 --- a/packages/techor/tests/mjs/src/components/BBB.ts +++ /dev/null @@ -1,3 +0,0 @@ -export class BBB { - name = 'test' -} \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/components/index.ts b/packages/techor/tests/mjs/src/components/index.ts deleted file mode 100644 index 09b3e44..0000000 --- a/packages/techor/tests/mjs/src/components/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './AAA' -export * from './BBB' \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/index.ts b/packages/techor/tests/mjs/src/index.ts deleted file mode 100644 index be0ece8..0000000 --- a/packages/techor/tests/mjs/src/index.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { AAA, BBB } from './components' -import 'server-only/default.js' - -export * from './components' -export const components = [ - AAA, - BBB -] - -const a = [...new Set([1, 2, 3])] -// eslint-disable-next-line quotes -const b = "import { AAA, BBB } from './components'" - -console.log(a) \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/tree-shaking.ts b/packages/techor/tests/mjs/src/tree-shaking.ts deleted file mode 100644 index fb295db..0000000 --- a/packages/techor/tests/mjs/src/tree-shaking.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { BBB } from './' - -console.log(BBB) \ No newline at end of file diff --git a/packages/techor/tests/mjs/src/utils/a-util.ts b/packages/techor/tests/mjs/src/utils/a-util.ts deleted file mode 100644 index e87ce48..0000000 --- a/packages/techor/tests/mjs/src/utils/a-util.ts +++ /dev/null @@ -1,3 +0,0 @@ -export function aUtil() { - return 'aUtil' -} \ No newline at end of file diff --git a/packages/techor/tests/mjs/test.ts b/packages/techor/tests/mjs/test.ts deleted file mode 100644 index 41a6056..0000000 --- a/packages/techor/tests/mjs/test.ts +++ /dev/null @@ -1,33 +0,0 @@ -import { execSync } from 'node:child_process' -import { readFileAsNormalizedStrSync } from '../../../fs/src' -import { join } from 'node:path' -import dedent from 'ts-dedent' - -beforeAll(() => { - execSync(`tsx ../../src/bin pack "./src/**/*.ts" --no-minify --mangle-props "^_"`, { cwd: __dirname, stdio: 'inherit' }) -}) - -it('mangle private', () => { - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.mjs'))).not.toContain('_fullAAAMembership') -}) - -it('autofill mjs', () => { - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/index.mjs'))).toContain(dedent` - import { AAA, BBB } from "./components/index.mjs"; - import "server-only/default.js"; - export * from "./components/index.mjs"; - `) - expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/components/AAA.mjs'))).toContain('import { aUtil } from "../utils/a-util.mjs";') -}) - -// it('bundled file and tree shaking', () => { -// expect(readFileAsNormalizedStrSync(join(__dirname, 'dist/tree-shaking.bundle.mjs'))).toEqual(dedent` -// // src/components/BBB.mts -// var BBB = class { -// name = "test"; -// }; - -// // src/tree-shaking.mts -// console.log(BBB);\n -// `) -// }) \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/pack.test.ts b/packages/techor/tests/multi-exports/pack.test.ts index d3670e2..ae47311 100644 --- a/packages/techor/tests/multi-exports/pack.test.ts +++ b/packages/techor/tests/multi-exports/pack.test.ts @@ -2,11 +2,20 @@ import { execSync } from 'node:child_process' import { expectExist } from '../../../../utils/expect-exist' it('exports multiple outputs', () => { - execSync('tsx ../../src/bin pack --declare', { cwd: __dirname, stdio: 'pipe' }) + execSync('tsx ../../src/bin build', { cwd: __dirname, stdio: 'pipe' }) expectExist([ - 'dist/index.browser.js', - 'dist/index.browser.d.ts', + 'dist/browser/index.cjs', + 'dist/browser/index.js', + 'dist/browser/index.mjs', + 'dist/browser/index.d.ts', + 'dist/a.cjs', + 'dist/b.cjs', + 'dist/index.cjs', + 'dist/a.mjs', + 'dist/b.mjs', + 'dist/index.mjs', + 'dist/a.d.ts', + 'dist/b.d.ts', 'dist/index.d.ts', - 'dist/options.d.ts', ]) }) \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/package.json b/packages/techor/tests/multi-exports/package.json index 6958b12..6f7a5ab 100644 --- a/packages/techor/tests/multi-exports/package.json +++ b/packages/techor/tests/multi-exports/package.json @@ -2,30 +2,29 @@ "name": "@test/multi-exports", "version": "1.0.0", "private": true, - "main": "./dist/index.js", - "jsnext:main": "./dist/index.js", - "browser": "./dist/index.browser.js", - "esnext": "./dist/index.js", - "module": "./dist/index.js", + "main": "./dist/index.cjs", + "browser": "./dist/browser/index.js", + "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { "node": { - "require": "./dist/index.js", - "import": "./dist/index.js" + "require": "./dist/index.cjs", + "import": "./dist/index.mjs" }, "browser": { - "import": "./dist/index.browser.mjs" + "require": "./dist/browser/index.cjs", + "import": "./dist/browser/index.mjs" }, "default": { - "require": "./dist/index.default.js", - "import": "./dist/index.default.mjs" + "require": "./dist/a.cjs", + "import": "./dist/a.mjs" }, "types": "./dist/index.d.ts" }, - "./options": { - "require": "./dist/options.js", - "import": "./dist/options.mjs" + "./b": { + "require": "./dist/b.cjs", + "import": "./dist/b.mjs" } }, "files": [ diff --git a/packages/techor/tests/multi-exports/src/a.ts b/packages/techor/tests/multi-exports/src/a.ts new file mode 100644 index 0000000..c7e14ef --- /dev/null +++ b/packages/techor/tests/multi-exports/src/a.ts @@ -0,0 +1 @@ +export const a = 'a' \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/b.ts b/packages/techor/tests/multi-exports/src/b.ts new file mode 100644 index 0000000..3ca86a4 --- /dev/null +++ b/packages/techor/tests/multi-exports/src/b.ts @@ -0,0 +1,3 @@ +import { a } from './a' +export const b = 'b' +console.log(a) \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/browser/index.ts b/packages/techor/tests/multi-exports/src/browser/index.ts new file mode 100644 index 0000000..53bd4a3 --- /dev/null +++ b/packages/techor/tests/multi-exports/src/browser/index.ts @@ -0,0 +1,2 @@ +export * from '../b' +export const browser = 'browser' \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/index.browser.ts b/packages/techor/tests/multi-exports/src/index.browser.ts deleted file mode 100644 index 909e1a0..0000000 --- a/packages/techor/tests/multi-exports/src/index.browser.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './options' -console.log('browser') \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/index.default.ts b/packages/techor/tests/multi-exports/src/index.default.ts deleted file mode 100644 index bb69eab..0000000 --- a/packages/techor/tests/multi-exports/src/index.default.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './options' -console.log('default') \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/index.ts b/packages/techor/tests/multi-exports/src/index.ts index 9a7078d..68b3854 100644 --- a/packages/techor/tests/multi-exports/src/index.ts +++ b/packages/techor/tests/multi-exports/src/index.ts @@ -1,2 +1,3 @@ -export * from './options' -console.log('node') \ No newline at end of file +export * from './a' +export * from './b' +export default 'main' \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/src/options.ts b/packages/techor/tests/multi-exports/src/options.ts deleted file mode 100644 index 1833995..0000000 --- a/packages/techor/tests/multi-exports/src/options.ts +++ /dev/null @@ -1,3 +0,0 @@ -export const options = { - module: 'master.css' -} \ No newline at end of file diff --git a/packages/techor/tests/multi-exports/tsconfig.json b/packages/techor/tests/multi-exports/tsconfig.json index b94c20e..bea9c99 100644 --- a/packages/techor/tests/multi-exports/tsconfig.json +++ b/packages/techor/tests/multi-exports/tsconfig.json @@ -2,7 +2,7 @@ "extends": "../../../../tsconfig.json", "compilerOptions": { "baseUrl": ".", - "outDir": "dist", + "outDir": "dist" }, "include": [ "src/**/*" diff --git a/packages/techor/tests/pnpm-lock.yaml b/packages/techor/tests/pnpm-lock.yaml index a68dfef..9525056 100644 --- a/packages/techor/tests/pnpm-lock.yaml +++ b/packages/techor/tests/pnpm-lock.yaml @@ -16,6 +16,8 @@ importers: args-externals: {} + auto: {} + b: {} c: @@ -24,16 +26,8 @@ importers: specifier: '' version: link:../a - css: {} - - css-args: {} - - css-bundle: {} - dev-dependency: {} - entry-names: {} - esm-bin: dependencies: ora: @@ -55,24 +49,28 @@ importers: specifier: '' version: 2.4.6 - mjs: + global: dependencies: - server-only: - specifier: ^0.0.1 - version: 0.0.1 + is-obj: + specifier: ^3.0.0 + version: 3.0.0 + + minify: {} multi-exports: {} npm: {} + raw-loader: {} + + shim: {} + specified: dependencies: server-only: specifier: ^0.0.1 version: 0.0.1 - specified-ext: {} - standard: dependencies: '@techor/extend': @@ -559,6 +557,11 @@ packages: engines: {node: '>=0.12.0'} dev: false + /is-obj@3.0.0: + resolution: {integrity: sha512-IlsXEHOjtKhpN8r/tRFj2nDyTmHvcfNeu/nrRIcXE17ROeatXchkojffa1SpdqW4cr/Fj6QkEf/Gn4zf6KKvEQ==} + engines: {node: '>=12'} + dev: false + /is-unicode-supported@1.3.0: resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} engines: {node: '>=12'} diff --git a/packages/techor/tests/raw-loader/declarations.d.ts b/packages/techor/tests/raw-loader/declarations.d.ts new file mode 100644 index 0000000..ecdd3ba --- /dev/null +++ b/packages/techor/tests/raw-loader/declarations.d.ts @@ -0,0 +1,4 @@ +declare module '*.txt' { + const content: string + export default content +} diff --git a/packages/techor/tests/raw-loader/package.json b/packages/techor/tests/raw-loader/package.json new file mode 100644 index 0000000..b3094ab --- /dev/null +++ b/packages/techor/tests/raw-loader/package.json @@ -0,0 +1,9 @@ +{ + "name": "@test/raw-loader", + "version": "1.0.0", + "private": true, + "module": "dist/index.mjs", + "files": [ + "dist" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/raw-loader/src/a.txt b/packages/techor/tests/raw-loader/src/a.txt new file mode 100644 index 0000000..5e1c309 --- /dev/null +++ b/packages/techor/tests/raw-loader/src/a.txt @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/packages/techor/tests/raw-loader/src/index.ts b/packages/techor/tests/raw-loader/src/index.ts new file mode 100644 index 0000000..23a4733 --- /dev/null +++ b/packages/techor/tests/raw-loader/src/index.ts @@ -0,0 +1,3 @@ +import a from './a.txt' + +console.log(a) \ No newline at end of file diff --git a/packages/techor/tests/raw-loader/techor.config.ts b/packages/techor/tests/raw-loader/techor.config.ts new file mode 100644 index 0000000..a3fa0e5 --- /dev/null +++ b/packages/techor/tests/raw-loader/techor.config.ts @@ -0,0 +1,11 @@ +import { Config, rawLoader } from '../../src' + +export default { + build: { + input: { + plugins: [ + rawLoader('**/*.txt') + ] + } + } +} as Config \ No newline at end of file diff --git a/packages/techor/tests/raw-loader/test.ts b/packages/techor/tests/raw-loader/test.ts new file mode 100644 index 0000000..87ddb05 --- /dev/null +++ b/packages/techor/tests/raw-loader/test.ts @@ -0,0 +1,11 @@ +import { execSync } from 'node:child_process' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' + +beforeAll(() => { + execSync('tsx ../../src/bin build', { cwd: __dirname }) +}) + +test('main', () => { + expect(readFileSync(join(__dirname, './dist/index.mjs'), 'utf-8')).toContain('var a = "Hello World";') +}) \ No newline at end of file diff --git a/packages/techor/tests/raw-loader/tsconfig.json b/packages/techor/tests/raw-loader/tsconfig.json new file mode 100644 index 0000000..1066abf --- /dev/null +++ b/packages/techor/tests/raw-loader/tsconfig.json @@ -0,0 +1,14 @@ +{ + "extends": "../../../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "outDir": "dist", + }, + "include": [ + "src/**/*", + "declarations.d.ts", + ], + "exclude": [ + "src/**/*.test.ts" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/shim/package.json b/packages/techor/tests/shim/package.json new file mode 100644 index 0000000..4c7e367 --- /dev/null +++ b/packages/techor/tests/shim/package.json @@ -0,0 +1,10 @@ +{ + "name": "@test/shim", + "version": "1.0.0", + "private": true, + "main": "dist/index.cjs", + "module": "dist/index.mjs", + "files": [ + "dist" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/shim/src/a.ts b/packages/techor/tests/shim/src/a.ts new file mode 100644 index 0000000..8f1072c --- /dev/null +++ b/packages/techor/tests/shim/src/a.ts @@ -0,0 +1 @@ +export default 'a' \ No newline at end of file diff --git a/packages/techor/tests/shim/src/index.ts b/packages/techor/tests/shim/src/index.ts new file mode 100644 index 0000000..0723ec8 --- /dev/null +++ b/packages/techor/tests/shim/src/index.ts @@ -0,0 +1,4 @@ +#!/usr/bin/env node +import fs from 'fs' + +console.log(fs, __dirname, __filename, require('./a')) \ No newline at end of file diff --git a/packages/techor/tests/shim/test.ts b/packages/techor/tests/shim/test.ts new file mode 100644 index 0000000..2e3aa0f --- /dev/null +++ b/packages/techor/tests/shim/test.ts @@ -0,0 +1,22 @@ +import { execSync } from 'node:child_process' +import { readFileSync } from 'node:fs' +import { join } from 'node:path' +import { ESM_SHIM_CODE } from '../../src/plugins/esm-shim' + +beforeAll(() => { + execSync('tsx ../../src/bin build', { cwd: __dirname }) +}) + +it('contains ESM shim code in ESM', () => { + expect(readFileSync(join(__dirname, './dist/index.mjs'), 'utf-8')).toContain(ESM_SHIM_CODE) +}) + +it('should not contain ESM shim code in CJS', () => { + expect(readFileSync(join(__dirname, './dist/index.cjs'), 'utf-8')).not.toContain(ESM_SHIM_CODE) +}) + +it('starts with #!', () => { + expect(readFileSync(join(__dirname, './dist/index.cjs'), 'utf-8').startsWith('#!')).toBeTruthy() + expect(readFileSync(join(__dirname, './dist/index.mjs'), 'utf-8').startsWith('#!')).toBeTruthy() +}) + diff --git a/packages/techor/tests/shim/tsconfig.json b/packages/techor/tests/shim/tsconfig.json new file mode 100644 index 0000000..b94c20e --- /dev/null +++ b/packages/techor/tests/shim/tsconfig.json @@ -0,0 +1,13 @@ +{ + "extends": "../../../../tsconfig.json", + "compilerOptions": { + "baseUrl": ".", + "outDir": "dist", + }, + "include": [ + "src/**/*" + ], + "exclude": [ + "src/**/*.test.ts" + ] +} \ No newline at end of file diff --git a/packages/techor/tests/specified-ext/pack.test.ts b/packages/techor/tests/specified-ext/pack.test.ts deleted file mode 100644 index aa42f66..0000000 --- a/packages/techor/tests/specified-ext/pack.test.ts +++ /dev/null @@ -1,7 +0,0 @@ -import { execSync } from 'node:child_process' -import { expectExist } from '../../../../utils/expect-exist' - -test('specified ext `.js` by "main": "dist/index.js"', () => { - execSync('tsx ../../src/bin pack', { cwd: __dirname, stdio: 'pipe' }) - expectExist(['dist/index.js']) -}) \ No newline at end of file diff --git a/packages/techor/tests/specified-ext/package.json b/packages/techor/tests/specified-ext/package.json deleted file mode 100644 index ae17494..0000000 --- a/packages/techor/tests/specified-ext/package.json +++ /dev/null @@ -1,14 +0,0 @@ -{ - "name": "@test/specified-ext", - "version": "1.0.0", - "private": true, - "main": "dist/index.js", - "exports": { - ".": { - "require": "./dist/index.js" - } - }, - "files": [ - "dist" - ] -} \ No newline at end of file diff --git a/packages/techor/tests/specified-ext/src/index.ts b/packages/techor/tests/specified-ext/src/index.ts deleted file mode 100644 index 7f7cc29..0000000 --- a/packages/techor/tests/specified-ext/src/index.ts +++ /dev/null @@ -1 +0,0 @@ -console.log('index') \ No newline at end of file diff --git a/packages/techor/tests/specified/package.json b/packages/techor/tests/specified/package.json index 5f5266c..a80204a 100644 --- a/packages/techor/tests/specified/package.json +++ b/packages/techor/tests/specified/package.json @@ -2,7 +2,6 @@ "name": "@test/force-bundle", "version": "1.0.0", "private": true, - "main": "./dist/index.bundle.js", "files": [ "dist" ], diff --git a/packages/techor/tests/specified/src/index.ts b/packages/techor/tests/specified/src/index.ts index 2fac8dc..26d3737 100644 --- a/packages/techor/tests/specified/src/index.ts +++ b/packages/techor/tests/specified/src/index.ts @@ -1 +1 @@ -import 'server-only' \ No newline at end of file +throw new Error('This module cannot be imported from a Client Component module. ' + 'It should only be used from a Server Component.') \ No newline at end of file diff --git a/packages/techor/tests/specified/test.ts b/packages/techor/tests/specified/test.ts index 852d482..0c7b5e0 100644 --- a/packages/techor/tests/specified/test.ts +++ b/packages/techor/tests/specified/test.ts @@ -1,9 +1,7 @@ import { execSync } from 'node:child_process' import { expectFileIncludes } from '../../../../utils/expect-file-includes' -import { expectExist } from '../../../../utils/expect-exist' it('force to bundle', () => { - execSync('tsx ../../src/bin pack "src/index.ts" --outfile "dist/bundle.js" --bundle --no-external --declare', { cwd: __dirname, stdio: 'pipe' }) - expectFileIncludes('dist/bundle.js', ['throw new Error("This module cannot be imported from a Client Component module. It should only be used from a Server Component.");'], { cwd: __dirname }) - expectExist(['dist/bundle.d.ts']) + execSync('tsx ../../src/bin build "src/index.ts" -o "dist/bundle.js" --no-external', { cwd: __dirname, stdio: 'pipe' }) + expectFileIncludes('dist/bundle.js', ['This module cannot be imported from a Client Component module.'], { cwd: __dirname }) }) \ No newline at end of file diff --git a/packages/techor/tests/src/a.txt b/packages/techor/tests/src/a.txt new file mode 100644 index 0000000..5e1c309 --- /dev/null +++ b/packages/techor/tests/src/a.txt @@ -0,0 +1 @@ +Hello World \ No newline at end of file diff --git a/packages/techor/tests/standard/package.json b/packages/techor/tests/standard/package.json index 36a4aa1..6fd3441 100644 --- a/packages/techor/tests/standard/package.json +++ b/packages/techor/tests/standard/package.json @@ -3,13 +3,13 @@ "version": "1.0.0", "private": true, "sideEffects": false, - "main": "./dist/index.bundle.js", - "module": "./dist/index.bundle.mjs", + "main": "./dist/index.js", + "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "exports": { ".": { - "require": "./dist/index.bundle.js", - "import": "./dist/index.bundle.mjs" + "require": "./dist/index.js", + "import": "./dist/index.mjs" } }, "files": [ diff --git a/packages/techor/tests/standard/src/options/index.ts b/packages/techor/tests/standard/src/options/index.ts index a32083b..7ed0b67 100644 --- a/packages/techor/tests/standard/src/options/index.ts +++ b/packages/techor/tests/standard/src/options/index.ts @@ -3,4 +3,6 @@ export * from './b' import extend from '@techor/extend' import log from '@techor/log' -console.log(extend, log) \ No newline at end of file +console.log(extend, log) + +export const extendedResult = extend({}) \ No newline at end of file diff --git a/packages/techor/tests/standard/test.ts b/packages/techor/tests/standard/test.ts index 5a67034..22fc2ca 100644 --- a/packages/techor/tests/standard/test.ts +++ b/packages/techor/tests/standard/test.ts @@ -1,50 +1,48 @@ import { execSync } from 'node:child_process' -import dedent from 'ts-dedent' -import fs from 'fs' import path from 'path' +import { readFileSync } from 'node:fs' beforeAll(() => { - execSync('tsx ../../src/bin pack --platform node --no-minify', { cwd: __dirname, stdio: 'pipe' }) + execSync('tsx ../../src/bin build', { cwd: __dirname }) }) it('contains bundled files', () => { - expect(fs.readFileSync(path.join(__dirname, 'dist/index.bundle.mjs')).toString()).toContain('src/options/a.ts') - expect(fs.readFileSync(path.join(__dirname, 'dist/index.bundle.mjs')).toString()).toContain('node_modules/pretty-bytes/index.js') + expect(readFileSync(path.join(__dirname, 'dist/index.mjs')).toString()).toContain('function prettyBytes(number, options)') }) // it('contains multiple entries for tree shaking', () => { -// expect(fs.readFileSync(path.join(__dirname, 'dist/index.js')).toString()).toContain('module.exports = __toCommonJS(src_exports);') -// expect(fs.readFileSync(path.join(__dirname, 'dist/index.mjs')).toString()).toContain('export * from "./options/index.mjs";') +// expect(readFileSync(path.join(__dirname, 'dist/index.js')).toString()).toContain('module.exports = __toCommonJS(src_exports);') +// expect(readFileSync(path.join(__dirname, 'dist/index.mjs')).toString()).toContain('export * from "./options/index.mjs";') // }) // it('`./options/index` contains `./options/a` and `./options/b`', () => { -// expect(fs.readFileSync(path.join(__dirname, 'dist/options/index.js')).toString()).toContain('require("./a")') -// expect(fs.readFileSync(path.join(__dirname, 'dist/options/index.js')).toString()).toContain('require("./b")') -// expect(fs.readFileSync(path.join(__dirname, 'dist/options/index.mjs')).toString()).toContain('export * from "./a.mjs";') -// expect(fs.readFileSync(path.join(__dirname, 'dist/options/index.mjs')).toString()).toContain('export * from "./b.mjs";') +// expect(readFileSync(path.join(__dirname, 'dist/options/index.js')).toString()).toContain('require("./a")') +// expect(readFileSync(path.join(__dirname, 'dist/options/index.js')).toString()).toContain('require("./b")') +// expect(readFileSync(path.join(__dirname, 'dist/options/index.mjs')).toString()).toContain('export * from "./a.mjs";') +// expect(readFileSync(path.join(__dirname, 'dist/options/index.mjs')).toString()).toContain('export * from "./b.mjs";') // }) // it('keep output file structure', () => { -// expect(fs.readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).toContain('import { internalA } from "../internal/a.mjs";') +// expect(readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).toContain('import { internalA } from "../internal/a.mjs";') // }) // it('always bundles devDependencies even if the entry is not with `--bundle`', () => { -// expect(fs.readFileSync(path.join(__dirname, 'dist/dev-deps.mjs')).toString()).not.toContain('import prettyBytes from "pretty-bytes";') -// expect(fs.readFileSync(path.join(__dirname, 'dist/dev-deps.js')).toString()).not.toContain('var import_pretty_bytes = __toESM(require("pretty-bytes"));') -// expect(fs.readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).not.toContain('from "./dev-dependency-foo.mjs"') -// expect(fs.readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).not.toContain('import { devDependencyFoo } from "@test/dev-dependency"') +// expect(readFileSync(path.join(__dirname, 'dist/dev-deps.mjs')).toString()).not.toContain('import prettyBytes from "pretty-bytes";') +// expect(readFileSync(path.join(__dirname, 'dist/dev-deps.js')).toString()).not.toContain('var import_pretty_bytes = __toESM(require("pretty-bytes"));') +// expect(readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).not.toContain('from "./dev-dependency-foo.mjs"') +// expect(readFileSync(path.join(__dirname, 'dist/external/index.mjs')).toString()).not.toContain('import { devDependencyFoo } from "@test/dev-dependency"') // }) // it('should not contain internal modules of external `execa`', () => { -// expect(fs.readFileSync(path.join(__dirname, 'dist/external/index.js')).toString()).not.toContain('require("./lib/parse")') +// expect(readFileSync(path.join(__dirname, 'dist/external/index.js')).toString()).not.toContain('require("./lib/parse")') // }) -it('cjs bundle should be same as esbuild', () => { - execSync('esbuild src/index.ts --bundle --outfile=esbuild-dist/index.bundle.js --format=cjs --platform=node --external:@techor/log --external:@techor/extend', { cwd: __dirname, stdio: 'pipe' }) - expect(fs.readFileSync(path.join(__dirname, 'dist/index.bundle.js')).toString()).toEqual(fs.readFileSync(path.join(__dirname, 'esbuild-dist/index.bundle.js')).toString()) -}) +// it('cjs bundle should be same as esbuild', () => { +// execSync('esbuild src/index.ts --bundle --outfile=esbuild-dist/index.js --format=cjs --platform=node --external:@techor/log --external:@techor/extend', { cwd: __dirname, stdio: 'pipe' }) +// expect(readFileSync(path.join(__dirname, 'dist/index.js')).toString()).toEqual(readFileSync(path.join(__dirname, 'esbuild-dist/index.js')).toString()) +// }) -it('esm bundle should be same as esbuild', () => { - execSync('esbuild src/index.ts --bundle --outfile=esbuild-dist/index.bundle.mjs --format=esm --platform=node --external:@techor/log --external:@techor/extend', { cwd: __dirname, stdio: 'pipe' }) - expect(fs.readFileSync(path.join(__dirname, 'dist/index.bundle.mjs')).toString()).toEqual(fs.readFileSync(path.join(__dirname, 'esbuild-dist/index.bundle.mjs')).toString()) -}) +// it('esm bundle should be same as esbuild', () => { +// execSync('esbuild src/index.ts --bundle --outfile=esbuild-dist/index.mjs --format=esm --platform=node --external:@techor/log --external:@techor/extend', { cwd: __dirname, stdio: 'pipe' }) +// expect(readFileSync(path.join(__dirname, 'dist/index.mjs')).toString()).toEqual(readFileSync(path.join(__dirname, 'esbuild-dist/index.mjs')).toString()) +// }) diff --git a/packages/techor/tests/tsx/test.ts b/packages/techor/tests/tsx/test.ts index 336229f..ffcc33f 100644 --- a/packages/techor/tests/tsx/test.ts +++ b/packages/techor/tests/tsx/test.ts @@ -2,6 +2,6 @@ import { execSync } from 'node:child_process' import { expectExist } from '../../../../utils/expect-exist' test('resolve `.tsx` with `package.json`', () => { - execSync('tsx ../../src/bin pack', { cwd: __dirname, stdio: 'pipe' }) + execSync('tsx ../../src/bin build', { cwd: __dirname, stdio: 'pipe' }) expectExist(['dist/index.js']) }) \ No newline at end of file diff --git a/packages/techor/tests/type/package.json b/packages/techor/tests/type/package.json index dc9d2fb..7eac4c0 100644 --- a/packages/techor/tests/type/package.json +++ b/packages/techor/tests/type/package.json @@ -3,7 +3,8 @@ "version": "1.0.0", "private": true, "sideEffects": false, - "main": "./dist/index.js", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", "types": "./dist/index.d.ts", "files": [ "dist" diff --git a/packages/techor/tests/type/src/foo/index.ts b/packages/techor/tests/type/src/foo/index.ts new file mode 100644 index 0000000..3fd2d09 --- /dev/null +++ b/packages/techor/tests/type/src/foo/index.ts @@ -0,0 +1,3 @@ +export class Foo { + constructor() { } +} \ No newline at end of file diff --git a/packages/techor/tests/type/src/index.ts b/packages/techor/tests/type/src/index.ts index d336a35..b5b8f94 100644 --- a/packages/techor/tests/type/src/index.ts +++ b/packages/techor/tests/type/src/index.ts @@ -1,11 +1,12 @@ export default class Person { constructor( - public readonly name: string, - public readonly age: number, + name: string, + age: number ) { } sex: string weight: number height: number } -const person = new Person('John', 18) \ No newline at end of file +export { Foo } from './foo' +export const person = new Person('John', 18) \ No newline at end of file diff --git a/packages/techor/tests/type/test.ts b/packages/techor/tests/type/test.ts index a60205c..daa302f 100644 --- a/packages/techor/tests/type/test.ts +++ b/packages/techor/tests/type/test.ts @@ -4,18 +4,18 @@ import path from 'path' import { readFileAsNormalizedStrSync } from '../../../fs/src' beforeAll(() => { - execSync('tsx ../../src/bin pack --declare', { cwd: __dirname, stdio: 'pipe' }) + execSync('tsx ../../src/bin build --declare', { cwd: __dirname, stdio: 'pipe' }) }) it('generates declarations', () => { expect(readFileAsNormalizedStrSync(path.join(__dirname, 'dist/index.d.ts'))).toEqual(dedent` export default class Person { - readonly name: string; - readonly age: number; constructor(name: string, age: number); sex: string; weight: number; height: number; - }\n + } + export { Foo } from './foo'; + export declare const person: Person;\n `) }) \ No newline at end of file diff --git a/packages/techor/tsconfig.json b/packages/techor/tsconfig.json index 5f24fd3..ad6d321 100644 --- a/packages/techor/tsconfig.json +++ b/packages/techor/tsconfig.json @@ -11,4 +11,4 @@ "exclude": [ "src/**/*.test.ts" ] -} +} \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a86fe51..2e0d451 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,21 @@ importers: .: dependencies: + '@rollup/plugin-commonjs': + specifier: ^25.0.7 + version: 25.0.7(rollup@4.11.0) + '@rollup/plugin-node-resolve': + specifier: ^15.2.3 + version: 15.2.3(rollup@4.11.0) + '@rollup/plugin-swc': + specifier: ^0.3.0 + version: 0.3.0(@swc/core@1.4.1)(rollup@4.11.0) + '@rollup/plugin-typescript': + specifier: ^11.1.6 + version: 11.1.6(rollup@4.11.0)(typescript@5.3.3) + '@rollup/pluginutils': + specifier: ^5.1.0 + version: 5.1.0(rollup@4.11.0) cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -21,6 +36,9 @@ importers: '@techor/jest': specifier: workspace:^ version: link:packages/jest + '@techor/jest-dom': + specifier: workspace:^ + version: link:packages/jest-dom '@types/fs-extra': specifier: ^9.0.13 version: 9.0.13 @@ -50,16 +68,16 @@ importers: version: 3.1.0 puppeteer: specifier: ^21.0.1 - version: 21.11.0 + version: 21.11.0(typescript@5.3.3) + rollup: + specifier: ^4.11.0 + version: 4.11.0 semantic-release-config-techor: specifier: workspace:^ version: link:packages/semantic-release-config strip-ansi: specifier: ^7.0.1 version: 7.1.0 - sucrase: - specifier: ^3.32.0 - version: 3.35.0 tmp: specifier: ^0.2.1 version: 0.2.1 @@ -67,8 +85,11 @@ importers: specifier: ^2.2.0 version: 2.2.0 tsx: - specifier: ^3.12.6 - version: 3.14.0 + specifier: ^4.7.1 + version: 4.7.1 + typescript: + specifier: ^5.3.3 + version: 5.3.3 packages/commitlint-config: dependencies: @@ -276,6 +297,18 @@ importers: packages/techor: dependencies: + '@rollup/plugin-commonjs': + specifier: ^25.0.7 + version: 25.0.7(rollup@4.11.0) + '@rollup/plugin-node-resolve': + specifier: ^15.2.3 + version: 15.2.3(rollup@4.11.0) + '@rollup/plugin-swc': + specifier: ^0.3.0 + version: 0.3.0(@swc/core@1.4.1)(rollup@4.11.0) + '@swc/core': + specifier: ^1.3.106 + version: 1.4.1 '@techor/extend': specifier: workspace:^ version: link:../extend @@ -298,17 +331,26 @@ importers: specifier: ^11.0.0 version: 11.1.0 esbuild: - specifier: ^0.18.11 - version: 0.18.20 + specifier: ^0.20.1 + version: 0.20.1 + escodegen: + specifier: ^2.1.0 + version: 2.1.0 execa: - specifier: ^7.1.1 + specifier: ^7.2.0 version: 7.2.0 explore-config: specifier: workspace:^ version: link:../explore-config + hrtime: + specifier: ^0.5.0 + version: 0.5.0 lodash.isequal: specifier: ^4.5.0 version: 4.5.0 + magic-string: + specifier: ^0.30.7 + version: 0.30.7 pkg-types: specifier: ^1.0.1 version: 1.0.3 @@ -318,9 +360,24 @@ importers: pretty-hrtime: specifier: ^1.0.3 version: 1.0.3 + rollup: + specifier: ^4.11.0 + version: 4.11.0 + rollup-plugin-swc-minify: + specifier: ^1.1.0 + version: 1.1.0(rollup@4.11.0) + rollup-plugin-ts: + specifier: ^3.4.5 + version: 3.4.5(@swc/core@1.4.1)(rollup@4.11.0)(typescript@5.3.3) + trim-newlines: + specifier: ^5.0.0 + version: 5.0.0 upath: specifier: ^2.0.1 version: 2.0.1 + wide-align: + specifier: ^1.1.5 + version: 1.1.5 devDependencies: dedent: specifier: ^0.7.0 @@ -836,180 +893,418 @@ packages: '@jridgewell/trace-mapping': 0.3.9 dev: false - /@esbuild/android-arm64@0.18.20: - resolution: {integrity: sha512-Nz4rJcchGDtENV0eMKUNa6L12zz2zBDXuhj/Vjh18zGqB44Bi7MBMSXjgunJgjRhCmKOjnPuZp4Mb6OKqtMHLQ==} + /@esbuild/aix-ppc64@0.19.12: + resolution: {integrity: sha512-bmoCYyWdEL3wDQIVbcyzRyeKLgk2WtWLTWz1ZIAZF/EGbNOwSA6ew3PftJ1PqMiOOGu0OyFMzG53L0zqIpPeNA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: true + optional: true + + /@esbuild/aix-ppc64@0.20.1: + resolution: {integrity: sha512-m55cpeupQ2DbuRGQMMZDzbv9J9PgVelPjlcmM5kxHnrBdBx6REaEd7LamYV7Dm8N7rCyR/XwU6rVP8ploKtIkA==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [aix] + requiresBuild: true + dev: false + optional: true + + /@esbuild/android-arm64@0.19.12: + resolution: {integrity: sha512-P0UVNGIienjZv3f5zq0DP3Nt2IE/3plFzuaS96vihvD0Hd6H/q4WXUGpCxD/E8YrSXfNyRPbpTq+T8ZQioSuPA==} engines: {node: '>=12'} cpu: [arm64] os: [android] requiresBuild: true + dev: true optional: true - /@esbuild/android-arm@0.18.20: - resolution: {integrity: sha512-fyi7TDI/ijKKNZTUJAQqiG5T7YjJXgnzkURqmGj13C6dCqckZBLdl4h7bkhHt/t0WP+zO9/zwroDvANaOqO5Sw==} + /@esbuild/android-arm64@0.20.1: + resolution: {integrity: sha512-hCnXNF0HM6AjowP+Zou0ZJMWWa1VkD77BXe959zERgGJBBxB+sV+J9f/rcjeg2c5bsukD/n17RKWXGFCO5dD5A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: false + optional: true + + /@esbuild/android-arm@0.19.12: + resolution: {integrity: sha512-qg/Lj1mu3CdQlDEEiWrlC4eaPZ1KztwGJ9B6J+/6G+/4ewxJg7gqj8eVYWvao1bXrqGiW2rsBZFSX3q2lcW05w==} engines: {node: '>=12'} cpu: [arm] os: [android] requiresBuild: true + dev: true optional: true - /@esbuild/android-x64@0.18.20: - resolution: {integrity: sha512-8GDdlePJA8D6zlZYJV/jnrRAi6rOiNaCC/JclcXpB+KIuvfBN4owLtgzY2bsxnx666XjJx2kDPUmnTtR8qKQUg==} + /@esbuild/android-arm@0.20.1: + resolution: {integrity: sha512-4j0+G27/2ZXGWR5okcJi7pQYhmkVgb4D7UKwxcqrjhvp5TKWx3cUjgB1CGj1mfdmJBQ9VnUGgUhign+FPF2Zgw==} + engines: {node: '>=12'} + cpu: [arm] + os: [android] + requiresBuild: true + dev: false + optional: true + + /@esbuild/android-x64@0.19.12: + resolution: {integrity: sha512-3k7ZoUW6Q6YqhdhIaq/WZ7HwBpnFBlW905Fa4s4qWJyiNOgT1dOqDiVAQFwBH7gBRZr17gLrlFCRzF6jFh7Kew==} engines: {node: '>=12'} cpu: [x64] os: [android] requiresBuild: true + dev: true + optional: true + + /@esbuild/android-x64@0.20.1: + resolution: {integrity: sha512-MSfZMBoAsnhpS+2yMFYIQUPs8Z19ajwfuaSZx+tSl09xrHZCjbeXXMsUF/0oq7ojxYEpsSo4c0SfjxOYXRbpaA==} + engines: {node: '>=12'} + cpu: [x64] + os: [android] + requiresBuild: true + dev: false optional: true - /@esbuild/darwin-arm64@0.18.20: - resolution: {integrity: sha512-bxRHW5kHU38zS2lPTPOyuyTm+S+eobPUnTNkdJEfAddYgEcll4xkT8DB9d2008DtTbl7uJag2HuE5NZAZgnNEA==} + /@esbuild/darwin-arm64@0.19.12: + resolution: {integrity: sha512-B6IeSgZgtEzGC42jsI+YYu9Z3HKRxp8ZT3cqhvliEHovq8HSX2YX8lNocDn79gCKJXOSaEot9MVYky7AKjCs8g==} engines: {node: '>=12'} cpu: [arm64] os: [darwin] requiresBuild: true + dev: true + optional: true + + /@esbuild/darwin-arm64@0.20.1: + resolution: {integrity: sha512-Ylk6rzgMD8klUklGPzS414UQLa5NPXZD5tf8JmQU8GQrj6BrFA/Ic9tb2zRe1kOZyCbGl+e8VMbDRazCEBqPvA==} + engines: {node: '>=12'} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: false + optional: true + + /@esbuild/darwin-x64@0.19.12: + resolution: {integrity: sha512-hKoVkKzFiToTgn+41qGhsUJXFlIjxI/jSYeZf3ugemDYZldIXIxhvwN6erJGlX4t5h417iFuheZ7l+YVn05N3A==} + engines: {node: '>=12'} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true optional: true - /@esbuild/darwin-x64@0.18.20: - resolution: {integrity: sha512-pc5gxlMDxzm513qPGbCbDukOdsGtKhfxD1zJKXjCCcU7ju50O7MeAZ8c4krSJcOIJGFR+qx21yMMVYwiQvyTyQ==} + /@esbuild/darwin-x64@0.20.1: + resolution: {integrity: sha512-pFIfj7U2w5sMp52wTY1XVOdoxw+GDwy9FsK3OFz4BpMAjvZVs0dT1VXs8aQm22nhwoIWUmIRaE+4xow8xfIDZA==} engines: {node: '>=12'} cpu: [x64] os: [darwin] requiresBuild: true + dev: false optional: true - /@esbuild/freebsd-arm64@0.18.20: - resolution: {integrity: sha512-yqDQHy4QHevpMAaxhhIwYPMv1NECwOvIpGCZkECn8w2WFHXjEwrBn3CeNIYsibZ/iZEUemj++M26W3cNR5h+Tw==} + /@esbuild/freebsd-arm64@0.19.12: + resolution: {integrity: sha512-4aRvFIXmwAcDBw9AueDQ2YnGmz5L6obe5kmPT8Vd+/+x/JMVKCgdcRwH6APrbpNXsPz+K653Qg8HB/oXvXVukA==} engines: {node: '>=12'} cpu: [arm64] os: [freebsd] requiresBuild: true + dev: true + optional: true + + /@esbuild/freebsd-arm64@0.20.1: + resolution: {integrity: sha512-UyW1WZvHDuM4xDz0jWun4qtQFauNdXjXOtIy7SYdf7pbxSWWVlqhnR/T2TpX6LX5NI62spt0a3ldIIEkPM6RHw==} + engines: {node: '>=12'} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: false + optional: true + + /@esbuild/freebsd-x64@0.19.12: + resolution: {integrity: sha512-EYoXZ4d8xtBoVN7CEwWY2IN4ho76xjYXqSXMNccFSx2lgqOG/1TBPW0yPx1bJZk94qu3tX0fycJeeQsKovA8gg==} + engines: {node: '>=12'} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true optional: true - /@esbuild/freebsd-x64@0.18.20: - resolution: {integrity: sha512-tgWRPPuQsd3RmBZwarGVHZQvtzfEBOreNuxEMKFcd5DaDn2PbBxfwLcj4+aenoh7ctXcbXmOQIn8HI6mCSw5MQ==} + /@esbuild/freebsd-x64@0.20.1: + resolution: {integrity: sha512-itPwCw5C+Jh/c624vcDd9kRCCZVpzpQn8dtwoYIt2TJF3S9xJLiRohnnNrKwREvcZYx0n8sCSbvGH349XkcQeg==} engines: {node: '>=12'} cpu: [x64] os: [freebsd] requiresBuild: true + dev: false optional: true - /@esbuild/linux-arm64@0.18.20: - resolution: {integrity: sha512-2YbscF+UL7SQAVIpnWvYwM+3LskyDmPhe31pE7/aoTMFKKzIc9lLbyGUpmmb8a8AixOL61sQ/mFh3jEjHYFvdA==} + /@esbuild/linux-arm64@0.19.12: + resolution: {integrity: sha512-EoTjyYyLuVPfdPLsGVVVC8a0p1BFFvtpQDB/YLEhaXyf/5bczaGeN15QkR+O4S5LeJ92Tqotve7i1jn35qwvdA==} engines: {node: '>=12'} cpu: [arm64] os: [linux] requiresBuild: true + dev: true optional: true - /@esbuild/linux-arm@0.18.20: - resolution: {integrity: sha512-/5bHkMWnq1EgKr1V+Ybz3s1hWXok7mDFUMQ4cG10AfW3wL02PSZi5kFpYKrptDsgb2WAJIvRcDm+qIvXf/apvg==} + /@esbuild/linux-arm64@0.20.1: + resolution: {integrity: sha512-cX8WdlF6Cnvw/DO9/X7XLH2J6CkBnz7Twjpk56cshk9sjYVcuh4sXQBy5bmTwzBjNVZze2yaV1vtcJS04LbN8w==} + engines: {node: '>=12'} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-arm@0.19.12: + resolution: {integrity: sha512-J5jPms//KhSNv+LO1S1TX1UWp1ucM6N6XuL6ITdKWElCu8wXP72l9MM0zDTzzeikVyqFE6U8YAV9/tFyj0ti+w==} engines: {node: '>=12'} cpu: [arm] os: [linux] requiresBuild: true + dev: true optional: true - /@esbuild/linux-ia32@0.18.20: - resolution: {integrity: sha512-P4etWwq6IsReT0E1KHU40bOnzMHoH73aXp96Fs8TIT6z9Hu8G6+0SHSw9i2isWrD2nbx2qo5yUqACgdfVGx7TA==} + /@esbuild/linux-arm@0.20.1: + resolution: {integrity: sha512-LojC28v3+IhIbfQ+Vu4Ut5n3wKcgTu6POKIHN9Wpt0HnfgUGlBuyDDQR4jWZUZFyYLiz4RBBBmfU6sNfn6RhLw==} + engines: {node: '>=12'} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-ia32@0.19.12: + resolution: {integrity: sha512-Thsa42rrP1+UIGaWz47uydHSBOgTUnwBwNq59khgIwktK6x60Hivfbux9iNR0eHCHzOLjLMLfUMLCypBkZXMHA==} engines: {node: '>=12'} cpu: [ia32] os: [linux] requiresBuild: true + dev: true optional: true - /@esbuild/linux-loong64@0.18.20: - resolution: {integrity: sha512-nXW8nqBTrOpDLPgPY9uV+/1DjxoQ7DoB2N8eocyq8I9XuqJ7BiAMDMf9n1xZM9TgW0J8zrquIb/A7s3BJv7rjg==} + /@esbuild/linux-ia32@0.20.1: + resolution: {integrity: sha512-4H/sQCy1mnnGkUt/xszaLlYJVTz3W9ep52xEefGtd6yXDQbz/5fZE5dFLUgsPdbUOQANcVUa5iO6g3nyy5BJiw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-loong64@0.19.12: + resolution: {integrity: sha512-LiXdXA0s3IqRRjm6rV6XaWATScKAXjI4R4LoDlvO7+yQqFdlr1Bax62sRwkVvRIrwXxvtYEHHI4dm50jAXkuAA==} engines: {node: '>=12'} cpu: [loong64] os: [linux] requiresBuild: true + dev: true optional: true - /@esbuild/linux-mips64el@0.18.20: - resolution: {integrity: sha512-d5NeaXZcHp8PzYy5VnXV3VSd2D328Zb+9dEq5HE6bw6+N86JVPExrA6O68OPwobntbNJ0pzCpUFZTo3w0GyetQ==} + /@esbuild/linux-loong64@0.20.1: + resolution: {integrity: sha512-c0jgtB+sRHCciVXlyjDcWb2FUuzlGVRwGXgI+3WqKOIuoo8AmZAddzeOHeYLtD+dmtHw3B4Xo9wAUdjlfW5yYA==} + engines: {node: '>=12'} + cpu: [loong64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-mips64el@0.19.12: + resolution: {integrity: sha512-fEnAuj5VGTanfJ07ff0gOA6IPsvrVHLVb6Lyd1g2/ed67oU1eFzL0r9WL7ZzscD+/N6i3dWumGE1Un4f7Amf+w==} + engines: {node: '>=12'} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-mips64el@0.20.1: + resolution: {integrity: sha512-TgFyCfIxSujyuqdZKDZ3yTwWiGv+KnlOeXXitCQ+trDODJ+ZtGOzLkSWngynP0HZnTsDyBbPy7GWVXWaEl6lhA==} engines: {node: '>=12'} cpu: [mips64el] os: [linux] requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-ppc64@0.19.12: + resolution: {integrity: sha512-nYJA2/QPimDQOh1rKWedNOe3Gfc8PabU7HT3iXWtNUbRzXS9+vgB0Fjaqr//XNbd82mCxHzik2qotuI89cfixg==} + engines: {node: '>=12'} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true optional: true - /@esbuild/linux-ppc64@0.18.20: - resolution: {integrity: sha512-WHPyeScRNcmANnLQkq6AfyXRFr5D6N2sKgkFo2FqguP44Nw2eyDlbTdZwd9GYk98DZG9QItIiTlFLHJHjxP3FA==} + /@esbuild/linux-ppc64@0.20.1: + resolution: {integrity: sha512-b+yuD1IUeL+Y93PmFZDZFIElwbmFfIKLKlYI8M6tRyzE6u7oEP7onGk0vZRh8wfVGC2dZoy0EqX1V8qok4qHaw==} engines: {node: '>=12'} cpu: [ppc64] os: [linux] requiresBuild: true + dev: false optional: true - /@esbuild/linux-riscv64@0.18.20: - resolution: {integrity: sha512-WSxo6h5ecI5XH34KC7w5veNnKkju3zBRLEQNY7mv5mtBmrP/MjNBCAlsM2u5hDBlS3NGcTQpoBvRzqBcRtpq1A==} + /@esbuild/linux-riscv64@0.19.12: + resolution: {integrity: sha512-2MueBrlPQCw5dVJJpQdUYgeqIzDQgw3QtiAHUC4RBz9FXPrskyyU3VI1hw7C0BSKB9OduwSJ79FTCqtGMWqJHg==} engines: {node: '>=12'} cpu: [riscv64] os: [linux] requiresBuild: true + dev: true + optional: true + + /@esbuild/linux-riscv64@0.20.1: + resolution: {integrity: sha512-wpDlpE0oRKZwX+GfomcALcouqjjV8MIX8DyTrxfyCfXxoKQSDm45CZr9fanJ4F6ckD4yDEPT98SrjvLwIqUCgg==} + engines: {node: '>=12'} + cpu: [riscv64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/linux-s390x@0.19.12: + resolution: {integrity: sha512-+Pil1Nv3Umes4m3AZKqA2anfhJiVmNCYkPchwFJNEJN5QxmTs1uzyy4TvmDrCRNT2ApwSari7ZIgrPeUx4UZDg==} + engines: {node: '>=12'} + cpu: [s390x] + os: [linux] + requiresBuild: true + dev: true optional: true - /@esbuild/linux-s390x@0.18.20: - resolution: {integrity: sha512-+8231GMs3mAEth6Ja1iK0a1sQ3ohfcpzpRLH8uuc5/KVDFneH6jtAJLFGafpzpMRO6DzJ6AvXKze9LfFMrIHVQ==} + /@esbuild/linux-s390x@0.20.1: + resolution: {integrity: sha512-5BepC2Au80EohQ2dBpyTquqGCES7++p7G+7lXe1bAIvMdXm4YYcEfZtQrP4gaoZ96Wv1Ute61CEHFU7h4FMueQ==} engines: {node: '>=12'} cpu: [s390x] os: [linux] requiresBuild: true + dev: false optional: true - /@esbuild/linux-x64@0.18.20: - resolution: {integrity: sha512-UYqiqemphJcNsFEskc73jQ7B9jgwjWrSayxawS6UVFZGWrAAtkzjxSqnoclCXxWtfwLdzU+vTpcNYhpn43uP1w==} + /@esbuild/linux-x64@0.19.12: + resolution: {integrity: sha512-B71g1QpxfwBvNrfyJdVDexenDIt1CiDN1TIXLbhOw0KhJzE78KIFGX6OJ9MrtC0oOqMWf+0xop4qEU8JrJTwCg==} engines: {node: '>=12'} cpu: [x64] os: [linux] requiresBuild: true + dev: true optional: true - /@esbuild/netbsd-x64@0.18.20: - resolution: {integrity: sha512-iO1c++VP6xUBUmltHZoMtCUdPlnPGdBom6IrO4gyKPFFVBKioIImVooR5I83nTew5UOYrk3gIJhbZh8X44y06A==} + /@esbuild/linux-x64@0.20.1: + resolution: {integrity: sha512-5gRPk7pKuaIB+tmH+yKd2aQTRpqlf1E4f/mC+tawIm/CGJemZcHZpp2ic8oD83nKgUPMEd0fNanrnFljiruuyA==} + engines: {node: '>=12'} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: false + optional: true + + /@esbuild/netbsd-x64@0.19.12: + resolution: {integrity: sha512-3ltjQ7n1owJgFbuC61Oj++XhtzmymoCihNFgT84UAmJnxJfm4sYCiSLTXZtE00VWYpPMYc+ZQmB6xbSdVh0JWA==} engines: {node: '>=12'} cpu: [x64] os: [netbsd] requiresBuild: true + dev: true optional: true - /@esbuild/openbsd-x64@0.18.20: - resolution: {integrity: sha512-e5e4YSsuQfX4cxcygw/UCPIEP6wbIL+se3sxPdCiMbFLBWu0eiZOJ7WoD+ptCLrmjZBK1Wk7I6D/I3NglUGOxg==} + /@esbuild/netbsd-x64@0.20.1: + resolution: {integrity: sha512-4fL68JdrLV2nVW2AaWZBv3XEm3Ae3NZn/7qy2KGAt3dexAgSVT+Hc97JKSZnqezgMlv9x6KV0ZkZY7UO5cNLCg==} + engines: {node: '>=12'} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: false + optional: true + + /@esbuild/openbsd-x64@0.19.12: + resolution: {integrity: sha512-RbrfTB9SWsr0kWmb9srfF+L933uMDdu9BIzdA7os2t0TXhCRjrQyCeOt6wVxr79CKD4c+p+YhCj31HBkYcXebw==} engines: {node: '>=12'} cpu: [x64] os: [openbsd] requiresBuild: true + dev: true optional: true - /@esbuild/sunos-x64@0.18.20: - resolution: {integrity: sha512-kDbFRFp0YpTQVVrqUd5FTYmWo45zGaXe0X8E1G/LKFC0v8x0vWrhOWSLITcCn63lmZIxfOMXtCfti/RxN/0wnQ==} + /@esbuild/openbsd-x64@0.20.1: + resolution: {integrity: sha512-GhRuXlvRE+twf2ES+8REbeCb/zeikNqwD3+6S5y5/x+DYbAQUNl0HNBs4RQJqrechS4v4MruEr8ZtAin/hK5iw==} + engines: {node: '>=12'} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: false + optional: true + + /@esbuild/sunos-x64@0.19.12: + resolution: {integrity: sha512-HKjJwRrW8uWtCQnQOz9qcU3mUZhTUQvi56Q8DPTLLB+DawoiQdjsYq+j+D3s9I8VFtDr+F9CjgXKKC4ss89IeA==} + engines: {node: '>=12'} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + + /@esbuild/sunos-x64@0.20.1: + resolution: {integrity: sha512-ZnWEyCM0G1Ex6JtsygvC3KUUrlDXqOihw8RicRuQAzw+c4f1D66YlPNNV3rkjVW90zXVsHwZYWbJh3v+oQFM9Q==} engines: {node: '>=12'} cpu: [x64] os: [sunos] requiresBuild: true + dev: false + optional: true + + /@esbuild/win32-arm64@0.19.12: + resolution: {integrity: sha512-URgtR1dJnmGvX864pn1B2YUYNzjmXkuJOIqG2HdU62MVS4EHpU2946OZoTMnRUHklGtJdJZ33QfzdjGACXhn1A==} + engines: {node: '>=12'} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true optional: true - /@esbuild/win32-arm64@0.18.20: - resolution: {integrity: sha512-ddYFR6ItYgoaq4v4JmQQaAI5s7npztfV4Ag6NrhiaW0RrnOXqBkgwZLofVTlq1daVTQNhtI5oieTvkRPfZrePg==} + /@esbuild/win32-arm64@0.20.1: + resolution: {integrity: sha512-QZ6gXue0vVQY2Oon9WyLFCdSuYbXSoxaZrPuJ4c20j6ICedfsDilNPYfHLlMH7vGfU5DQR0czHLmJvH4Nzis/A==} engines: {node: '>=12'} cpu: [arm64] os: [win32] requiresBuild: true + dev: false optional: true - /@esbuild/win32-ia32@0.18.20: - resolution: {integrity: sha512-Wv7QBi3ID/rROT08SABTS7eV4hX26sVduqDOTe1MvGMjNd3EjOz4b7zeexIR62GTIEKrfJXKL9LFxTYgkyeu7g==} + /@esbuild/win32-ia32@0.19.12: + resolution: {integrity: sha512-+ZOE6pUkMOJfmxmBZElNOx72NKpIa/HFOMGzu8fqzQJ5kgf6aTGrcJaFsNiVMH4JKpMipyK+7k0n2UXN7a8YKQ==} engines: {node: '>=12'} cpu: [ia32] os: [win32] requiresBuild: true + dev: true + optional: true + + /@esbuild/win32-ia32@0.20.1: + resolution: {integrity: sha512-HzcJa1NcSWTAU0MJIxOho8JftNp9YALui3o+Ny7hCh0v5f90nprly1U3Sj1Ldj/CvKKdvvFsCRvDkpsEMp4DNw==} + engines: {node: '>=12'} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: false + optional: true + + /@esbuild/win32-x64@0.19.12: + resolution: {integrity: sha512-T1QyPSDCyMXaO3pzBkF96E8xMkiRYbUEZADd29SyPGabqxMViNoii+NcK7eWJAEoU6RZyEm5lVSIjTmcdoB9HA==} + engines: {node: '>=12'} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true optional: true - /@esbuild/win32-x64@0.18.20: - resolution: {integrity: sha512-kTdfRcSiDfQca/y9QIkng02avJ+NCaQvrMejlsB3RRv5sE9rRoeBPISaZpKxHELzRxZyLvNts1P27W3wV+8geQ==} + /@esbuild/win32-x64@0.20.1: + resolution: {integrity: sha512-0MBh53o6XtI6ctDnRMeQ+xoCN8kD2qI1rY1KgF/xdWQwoFeKou7puvDfV8/Wv4Ctx2rRpET/gGdz3YlNtNACSA==} engines: {node: '>=12'} cpu: [x64] os: [win32] requiresBuild: true + dev: false optional: true /@eslint-community/eslint-utils@4.4.0(eslint@8.56.0): @@ -1087,6 +1382,7 @@ packages: strip-ansi-cjs: /strip-ansi@6.0.1 wrap-ansi: 8.1.0 wrap-ansi-cjs: /wrap-ansi@7.0.0 + dev: false /@istanbuljs/load-nyc-config@1.1.0: resolution: {integrity: sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==} @@ -1361,23 +1657,28 @@ packages: '@jridgewell/set-array': 1.1.2 '@jridgewell/sourcemap-codec': 1.4.15 '@jridgewell/trace-mapping': 0.3.22 + dev: false /@jridgewell/resolve-uri@3.1.2: resolution: {integrity: sha512-bRISgCIjP20/tbWSPWMEi54QVPRZExkuD9lJL+UIxUKtwVJA8wW1Trb1jMs1RFXo1CBTNZ/5hpC9QvmKWdopKw==} engines: {node: '>=6.0.0'} + dev: false /@jridgewell/set-array@1.1.2: resolution: {integrity: sha512-xnkseuNADM0gt2bs+BvhO0p78Mk762YnZdsuzFV018NoG1Sj1SCQvpSqa7XUaTam5vAGasABV9qXASMKnFMwMw==} engines: {node: '>=6.0.0'} + dev: false /@jridgewell/sourcemap-codec@1.4.15: resolution: {integrity: sha512-eF2rxCRulEKXHTRiDrDy6erMYWqNw4LPdQ8UQA4huuxaQsVeRPFl2oM8oDGxMFhJUWZf9McpLtJasDDZb/Bpeg==} + dev: false /@jridgewell/trace-mapping@0.3.22: resolution: {integrity: sha512-Wf963MzWtA2sjrNt+g18IAln9lKnlRp+K2eH4jjIoF1wYeq3aMREpG09xhlhdzS0EjwU7qmUJYangWa+151vZw==} dependencies: '@jridgewell/resolve-uri': 3.1.2 '@jridgewell/sourcemap-codec': 1.4.15 + dev: false /@jridgewell/trace-mapping@0.3.9: resolution: {integrity: sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ==} @@ -1386,6 +1687,10 @@ packages: '@jridgewell/sourcemap-codec': 1.4.15 dev: false + /@mdn/browser-compat-data@5.5.10: + resolution: {integrity: sha512-s2GGND9oLhEuksOFtICYOBZdMWPANBXTMqAXh89q6g1Mi3+OuWEmp9WFzw2v/nmS175vqeewpC1kDJA7taaxyA==} + dev: false + /@nodelib/fs.scandir@2.1.5: resolution: {integrity: sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g==} engines: {node: '>= 8'} @@ -1494,6 +1799,7 @@ packages: resolution: {integrity: sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==} engines: {node: '>=14'} requiresBuild: true + dev: false optional: true /@pnpm/config.env-replace@1.1.0: @@ -1530,6 +1836,183 @@ packages: - supports-color dev: true + /@rollup/plugin-commonjs@25.0.7(rollup@4.11.0): + resolution: {integrity: sha512-nEvcR+LRjEjsaSsc4x3XZfCCvZIaSMenZu/OiwOKGN2UhQpAYI7ru7czFvyWbErlpoGjnSX3D5Ch5FcMA3kRWQ==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.68.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.11.0) + commondir: 1.0.1 + estree-walker: 2.0.2 + glob: 8.1.0 + is-reference: 1.2.1 + magic-string: 0.30.7 + rollup: 4.11.0 + dev: false + + /@rollup/plugin-node-resolve@15.2.3(rollup@4.11.0): + resolution: {integrity: sha512-j/lym8nf5E21LwBT4Df1VD6hRO2L2iwUeUmP7litikRsVp1H6NWx20NEp0Y7su+7XGc476GnXXc4kFeZNGmaSQ==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.78.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.11.0) + '@types/resolve': 1.20.2 + deepmerge: 4.3.1 + is-builtin-module: 3.2.1 + is-module: 1.0.0 + resolve: 1.22.8 + rollup: 4.11.0 + dev: false + + /@rollup/plugin-swc@0.3.0(@swc/core@1.4.1)(rollup@4.11.0): + resolution: {integrity: sha512-PC1c1FFAwGoasYUesGCMtJ3DggJl1l9ydvufze5esUwdIFjg2BmKeM6j0JA6WHTJjx6C4x9RjF4LNHEIknKPgA==} + engines: {node: '>=14.0.0'} + peerDependencies: + '@swc/core': ^1.3.0 + rollup: ^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.11.0) + '@swc/core': 1.4.1 + rollup: 4.11.0 + smob: 1.4.1 + dev: false + + /@rollup/plugin-typescript@11.1.6(rollup@4.11.0)(typescript@5.3.3): + resolution: {integrity: sha512-R92yOmIACgYdJ7dJ97p4K69I8gg6IEHt8M7dUBxN3W6nrO8uUxX5ixl0yU/N3aZTi8WhPuICvOHXQvF6FaykAA==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^2.14.0||^3.0.0||^4.0.0 + tslib: '*' + typescript: '>=3.7.0' + peerDependenciesMeta: + rollup: + optional: true + tslib: + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.11.0) + resolve: 1.22.8 + rollup: 4.11.0 + typescript: 5.3.3 + dev: false + + /@rollup/pluginutils@5.1.0(rollup@4.11.0): + resolution: {integrity: sha512-XTIWOPPcpvyKI6L1NHo0lFlCyznUEyPmPY1mc3KpPVDYulHSTvyeLNVW00QTLIAFNhR3kYnJTQHeGqU4M3n09g==} + engines: {node: '>=14.0.0'} + peerDependencies: + rollup: ^1.20.0||^2.0.0||^3.0.0||^4.0.0 + peerDependenciesMeta: + rollup: + optional: true + dependencies: + '@types/estree': 1.0.5 + estree-walker: 2.0.2 + picomatch: 2.3.1 + rollup: 4.11.0 + dev: false + + /@rollup/rollup-android-arm-eabi@4.11.0: + resolution: {integrity: sha512-BV+u2QSfK3i1o6FucqJh5IK9cjAU6icjFFhvknzFgu472jzl0bBojfDAkJLBEsHFMo+YZg6rthBvBBt8z12IBQ==} + cpu: [arm] + os: [android] + requiresBuild: true + optional: true + + /@rollup/rollup-android-arm64@4.11.0: + resolution: {integrity: sha512-0ij3iw7sT5jbcdXofWO2NqDNjSVVsf6itcAkV2I6Xsq4+6wjW1A8rViVB67TfBEan7PV2kbLzT8rhOVWLI2YXw==} + cpu: [arm64] + os: [android] + requiresBuild: true + optional: true + + /@rollup/rollup-darwin-arm64@4.11.0: + resolution: {integrity: sha512-yPLs6RbbBMupArf6qv1UDk6dzZvlH66z6NLYEwqTU0VHtss1wkI4UYeeMS7TVj5QRVvaNAWYKP0TD/MOeZ76Zg==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + optional: true + + /@rollup/rollup-darwin-x64@4.11.0: + resolution: {integrity: sha512-OvqIgwaGAwnASzXaZEeoJY3RltOFg+WUbdkdfoluh2iqatd090UeOG3A/h0wNZmE93dDew9tAtXgm3/+U/B6bw==} + cpu: [x64] + os: [darwin] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm-gnueabihf@4.11.0: + resolution: {integrity: sha512-X17s4hZK3QbRmdAuLd2EE+qwwxL8JxyVupEqAkxKPa/IgX49ZO+vf0ka69gIKsaYeo6c1CuwY3k8trfDtZ9dFg==} + cpu: [arm] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm64-gnu@4.11.0: + resolution: {integrity: sha512-673Lu9EJwxVB9NfYeA4AdNu0FOHz7g9t6N1DmT7bZPn1u6bTF+oZjj+fuxUcrfxWXE0r2jxl5QYMa9cUOj9NFg==} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-arm64-musl@4.11.0: + resolution: {integrity: sha512-yFW2msTAQNpPJaMmh2NpRalr1KXI7ZUjlN6dY/FhWlOclMrZezm5GIhy3cP4Ts2rIAC+IPLAjNibjp1BsxCVGg==} + cpu: [arm64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-riscv64-gnu@4.11.0: + resolution: {integrity: sha512-kKT9XIuhbvYgiA3cPAGntvrBgzhWkGpBMzuk1V12Xuoqg7CI41chye4HU0vLJnGf9MiZzfNh4I7StPeOzOWJfA==} + cpu: [riscv64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-x64-gnu@4.11.0: + resolution: {integrity: sha512-6q4ESWlyTO+erp1PSCmASac+ixaDv11dBk1fqyIuvIUc/CmRAX2Zk+2qK1FGo5q7kyDcjHCFVwgGFCGIZGVwCA==} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-linux-x64-musl@4.11.0: + resolution: {integrity: sha512-vIAQUmXeMLmaDN78HSE4Kh6xqof2e3TJUKr+LPqXWU4NYNON0MDN9h2+t4KHrPAQNmU3w1GxBQ/n01PaWFwa5w==} + cpu: [x64] + os: [linux] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-arm64-msvc@4.11.0: + resolution: {integrity: sha512-LVXo9dDTGPr0nezMdqa1hK4JeoMZ02nstUxGYY/sMIDtTYlli1ZxTXBYAz3vzuuvKO4X6NBETciIh7N9+abT1g==} + cpu: [arm64] + os: [win32] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-ia32-msvc@4.11.0: + resolution: {integrity: sha512-xZVt6K70Gr3I7nUhug2dN6VRR1ibot3rXqXS3wo+8JP64t7djc3lBFyqO4GiVrhNaAIhUCJtwQ/20dr0h0thmQ==} + cpu: [ia32] + os: [win32] + requiresBuild: true + optional: true + + /@rollup/rollup-win32-x64-msvc@4.11.0: + resolution: {integrity: sha512-f3I7h9oTg79UitEco9/2bzwdciYkWr8pITs3meSDSlr1TdvQ7IxkQaaYN2YqZXX5uZhiYL+VuYDmHwNzhx+HOg==} + cpu: [x64] + os: [win32] + requiresBuild: true + optional: true + /@semantic-release/commit-analyzer@11.0.0(semantic-release@23.0.2): resolution: {integrity: sha512-uEXyf4Z0AWJuxI9TbSQP5kkIYqus1/E1NcmE7pIv6d6/m/5EJcNWAGR4FOo34vrV26FhEaRVkxFfYzp/M7BKIg==} engines: {node: ^18.17 || >=20.6.1} @@ -1875,6 +2358,9 @@ packages: '@babel/types': 7.23.9 dev: false + /@types/estree@1.0.5: + resolution: {integrity: sha512-/kYRxGDLWzHOB7q+wtSUQlFrtcdUccpfy+X+9iMBpHK8QLLhx2wIPYuS5DYtR9Wa/YlZAbIovy7qVdB1Aq6Lyw==} + /@types/fs-extra@9.0.13: resolution: {integrity: sha512-nEnwB++1u5lVDM2UI4c1+5R+FYaKfaAzS4OococimjVm3nQw3TuzH5UNsocrcTBbhnerblyHj4A49qXbIiZdpA==} dependencies: @@ -1922,6 +2408,10 @@ packages: resolution: {integrity: sha512-hov8bUuiLiyFPGyFPE1lwWhmzYbirOXQNNo40+y3zow8aFVTeyn3VWL0VFFfdNddA8S4Vf0Tc062rzyNr7Paag==} dev: false + /@types/node@17.0.45: + resolution: {integrity: sha512-w+tIMs3rq2afQdsPJlODhoUEKzFP1ayaoyl1CcnwtIlsVe7K7bA1NGm4s3PraqTLlXnbIN84zuBlxBWo1u9BLw==} + dev: false + /@types/node@20.11.17: resolution: {integrity: sha512-QmgQZGWu1Yw9TDyAP9ZzpFJKynYNeOvwMJmaxABfieQoVoiVOS6MN1WSpqpRcbeA5+RW82kraAVxCCJg+780Qw==} dependencies: @@ -1930,6 +2420,14 @@ packages: /@types/normalize-package-data@2.4.4: resolution: {integrity: sha512-37i+OaWTh9qeK4LSHPsyRC7NahnGotNuZvjLSgcPzblpHB3rrCJxAOgI5gCdKm7coonsaX1Of0ILiTcnZjbfxA==} + /@types/object-path@0.11.4: + resolution: {integrity: sha512-4tgJ1Z3elF/tOMpA8JLVuR9spt9Ynsf7+JjqsQ2IqtiPJtcLoHoXcT6qU4E10cPFqyXX5HDm9QwIzZhBSkLxsw==} + dev: false + + /@types/resolve@1.20.2: + resolution: {integrity: sha512-60BCwRFOZCQhDncwQdxxeOEEkbc5dIMccYLwbxsS4TUNeVECQ/pBJ0j09mrHOl/JJvpRPGwO9SvE4nR2Nb/a4Q==} + dev: false + /@types/semver@7.5.7: resolution: {integrity: sha512-/wdoPq1QqkSj9/QOeKkFquEuPzQbHTWAMPH/PaUMB+JuR31lXhlWXRZ52IpfDYVlDOUBvX09uBrPwxGT1hjNBg==} dev: false @@ -1940,6 +2438,10 @@ packages: /@types/tough-cookie@4.0.5: resolution: {integrity: sha512-/Ad8+nIOV7Rl++6f1BdKxFSMgmoqEoYbHRpPcx3JEfv8VRsQe9Z4mCXeJBzxs7mbHY/XOZZuXlRNfhpVPbs6ZA==} + /@types/ua-parser-js@0.7.39: + resolution: {integrity: sha512-P/oDfpofrdtF5xw433SPALpdSchtJmY7nsJItf8h3KXqOslkbySh8zq4dSWXH2oTjRvJ5PczVEoCZPow6GicLg==} + dev: false + /@types/yargs-parser@21.0.3: resolution: {integrity: sha512-I4q9QU9MQv4oEOz4tAHJtNz1cwuLxn2F3xcc2iV5WdqLPpUnj30aUuxt1mAxYTG+oe8CZMV/+6rU4S4gRDzqtQ==} @@ -2097,6 +2599,11 @@ packages: /@ungap/structured-clone@1.2.0: resolution: {integrity: sha512-zuVdFrMJiuCDQUMCzQaD6KL28MjnqqN8XnAqiEq9PNm/hCPTSGfrXCOfwj1ow4LFb/tNymJPwsNbVePc1xFqrQ==} + /@wessberg/stringutil@1.0.19: + resolution: {integrity: sha512-9AZHVXWlpN8Cn9k5BC/O0Dzb9E9xfEMXzYrNunwvkUTvuK7xgQPVRZpLo+jWCOZ5r8oBa8NIrHuPEu1hzbb6bg==} + engines: {node: '>=8.0.0'} + dev: false + /JSONStream@1.3.5: resolution: {integrity: sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==} hasBin: true @@ -2182,6 +2689,11 @@ packages: uri-js: 4.4.1 dev: false + /ansi-colors@4.1.3: + resolution: {integrity: sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==} + engines: {node: '>=6'} + dev: false + /ansi-escapes@4.3.2: resolution: {integrity: sha512-gKXj5ALrKWQLsYG9jlTRmR/xKluxHV+Z9QEwNIgCfM1/uwPMCuzVVnh5mwTd+OuBZcwSIMbqssNWRm1lE51QaQ==} engines: {node: '>=8'} @@ -2222,6 +2734,7 @@ packages: /ansi-styles@6.2.1: resolution: {integrity: sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==} engines: {node: '>=12'} + dev: false /any-promise@1.3.0: resolution: {integrity: sha512-7UvmKalWRt1wgjL1RrGxoSJW/0QZFIegpeGvZG9kjp8vrRu55XTHbwnqq2GpXm9uLbcuhxm3IqX9OB4MZR1b2A==} @@ -2396,6 +2909,7 @@ packages: resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} dependencies: balanced-match: 1.0.2 + dev: false /braces@3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} @@ -2403,6 +2917,22 @@ packages: dependencies: fill-range: 7.0.1 + /browserslist-generator@2.1.0: + resolution: {integrity: sha512-ZFz4mAOgqm0cbwKaZsfJbYDbTXGoPANlte7qRsRJOfjB9KmmISQrXJxAVrnXG8C8v/QHNzXyeJt0Cfcks6zZvQ==} + engines: {node: '>=16.15.1', npm: '>=7.0.0', pnpm: '>=3.2.0', yarn: '>=1.13'} + dependencies: + '@mdn/browser-compat-data': 5.5.10 + '@types/object-path': 0.11.4 + '@types/semver': 7.5.7 + '@types/ua-parser-js': 0.7.39 + browserslist: 4.23.0 + caniuse-lite: 1.0.30001587 + isbot: 3.8.0 + object-path: 0.11.8 + semver: 7.6.0 + ua-parser-js: 1.0.37 + dev: false + /browserslist@4.23.0: resolution: {integrity: sha512-QW8HiM1shhT2GuzkvklfjcKDiWFXHOeFCIA/huJPwHsslwcydgk7X+z2zXpEijP98UCY7HbubZt5J2Zgvf0CaQ==} engines: {node: ^6 || ^7 || ^8 || ^9 || ^10 || ^11 || ^12 || >=13.7} @@ -2433,6 +2963,7 @@ packages: /buffer-from@1.1.2: resolution: {integrity: sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==} + dev: false /buffer@5.7.1: resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} @@ -2441,6 +2972,11 @@ packages: ieee754: 1.2.1 dev: true + /builtin-modules@3.3.0: + resolution: {integrity: sha512-zhaCDicdLuWN5UbN5IMnFqNMhNfo919sH85y2/ea+5Yg9TsTkeZxpL+JLbp6cgYFS4sRLp3YV4S6yDuqVWHYOw==} + engines: {node: '>=6'} + dev: false + /callsites@3.1.0: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} @@ -2616,18 +3152,33 @@ packages: /commander@4.1.1: resolution: {integrity: sha512-NOKm8xhkzAjzFx8B2v5OAHT+u5pRQc2UCa2Vq9jYL/31o2wi9mxBA7LIFs3sV5VSC49z6pEhfbMULvShKj26WA==} engines: {node: '>= 6'} + dev: false /commander@5.1.0: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} engines: {node: '>= 6'} dev: true + /commondir@1.0.1: + resolution: {integrity: sha512-W9pAhw0ja1Edb5GVdIF1mjZw/ASI0AlShXM83UUGe2DVr5TdAPEA1OA8m/g8zWp9x6On7gqufY+FatDbC3MDQg==} + dev: false + /compare-func@2.0.0: resolution: {integrity: sha512-zHig5N+tPWARooBnb0Zx1MFcdfpyJrfTJ3Y5L+IFvUm8rM74hHz66z0gw0x4tijh5CorKkKUCnW82R2vmpeCRA==} dependencies: array-ify: 1.0.0 dot-prop: 5.3.0 + /compatfactory@3.0.0(typescript@5.3.3): + resolution: {integrity: sha512-WD5kF7koPwVoyKL8p0LlrmIZtilrD46sQStyzzxzTFinMKN2Dxk1hN+sddLSQU1mGIZvQfU8c+ONSghvvM40jg==} + engines: {node: '>=14.9.0'} + peerDependencies: + typescript: '>=3.x || >= 4.x || >= 5.x' + dependencies: + helpertypes: 0.0.19 + typescript: 5.3.3 + dev: false + /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -2722,21 +3273,6 @@ packages: typescript: 5.3.3 dev: false - /cosmiconfig@9.0.0: - resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} - engines: {node: '>=14'} - peerDependencies: - typescript: '>=4.9.5' - peerDependenciesMeta: - typescript: - optional: true - dependencies: - env-paths: 2.2.1 - import-fresh: 3.3.0 - js-yaml: 4.1.0 - parse-json: 5.2.0 - dev: true - /cosmiconfig@9.0.0(typescript@5.3.3): resolution: {integrity: sha512-itvL5h8RETACmOTFc4UfIyB2RfEHi71Ax6E/PivVxq9NseKbOWpeyHEOIbmAw1rs8Ak0VursQNww7lf7YtUwzg==} engines: {node: '>=14'} @@ -2799,6 +3335,13 @@ packages: shebang-command: 2.0.0 which: 2.0.2 + /crosspath@2.0.0: + resolution: {integrity: sha512-ju88BYCQ2uvjO2bR+SsgLSTwTSctU+6Vp2ePbKPgSCZyy4MWZxYsT738DlKVRE5utUjobjPRm1MkTYKJxCmpTA==} + engines: {node: '>=14.9.0'} + dependencies: + '@types/node': 17.0.45 + dev: false + /crypto-random-string@4.0.0: resolution: {integrity: sha512-x8dy3RnvYdlUcPOjkEHqozhiwzKNSq7GcPuXFbnyMOCHxX8V3OgIg/pYuabl2sbUPfIJaeAQB7PMOK8DFIdoRA==} engines: {node: '>=12'} @@ -2971,6 +3514,7 @@ packages: /eastasianwidth@0.2.0: resolution: {integrity: sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==} + dev: false /electron-to-chromium@1.4.670: resolution: {integrity: sha512-hcijYOWjOtjKrKPtNA6tuLlA/bTLO3heFG8pQA6mLpq7dRydSWicXova5lyxDzp1iVJaYhK7J2OQlGE52KYn7A==} @@ -2986,6 +3530,7 @@ packages: /emoji-regex@9.2.2: resolution: {integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==} + dev: false /emojilib@2.4.0: resolution: {integrity: sha512-5U0rVMU5Y2n2+ykNLQqMoqklN9ICBT/KsvC1Gz6vqHbz2AXXGkG+Pm5rMWk/8Vjrr/mY9985Hi8DYzn1F09Nyw==} @@ -3016,34 +3561,67 @@ packages: dependencies: is-arrayish: 0.2.1 - /esbuild@0.18.20: - resolution: {integrity: sha512-ceqxoedUrcayh7Y7ZX6NdbbDzGROiyVBgC4PriJThBKSVPWnnFHZAkfI1lJT8QFkOwH4qOS2SJkS4wvpGl8BpA==} + /esbuild@0.19.12: + resolution: {integrity: sha512-aARqgq8roFBj054KvQr5f1sFu0D65G+miZRCuJyJ0G13Zwx7vRar5Zhn2tkQNzIXcBrNVsv/8stehpj+GAjgbg==} engines: {node: '>=12'} hasBin: true requiresBuild: true optionalDependencies: - '@esbuild/android-arm': 0.18.20 - '@esbuild/android-arm64': 0.18.20 - '@esbuild/android-x64': 0.18.20 - '@esbuild/darwin-arm64': 0.18.20 - '@esbuild/darwin-x64': 0.18.20 - '@esbuild/freebsd-arm64': 0.18.20 - '@esbuild/freebsd-x64': 0.18.20 - '@esbuild/linux-arm': 0.18.20 - '@esbuild/linux-arm64': 0.18.20 - '@esbuild/linux-ia32': 0.18.20 - '@esbuild/linux-loong64': 0.18.20 - '@esbuild/linux-mips64el': 0.18.20 - '@esbuild/linux-ppc64': 0.18.20 - '@esbuild/linux-riscv64': 0.18.20 - '@esbuild/linux-s390x': 0.18.20 - '@esbuild/linux-x64': 0.18.20 - '@esbuild/netbsd-x64': 0.18.20 - '@esbuild/openbsd-x64': 0.18.20 - '@esbuild/sunos-x64': 0.18.20 - '@esbuild/win32-arm64': 0.18.20 - '@esbuild/win32-ia32': 0.18.20 - '@esbuild/win32-x64': 0.18.20 + '@esbuild/aix-ppc64': 0.19.12 + '@esbuild/android-arm': 0.19.12 + '@esbuild/android-arm64': 0.19.12 + '@esbuild/android-x64': 0.19.12 + '@esbuild/darwin-arm64': 0.19.12 + '@esbuild/darwin-x64': 0.19.12 + '@esbuild/freebsd-arm64': 0.19.12 + '@esbuild/freebsd-x64': 0.19.12 + '@esbuild/linux-arm': 0.19.12 + '@esbuild/linux-arm64': 0.19.12 + '@esbuild/linux-ia32': 0.19.12 + '@esbuild/linux-loong64': 0.19.12 + '@esbuild/linux-mips64el': 0.19.12 + '@esbuild/linux-ppc64': 0.19.12 + '@esbuild/linux-riscv64': 0.19.12 + '@esbuild/linux-s390x': 0.19.12 + '@esbuild/linux-x64': 0.19.12 + '@esbuild/netbsd-x64': 0.19.12 + '@esbuild/openbsd-x64': 0.19.12 + '@esbuild/sunos-x64': 0.19.12 + '@esbuild/win32-arm64': 0.19.12 + '@esbuild/win32-ia32': 0.19.12 + '@esbuild/win32-x64': 0.19.12 + dev: true + + /esbuild@0.20.1: + resolution: {integrity: sha512-OJwEgrpWm/PCMsLVWXKqvcjme3bHNpOgN7Tb6cQnR5n0TPbQx1/Xrn7rqM+wn17bYeT6MGB5sn1Bh5YiGi70nA==} + engines: {node: '>=12'} + hasBin: true + requiresBuild: true + optionalDependencies: + '@esbuild/aix-ppc64': 0.20.1 + '@esbuild/android-arm': 0.20.1 + '@esbuild/android-arm64': 0.20.1 + '@esbuild/android-x64': 0.20.1 + '@esbuild/darwin-arm64': 0.20.1 + '@esbuild/darwin-x64': 0.20.1 + '@esbuild/freebsd-arm64': 0.20.1 + '@esbuild/freebsd-x64': 0.20.1 + '@esbuild/linux-arm': 0.20.1 + '@esbuild/linux-arm64': 0.20.1 + '@esbuild/linux-ia32': 0.20.1 + '@esbuild/linux-loong64': 0.20.1 + '@esbuild/linux-mips64el': 0.20.1 + '@esbuild/linux-ppc64': 0.20.1 + '@esbuild/linux-riscv64': 0.20.1 + '@esbuild/linux-s390x': 0.20.1 + '@esbuild/linux-x64': 0.20.1 + '@esbuild/netbsd-x64': 0.20.1 + '@esbuild/openbsd-x64': 0.20.1 + '@esbuild/sunos-x64': 0.20.1 + '@esbuild/win32-arm64': 0.20.1 + '@esbuild/win32-ia32': 0.20.1 + '@esbuild/win32-x64': 0.20.1 + dev: false /escalade@3.1.2: resolution: {integrity: sha512-ErCHMCae19vR8vQGe50xIsVomy19rg6gFu3+r3jkEO46suLMWBksvVyoGgQV+jOfl84ZSOSlmv6Gxa89PmTGmA==} @@ -3171,6 +3749,10 @@ packages: resolution: {integrity: sha512-MMdARuVEQziNTeJD8DgMqmhwR11BRQ/cBP+pLtYdSTnf3MIO8fFeiINEbX36ZdNlfU/7A9f3gUw49B3oQsvwBA==} engines: {node: '>=4.0'} + /estree-walker@2.0.2: + resolution: {integrity: sha512-Rfkk/Mp/DL7JVje3u18FxFujQlTNR2q6QfMSMB7AvCBx91NGj/ba3kCfza0f6dVDbw7YlRf/nDrn7pQrCCyQ/w==} + dev: false + /esutils@2.0.3: resolution: {integrity: sha512-kVscqXk4OCp68SZ0dkgEKVi6/8ij300KBWTJq32P/dYeWTSwK41WyTxalN1eRmA5Z9UU/LX9D7FWSmV9SAYx6g==} engines: {node: '>=0.10.0'} @@ -3432,6 +4014,7 @@ packages: dependencies: cross-spawn: 7.0.3 signal-exit: 4.1.0 + dev: false /form-data@4.0.0: resolution: {integrity: sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==} @@ -3587,6 +4170,7 @@ packages: minimatch: 9.0.3 minipass: 7.0.4 path-scurry: 1.10.1 + dev: false /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} @@ -3598,6 +4182,17 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 + /glob@8.1.0: + resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} + engines: {node: '>=12'} + dependencies: + fs.realpath: 1.0.0 + inflight: 1.0.6 + inherits: 2.0.4 + minimatch: 5.1.6 + once: 1.4.0 + dev: false + /global-dirs@0.1.1: resolution: {integrity: sha512-NknMLn7F2J7aflwFOlGdNIuCDpN3VGoSoB+aap3KABFWbHVn1TCgFC+np23J8W2BiZbjfEw3BFBycSMv1AFblg==} engines: {node: '>=4'} @@ -3697,6 +4292,11 @@ packages: dependencies: function-bind: 1.1.2 + /helpertypes@0.0.19: + resolution: {integrity: sha512-J00e55zffgi3yVnUp0UdbMztNkr2PnizEkOe9URNohnrNhW5X0QpegkuLpOmFQInpi93Nb8MCjQRHAiCDF42NQ==} + engines: {node: '>=10.0.0'} + dev: false + /highlight.js@10.7.3: resolution: {integrity: sha512-tzcUFauisWKNHaRkN4Wjl/ZA07gENAjFl3J/c480dprkGTg5EQstgaNFqBfUqCq54kZRIEcreTsAgF/m2quD7A==} @@ -3728,6 +4328,10 @@ packages: dependencies: lru-cache: 10.2.0 + /hrtime@0.5.0: + resolution: {integrity: sha512-LcmT1NgqzxGC8leMimQBqBIlCPMg+dxotqvUfUsrGiqPLTdLmnFBXf3R4xlpeqfBEmFTbuwM5Q6f42Y9dxxUiQ==} + dev: false + /html-encoding-sniffer@3.0.0: resolution: {integrity: sha512-oWv4T4yJ52iKrufjnyZPkrN0CH3QnrUqdB6In1g5Fe1mia8GmF36gnfNySxoZtxD5+NmYw1EElVXiBk93UeskA==} engines: {node: '>=12'} @@ -3892,6 +4496,13 @@ packages: resolution: {integrity: sha512-NcdALwpXkTm5Zvvbk7owOUSvVvBKDgKP5/ewfXEznmQFfs4ZRmanOeKBTjRVjka3QFoN6XJ+9F3USqfHqTaU5w==} dev: true + /is-builtin-module@3.2.1: + resolution: {integrity: sha512-BSLE3HnV2syZ0FK0iMA/yUGplUeMmNz4AW5fnTunbCIqZi4vG3WjJT9FHMy5D69xmAYBHXQhJdALdpwVxV501A==} + engines: {node: '>=6'} + dependencies: + builtin-modules: 3.3.0 + dev: false + /is-core-module@2.13.1: resolution: {integrity: sha512-hHrIjvZsftOsvKSn2TRYl63zvxsgE0K+0mYMoH6gD4omR5IWB2KynivBQczo3+wF1cCkjzvptnI9Q0sPU66ilw==} dependencies: @@ -3921,6 +4532,10 @@ packages: dependencies: is-extglob: 2.1.1 + /is-module@1.0.0: + resolution: {integrity: sha512-51ypPSPCoTEIN9dy5Oy+h4pShgJmPCygKfyRCISBI+JoWT/2oJvK8QPxmwv7b/p239jXrm9M1mlQbyKJ5A152g==} + dev: false + /is-number@7.0.0: resolution: {integrity: sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==} engines: {node: '>=0.12.0'} @@ -3948,6 +4563,12 @@ packages: /is-potential-custom-element-name@1.0.1: resolution: {integrity: sha512-bCYeRA2rVibKZd+s2625gGnGF/t7DSqDs4dP7CrLA1m7jKWz6pps0LpYLJN8Q64HtmPKJ1hrN3nzPNKFEKOUiQ==} + /is-reference@1.2.1: + resolution: {integrity: sha512-U82MsXXiFIrjCK4otLT+o2NA2Cd2g5MLoOVXUZjIOhLurrRxpEXzI8O0KZHr3IjLvlAH1kTPYSuqer5T9ZVBKQ==} + dependencies: + '@types/estree': 1.0.5 + dev: false + /is-stream@2.0.1: resolution: {integrity: sha512-hFoiJiTl63nn+kstHGBtewWSKnQLpyb155KHheA1l39uvtO9nWIop1p3udqPcUd/xbF1VLMO4n7OI6p7RbngDg==} engines: {node: '>=8'} @@ -3975,6 +4596,11 @@ packages: /isarray@1.0.0: resolution: {integrity: sha512-VLghIWNM6ELQzo7zwmcg0NmTVyWKYjvIeM83yjp0wRDTmUnrM678fQbcKBo6n2CJEF0szoG//ytg+TKla89ALQ==} + /isbot@3.8.0: + resolution: {integrity: sha512-vne1mzQUTR+qsMLeCBL9+/tgnDXRyc2pygLGl/WsgA+EZKIiB5Ehu0CiVTHIIk30zhJ24uGz4M5Ppse37aR0Hg==} + engines: {node: '>=12'} + dev: false + /isexe@2.0.0: resolution: {integrity: sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==} @@ -4059,6 +4685,7 @@ packages: '@isaacs/cliui': 8.0.2 optionalDependencies: '@pkgjs/parseargs': 0.11.0 + dev: false /java-properties@1.0.2: resolution: {integrity: sha512-qjdpeo2yKlYTH7nFdK0vbZWuTCesk4o63v5iVOlhMQPfuIZQfW/HI35SjfhA+4qpg36rnFSvUK5b1m+ckIblQQ==} @@ -4379,7 +5006,7 @@ packages: dependencies: expect-puppeteer: 6.1.1 jest-environment-puppeteer: 6.2.0 - puppeteer: 21.11.0 + puppeteer: 21.11.0(typescript@5.3.3) transitivePeerDependencies: - debug - supports-color @@ -4891,6 +5518,13 @@ packages: engines: {node: '>=12'} dev: true + /magic-string@0.30.7: + resolution: {integrity: sha512-8vBuFF/I/+OSLRmdf2wwFCJCz+nSn0m6DPvGH1fS/KiQoSaR+sETbov0eIk9KhEKy8CYqIkIAnbohxT/4H0kuA==} + engines: {node: '>=12'} + dependencies: + '@jridgewell/sourcemap-codec': 1.4.15 + dev: false + /make-dir@4.0.0: resolution: {integrity: sha512-hXdUTZYIVOt1Ex//jAQi+wTZZpUpwBj/0QsOzqegb3rGMMeJiSEu5xLHnYfBrRV4RH2+OCSOO95Is/7x1WJ4bw==} engines: {node: '>=10'} @@ -5015,11 +5649,19 @@ packages: dependencies: brace-expansion: 1.1.11 + /minimatch@5.1.6: + resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} + engines: {node: '>=10'} + dependencies: + brace-expansion: 2.0.1 + dev: false + /minimatch@9.0.3: resolution: {integrity: sha512-RHiac9mvaRw0x3AYRgDC1CxAP7HTcNrrECeA8YYJeWnpo+2Q5CegtZjaotWTWxDG3UeGA1coE05iH1mPjT/2mg==} engines: {node: '>=16 || 14 >=14.17'} dependencies: brace-expansion: 2.0.1 + dev: false /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} @@ -5036,6 +5678,7 @@ packages: /minipass@7.0.4: resolution: {integrity: sha512-jYofLM5Dam9279rdkWzqHozUo4ybjdZmCsDHePy5V/PbBcVMiSZR97gmAy45aqi8CK1lG2ECd356FU86avfwUQ==} engines: {node: '>=16 || 14 >=14.17'} + dev: false /mitt@3.0.1: resolution: {integrity: sha512-vKivATfr97l2/QBCYAkXYDbrIWPM2IIKEl7YPhjCvKlG3kE2gm+uBo6nEXK3M5/Ffh/FLpKExzOQ3JJoJGFKBw==} @@ -5248,6 +5891,11 @@ packages: resolution: {integrity: sha512-rJgTQnkUnH1sFw8yT6VSU3zD3sWmu6sZhIseY8VX+GRu3P6F7Fu+JNDoXfklElbLJSnc3FUQHVe4cU5hj+BcUg==} engines: {node: '>=0.10.0'} + /object-path@0.11.8: + resolution: {integrity: sha512-YJjNZrlXJFM42wTBn6zgOJVar9KFJvzx6sTWDte8sWZF//cnjl0BxHNpfZx+ZffXX63A9q0b1zsFiBX4g4X5KA==} + engines: {node: '>= 10.12.0'} + dev: false + /object-treeify@3.3.1: resolution: {integrity: sha512-oGCWfO3GEvv5foAuiLR64W02Xj/lWGLY7tuY35L2JBaOasaBxI0184PQzdhWHhib8guarXig3LMTL+MTI6cdSQ==} engines: {node: '>= 12'} @@ -5498,6 +6146,7 @@ packages: dependencies: lru-cache: 10.2.0 minipass: 7.0.4 + dev: false /path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} @@ -5530,6 +6179,7 @@ packages: /pirates@4.0.6: resolution: {integrity: sha512-saLsH7WeYYPiD25LDuLRRY/i+6HaPYr6G1OUlN39otzkSTxKnubR9RTxS3/Kk50s1g2JTgFwWQDQyplC5/SHZg==} engines: {node: '>= 6'} + dev: false /pkg-conf@2.1.0: resolution: {integrity: sha512-C+VUP+8jis7EsQZIhDYmS5qlNtjv2yP4SNtjXK9AP1ZcTRlnSfuumaTnRfYZnYgUUYVIKqL0fRvmUGDV2fmp6g==} @@ -5653,14 +6303,14 @@ packages: - utf-8-validate dev: true - /puppeteer@21.11.0: + /puppeteer@21.11.0(typescript@5.3.3): resolution: {integrity: sha512-9jTHuYe22TD3sNxy0nEIzC7ZrlRnDgeX3xPkbS7PnbdwYjl2o/z/YuCrRBwezdKpbTDTJ4VqIggzNyeRcKq3cg==} engines: {node: '>=16.13.2'} hasBin: true requiresBuild: true dependencies: '@puppeteer/browsers': 1.9.1 - cosmiconfig: 9.0.0 + cosmiconfig: 9.0.0(typescript@5.3.3) puppeteer-core: 21.11.0 transitivePeerDependencies: - bufferutil @@ -5866,6 +6516,84 @@ packages: dependencies: glob: 7.2.3 + /rollup-plugin-swc-minify@1.1.0(rollup@4.11.0): + resolution: {integrity: sha512-oVGLF95v1tdyQdEk1QFu2Imd54c+x62NHT198sifMwy9rT/nfamK260cGZ8Dgg3hUp+KQVFY2WcbmjZpmSk60A==} + engines: {node: '>= 14.18'} + peerDependencies: + rollup: ^2 || ^3 || ^4 + dependencies: + '@swc/core': 1.4.1 + rollup: 4.11.0 + transitivePeerDependencies: + - '@swc/helpers' + dev: false + + /rollup-plugin-ts@3.4.5(@swc/core@1.4.1)(rollup@4.11.0)(typescript@5.3.3): + resolution: {integrity: sha512-9iCstRJpEZXSRQuXitlSZAzcGlrqTbJg1pE4CMbEi6xYldxVncdPyzA2I+j6vnh73wBymZckerS+Q/iEE/M3Ow==} + engines: {node: '>=16.15.1', npm: '>=7.0.0', pnpm: '>=3.2.0', yarn: '>=1.13'} + peerDependencies: + '@babel/core': '>=7.x' + '@babel/plugin-transform-runtime': '>=7.x' + '@babel/preset-env': '>=7.x' + '@babel/preset-typescript': '>=7.x' + '@babel/runtime': '>=7.x' + '@swc/core': '>=1.x' + '@swc/helpers': '>=0.2' + rollup: '>=1.x || >=2.x || >=3.x' + typescript: '>=3.2.x || >= 4.x || >= 5.x' + peerDependenciesMeta: + '@babel/core': + optional: true + '@babel/plugin-transform-runtime': + optional: true + '@babel/preset-env': + optional: true + '@babel/preset-typescript': + optional: true + '@babel/runtime': + optional: true + '@swc/core': + optional: true + '@swc/helpers': + optional: true + dependencies: + '@rollup/pluginutils': 5.1.0(rollup@4.11.0) + '@swc/core': 1.4.1 + '@wessberg/stringutil': 1.0.19 + ansi-colors: 4.1.3 + browserslist: 4.23.0 + browserslist-generator: 2.1.0 + compatfactory: 3.0.0(typescript@5.3.3) + crosspath: 2.0.0 + magic-string: 0.30.7 + rollup: 4.11.0 + ts-clone-node: 3.0.0(typescript@5.3.3) + tslib: 2.6.2 + typescript: 5.3.3 + dev: false + + /rollup@4.11.0: + resolution: {integrity: sha512-2xIbaXDXjf3u2tajvA5xROpib7eegJ9Y/uPlSFhXLNpK9ampCczXAhLEb5yLzJyG3LAdI1NWtNjDXiLyniNdjQ==} + engines: {node: '>=18.0.0', npm: '>=8.0.0'} + hasBin: true + dependencies: + '@types/estree': 1.0.5 + optionalDependencies: + '@rollup/rollup-android-arm-eabi': 4.11.0 + '@rollup/rollup-android-arm64': 4.11.0 + '@rollup/rollup-darwin-arm64': 4.11.0 + '@rollup/rollup-darwin-x64': 4.11.0 + '@rollup/rollup-linux-arm-gnueabihf': 4.11.0 + '@rollup/rollup-linux-arm64-gnu': 4.11.0 + '@rollup/rollup-linux-arm64-musl': 4.11.0 + '@rollup/rollup-linux-riscv64-gnu': 4.11.0 + '@rollup/rollup-linux-x64-gnu': 4.11.0 + '@rollup/rollup-linux-x64-musl': 4.11.0 + '@rollup/rollup-win32-arm64-msvc': 4.11.0 + '@rollup/rollup-win32-ia32-msvc': 4.11.0 + '@rollup/rollup-win32-x64-msvc': 4.11.0 + fsevents: 2.3.3 + /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: @@ -6015,6 +6743,10 @@ packages: engines: {node: '>= 6.0.0', npm: '>= 3.0.0'} dev: true + /smob@1.4.1: + resolution: {integrity: sha512-9LK+E7Hv5R9u4g4C3p+jjLstaLe11MDsL21UpYaCNmapvMkYhqCV4A/f/3gyH8QjMyh6l68q9xC85vihY9ahMQ==} + dev: false + /socks-proxy-agent@8.0.2: resolution: {integrity: sha512-8zuqoLv1aP/66PHF5TqwJ7Czm3Yv32urJQHrVyhD7mmA6d61Zv8cIXQYPTWwmg6qlupnPvs/QKDmfa4P/qct2g==} engines: {node: '>= 14'} @@ -6041,16 +6773,10 @@ packages: source-map: 0.6.1 dev: false - /source-map-support@0.5.21: - resolution: {integrity: sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==} - dependencies: - buffer-from: 1.1.2 - source-map: 0.6.1 - dev: true - /source-map@0.6.1: resolution: {integrity: sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==} engines: {node: '>=0.10.0'} + requiresBuild: true /spawn-error-forwarder@1.0.0: resolution: {integrity: sha512-gRjMgK5uFjbCvdibeGJuy3I5OYz6VLoVdsOJdA6wV0WlfQVLFueoqMxwwYD9RODdgb6oUIvlRlsyFSiQkMKu0g==} @@ -6148,6 +6874,7 @@ packages: eastasianwidth: 0.2.0 emoji-regex: 9.2.2 strip-ansi: 7.1.0 + dev: false /string_decoder@1.1.1: resolution: {integrity: sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==} @@ -6217,6 +6944,7 @@ packages: mz: 2.7.0 pirates: 4.0.6 ts-interface-checker: 0.1.13 + dev: false /supports-color@5.5.0: resolution: {integrity: sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==} @@ -6378,6 +7106,11 @@ packages: engines: {node: '>=8'} dev: false + /trim-newlines@5.0.0: + resolution: {integrity: sha512-kstfs+hgwmdsOadN3KgA+C68wPJwnZq4DN6WMDCvZapDWEF34W2TyPKN2v2+BJnZgIz5QOfxFeldLyYvdgRAwg==} + engines: {node: '>=14.16'} + dev: false + /ts-api-utils@1.2.1(typescript@5.3.3): resolution: {integrity: sha512-RIYA36cJn2WiH9Hy77hdF9r7oEwxAtB/TS9/S4Qd90Ap4z5FSiin5zEiTL44OII1Y3IIlEvxwxFUVgrHSZ/UpA==} engines: {node: '>=16'} @@ -6387,6 +7120,16 @@ packages: typescript: 5.3.3 dev: false + /ts-clone-node@3.0.0(typescript@5.3.3): + resolution: {integrity: sha512-egavvyHbIoelkgh1IC2agNB1uMNjB8VJgh0g/cn0bg2XXTcrtjrGMzEk4OD3Fi2hocICjP3vMa56nkzIzq0FRg==} + engines: {node: '>=14.9.0'} + peerDependencies: + typescript: ^3.x || ^4.x || ^5.x + dependencies: + compatfactory: 3.0.0(typescript@5.3.3) + typescript: 5.3.3 + dev: false + /ts-dedent@2.2.0: resolution: {integrity: sha512-q5W7tVM71e2xjHZTlgfTDoPF/SmqKG5hddq9SzR49CH2hayqRKJtQ4mtRlSxKaJlR/+9rEM+mnBHf7I2/BQcpQ==} engines: {node: '>=6.10'} @@ -6394,6 +7137,7 @@ packages: /ts-interface-checker@0.1.13: resolution: {integrity: sha512-Y/arvbn+rrz3JCKl9C4kVNfTfSm2/mEp5FSz5EsZSANGPSlQrpRI5M4PKF+mJnE52jOO90PnPSc3Ur3bTQw0gA==} + dev: false /ts-jest@29.1.2(@babel/core@7.23.9)(jest@29.7.0)(typescript@5.3.3): resolution: {integrity: sha512-br6GJoH/WUX4pu7FbZXuWGKGNDuU7b8Uj77g/Sp7puZV6EXzuByl6JrECvm0MzVzSTkSHWTihsXt+5XYER5b+g==} @@ -6463,15 +7207,14 @@ packages: /tslib@2.6.2: resolution: {integrity: sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==} - dev: true - /tsx@3.14.0: - resolution: {integrity: sha512-xHtFaKtHxM9LOklMmJdI3BEnQq/D5F73Of2E1GDrITi9sgoVkvIsrQUTY1G8FlmGtA+awCI4EBlTRRYxkL2sRg==} + /tsx@4.7.1: + resolution: {integrity: sha512-8d6VuibXHtlN5E3zFkgY8u4DX7Y3Z27zvvPKVmLon/D4AjuKzarkUBTLDBgj9iTQ0hg5xM7c/mYiRVM+HETf0g==} + engines: {node: '>=18.0.0'} hasBin: true dependencies: - esbuild: 0.18.20 + esbuild: 0.19.12 get-tsconfig: 4.7.2 - source-map-support: 0.5.21 optionalDependencies: fsevents: 2.3.3 dev: true @@ -6591,6 +7334,10 @@ packages: engines: {node: '>=14.17'} hasBin: true + /ua-parser-js@1.0.37: + resolution: {integrity: sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==} + dev: false + /ufo@1.4.0: resolution: {integrity: sha512-Hhy+BhRBleFjpJ2vchUNN40qgkh0366FWJGqVLYBHev0vpHTrXSA0ryT+74UiW6KWsldNurQMKGqCm1M2zBciQ==} dev: false @@ -6766,6 +7513,12 @@ packages: dependencies: isexe: 2.0.0 + /wide-align@1.1.5: + resolution: {integrity: sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==} + dependencies: + string-width: 4.2.3 + dev: false + /wordwrap@1.0.0: resolution: {integrity: sha512-gvVzJFlPycKc5dZN4yPkP8w7Dc37BtP1yczEneOb4uq34pXZcvrtRTmWV8W+Ume+XCxKgbjM+nevkyFPMybd4Q==} @@ -6784,6 +7537,7 @@ packages: ansi-styles: 6.2.1 string-width: 5.1.2 strip-ansi: 7.1.0 + dev: false /wrappy@1.0.2: resolution: {integrity: sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==} diff --git a/rollup.config.mjs b/rollup.config.mjs new file mode 100644 index 0000000..9002bfb --- /dev/null +++ b/rollup.config.mjs @@ -0,0 +1,91 @@ +import swc from '@rollup/plugin-swc' +import commonjs from '@rollup/plugin-commonjs' +import { nodeResolve } from '@rollup/plugin-node-resolve' +import { readFileSync } from 'fs' +import { createFilter } from '@rollup/pluginutils' +import { extname } from 'path' + +const raw = (pattern) => [ + createFilter(pattern), + { + name: 'raw-loader', + load(id) { + if (id.endsWith(extname(pattern))) { + return `export default \`${readFileSync(id, 'utf-8')}\`;` + } + return null + } + } +] + +import MagicString from 'magic-string' + +export const ESM_SHIM_CODE = ` +/* Techor ESM Shim */ +import __url_for_shim from 'url'; +import __path_for_shim from 'path'; +import __mod_for_shim from 'module'; +const __filename = __url_for_shim.fileURLToPath(import.meta.url); +const __dirname = __path_for_shim.dirname(__filename); +const require = __mod_for_shim.createRequire(import.meta.url);\n +` + +function esmShim() { + return { + name: 'techor-esm-shim', + renderChunk(code, chunk, options) { + if (options.format === 'es' && !code.includes(ESM_SHIM_CODE) && /__filename|__dirname|require\(|require\.resolve\(/.test(code)) { + const str = new MagicString(code) + /* insert ESM_SHIM_CODE after the something like: + * #!/usr/bin/env node + */ + if (code.startsWith('#!')) { + str.prependRight(code.indexOf('\n') + 1, ESM_SHIM_CODE) + } else { + str.prepend(ESM_SHIM_CODE) + } + return { + code: str.toString(), + map: str.generateMap() + } + } + return null + }, + } +} + +const pkg = JSON.parse(readFileSync('package.json', 'utf-8')) + +const DEFAULT_EXTENSIONS = [ + '.ts', + '.tsx', + '.mjs', + '.cjs', + '.js', + '.jsx', + '.json', +] + +/** @type {import('rollup').RollupOptions} */ +export default { + input: 'src/index.ts', + output: [ + { file: 'dist/index.cjs', format: 'cjs' }, + { file: 'dist/index.mjs', format: 'esm' } + ], + plugins: [ + swc(), + commonjs({ extensions: ['.js', '.ts'] }), + nodeResolve({ + extensions: DEFAULT_EXTENSIONS, + exportConditions: ['node', 'import', 'require', 'default'] + }), + esmShim(), + raw('**/*.hbs') + ], + external: [ + ...Object.keys(pkg.dependencies || {}), + ...Object.keys(pkg.peerDependencies || {}), + ...Object.keys(pkg.optionalDependencies || {}) + ] +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 323ed52..1f6f21e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -18,4 +18,7 @@ "esnext" ] }, + "include": [ + "**/tests/**/*" + ] } \ No newline at end of file