From 638b1686288ad685243d34cd9f1db3814f4db1c0 Mon Sep 17 00:00:00 2001 From: Anthony Fu Date: Fri, 13 May 2022 11:00:54 +0800 Subject: [PATCH] chore: use `unbuild` to bundle plugins (#8139) --- .eslintignore | 4 + .eslintrc.cjs | 2 +- .github/workflows/ci.yml | 17 +- .prettierignore | 8 +- package.json | 17 +- packages/plugin-legacy/build.config.ts | 10 + packages/plugin-legacy/package.json | 25 +- .../plugin-legacy/{index.js => src/index.ts} | 209 +++++----- .../{index.d.ts => src/types.ts} | 8 - packages/plugin-legacy/tsconfig.json | 19 + packages/plugin-react/api-extractor.json | 53 --- packages/plugin-react/build.config.ts | 12 + packages/plugin-react/package.json | 25 +- packages/plugin-react/src/index.ts | 11 +- .../src/jsx-runtime/restore-jsx.ts | 17 +- packages/plugin-react/tsconfig.json | 6 +- packages/plugin-vue-jsx/build.config.ts | 10 + packages/plugin-vue-jsx/index.d.ts | 14 - packages/plugin-vue-jsx/package.json | 24 +- .../plugin-vue-jsx/{index.js => src/index.ts} | 84 ++-- packages/plugin-vue-jsx/src/types.ts | 10 + packages/plugin-vue-jsx/tsconfig.json | 19 + packages/plugin-vue/api-extractor.json | 53 --- packages/plugin-vue/build.config.ts | 12 + packages/plugin-vue/package.json | 27 +- packages/plugin-vue/src/index.ts | 10 +- packages/plugin-vue/tsconfig.json | 5 +- packages/vite/package.json | 3 +- playground/react-emotion/vite.config.ts | 8 +- pnpm-lock.yaml | 391 +++++++++++++++++- scripts/patchCJS.ts | 57 +++ scripts/patchEsbuildDist.ts | 31 -- 32 files changed, 766 insertions(+), 435 deletions(-) create mode 100644 .eslintignore create mode 100644 packages/plugin-legacy/build.config.ts rename packages/plugin-legacy/{index.js => src/index.ts} (83%) rename packages/plugin-legacy/{index.d.ts => src/types.ts} (75%) create mode 100644 packages/plugin-legacy/tsconfig.json delete mode 100644 packages/plugin-react/api-extractor.json create mode 100644 packages/plugin-react/build.config.ts create mode 100644 packages/plugin-vue-jsx/build.config.ts delete mode 100644 packages/plugin-vue-jsx/index.d.ts rename packages/plugin-vue-jsx/{index.js => src/index.ts} (81%) create mode 100644 packages/plugin-vue-jsx/src/types.ts create mode 100644 packages/plugin-vue-jsx/tsconfig.json delete mode 100644 packages/plugin-vue/api-extractor.json create mode 100644 packages/plugin-vue/build.config.ts create mode 100644 scripts/patchCJS.ts delete mode 100644 scripts/patchEsbuildDist.ts diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 000000000..3e795e7a9 --- /dev/null +++ b/.eslintignore @@ -0,0 +1,4 @@ +dist +playground-temp +temp + diff --git a/.eslintrc.cjs b/.eslintrc.cjs index d5050bd48..bb48bf9c3 100644 --- a/.eslintrc.cjs +++ b/.eslintrc.cjs @@ -125,7 +125,7 @@ module.exports = defineConfig({ } }, { - files: ['packages/create-vite/template-*/**'], + files: ['packages/create-vite/template-*/**', '**/build.config.ts'], rules: { 'node/no-missing-import': 'off' } diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 05813fbd7..7a329e3c2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,14 +66,8 @@ jobs: - name: Install Playwright run: pnpm playwright install - - name: Build vite - run: pnpm run ci-build-vite - - - name: Build plugin-vue - run: pnpm run build-plugin-vue - - - name: Build plugin-react - run: pnpm run build-plugin-react + - name: Build + run: pnpm run build - name: Test unit run: pnpm run test-unit @@ -107,11 +101,8 @@ jobs: env: PLAYWRIGHT_SKIP_BROWSER_DOWNLOAD: "1" - - name: Prepare - run: | - pnpm run ci-build-vite - pnpm run build-plugin-vue - pnpm run build-plugin-react + - name: Build + run: pnpm run build - name: Lint run: pnpm run lint diff --git a/.prettierignore b/.prettierignore index a2c1f98cf..0d5487354 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1,12 +1,8 @@ -docs/.vitepress/dist/ -packages/vite/dist/ -packages/vite/temp/ -packages/plugin-react/dist/ -packages/plugin-vue/dist/ packages/*/CHANGELOG.md playground-temp/ +dist/ +temp/ LICENSE.md -.prettierignore pnpm-lock.yaml pnpm-workspace.yaml playground/tsconfig-json-load-error/has-error/tsconfig.json diff --git a/package.json b/package.json index 92a5fd2ee..dd19523df 100644 --- a/package.json +++ b/package.json @@ -16,6 +16,7 @@ "preinstall": "npx only-allow pnpm", "format": "prettier --write .", "lint": "eslint packages/*/{src,types}/** playground/**/__tests__/** scripts/**", + "typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit", "test": "run-s test-unit test-serve test-build", "test-serve": "vitest run -c vitest.config.e2e.ts", "test-build": "cross-env VITE_TEST_BUILD=1 vitest run -c vitest.config.e2e.ts", @@ -23,21 +24,18 @@ "debug-serve": "cross-env VITE_DEBUG_SERVE=1 vitest run -c vitest.config.e2e.ts", "debug-build": "cross-env VITE_TEST_BUILD=1 VITE_PRESERVE_BUILD_ARTIFACTS=1 vitest run -c vitest.config.e2e.ts", "docs": "vitepress dev docs", - "build-docs": "vitepress build docs", - "serve-docs": "vitepress serve docs", + "docs-build": "vitepress build docs", + "docs-serve": "vitepress serve docs", + "build": "pnpm -r --filter=./packages/* run build", + "dev": "pnpm -r --parallel --filter=./packages/* run dev", "release": "ts-node scripts/release.ts", "ci-publish": "ts-node scripts/publishCI.ts", - "typecheck": "tsc -p scripts --noEmit && tsc -p playground --noEmit", - "build": "run-s build-vite build-plugin-vue build-plugin-react", - "build-vite": "cd packages/vite && npm run build", - "build-plugin-vue": "cd packages/plugin-vue && npm run build", - "build-plugin-react": "cd packages/plugin-react && npm run build", - "ci-build-vite": "cd packages/vite && npm run ci-build", - "ci-docs": "run-s build-vite build-plugin-vue build-docs" + "ci-docs": "run-s build docs-build" }, "devDependencies": { "@microsoft/api-extractor": "^7.23.1", "@types/babel__core": "^7.1.19", + "@types/babel__standalone": "^7.1.4", "@types/convert-source-map": "^1.5.2", "@types/cross-spawn": "^6.0.2", "@types/debug": "^4.1.7", @@ -83,6 +81,7 @@ "sirv": "^2.0.2", "ts-node": "^10.7.0", "typescript": "^4.6.4", + "unbuild": "^0.7.4", "vite": "workspace:*", "vitepress": "^0.22.4", "vitest": "^0.12.4", diff --git a/packages/plugin-legacy/build.config.ts b/packages/plugin-legacy/build.config.ts new file mode 100644 index 000000000..6dcf1a5a2 --- /dev/null +++ b/packages/plugin-legacy/build.config.ts @@ -0,0 +1,10 @@ +import { defineBuildConfig } from 'unbuild' + +export default defineBuildConfig({ + entries: ['src/index'], + clean: true, + declaration: true, + rollup: { + emitCJS: true + } +}) diff --git a/packages/plugin-legacy/package.json b/packages/plugin-legacy/package.json index 296c99416..828b31d57 100644 --- a/packages/plugin-legacy/package.json +++ b/packages/plugin-legacy/package.json @@ -4,11 +4,24 @@ "license": "MIT", "author": "Evan You", "files": [ - "index.js", - "index.d.ts" + "dist" ], - "main": "index.js", - "types": "index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + } + }, + "scripts": { + "dev": "unbuild --stub", + "build": "unbuild && pnpm run patch-cjs", + "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "prepublishOnly": "npm run build" + }, "engines": { "node": ">=14.6.0" }, @@ -30,5 +43,9 @@ }, "peerDependencies": { "vite": "^2.8.0" + }, + "devDependencies": { + "vite": "workspace:*", + "@babel/core": "^7.17.10" } } diff --git a/packages/plugin-legacy/index.js b/packages/plugin-legacy/src/index.ts similarity index 83% rename from packages/plugin-legacy/index.js rename to packages/plugin-legacy/src/index.ts index 2f1b1991c..5fedb716f 100644 --- a/packages/plugin-legacy/index.js +++ b/packages/plugin-legacy/src/index.ts @@ -1,15 +1,33 @@ -// @ts-check -const path = require('path') -const { createHash } = require('crypto') -const { build } = require('vite') -const MagicString = require('magic-string').default +/* eslint-disable node/no-extraneous-import */ +import path from 'path' +import { createHash } from 'crypto' +import { build } from 'vite' +import MagicString from 'magic-string' +import type { + BuildOptions, + HtmlTagDescriptor, + Plugin, + ResolvedConfig +} from 'vite' +import type { + NormalizedOutputOptions, + OutputBundle, + OutputOptions, + PreRenderedChunk, + RenderedChunk +} from 'rollup' +import type { PluginItem as BabelPlugin } from '@babel/core' +import type { Options } from './types' // lazy load babel since it's not used during dev -let babel -/** - * @return {import('@babel/standalone')} - */ -const loadBabel = () => babel || (babel = require('@babel/standalone')) +// eslint-disable-next-line @typescript-eslint/consistent-type-imports +let babel: typeof import('@babel/standalone') | undefined +async function loadBabel() { + if (!babel) { + babel = await import('@babel/standalone') + } + return babel +} // https://gist.github.com/samthor/64b114e4a4f539915a95b91ffd340acc // DO NOT ALTER THIS CONTENT @@ -27,15 +45,8 @@ const forceDynamicImportUsage = `export function __vite_legacy_guard(){import('d const legacyEnvVarMarker = `__VITE_IS_LEGACY__` -/** - * @param {import('.').Options} options - * @returns {import('vite').Plugin[]} - */ -function viteLegacyPlugin(options = {}) { - /** - * @type {import('vite').ResolvedConfig} - */ - let config +function viteLegacyPlugin(options: Options = {}): Plugin[] { + let config: ResolvedConfig const targets = options.targets || 'defaults' const genLegacy = options.renderLegacyChunks !== false const genDynamicFallback = genLegacy @@ -47,7 +58,7 @@ function viteLegacyPlugin(options = {}) { const facadeToLegacyChunkMap = new Map() const facadeToLegacyPolyfillMap = new Map() const facadeToModernPolyfillMap = new Map() - const modernPolyfills = new Set() + const modernPolyfills = new Set() // System JS relies on the Promise interface. It needs to be polyfilled for IE 11. (array.iterator is mandatory for supporting Promise.all) const DEFAULT_LEGACY_POLYFILL = [ 'core-js/modules/es.promise', @@ -79,10 +90,7 @@ function viteLegacyPlugin(options = {}) { }) } - /** - * @type {import('vite').Plugin} - */ - const legacyConfigPlugin = { + const legacyConfigPlugin: Plugin = { name: 'vite:legacy-config', apply: 'build', @@ -96,16 +104,13 @@ function viteLegacyPlugin(options = {}) { // Full CSS compat table available at https://github.com/evanw/esbuild/blob/78e04680228cf989bdd7d471e02bbc2c8d345dc9/internal/compat/css_table.go // But note that only the `HexRGBA` feature affects the minify outcome. // HSL & rebeccapurple values will be minified away regardless the target. - // So targeting `chrome61` suffices to fix the compatiblity issue. + // So targeting `chrome61` suffices to fix the compatibility issue. config.build.cssTarget = 'chrome61' } } } - /** - * @type {import('vite').Plugin} - */ - const legacyGenerateBundlePlugin = { + const legacyGenerateBundlePlugin: Plugin = { name: 'vite:legacy-generate-polyfill-chunk', apply: 'build', @@ -143,7 +148,7 @@ function viteLegacyPlugin(options = {}) { if (!legacyPolyfills.has('es.promise')) { // check if the target needs Promise polyfill because SystemJS relies // on it - detectPolyfills(`Promise.resolve()`, targets, legacyPolyfills) + await detectPolyfills(`Promise.resolve()`, targets, legacyPolyfills) } isDebug && @@ -166,10 +171,7 @@ function viteLegacyPlugin(options = {}) { } } - /** - * @type {import('vite').Plugin} - */ - const legacyPostPlugin = { + const legacyPostPlugin: Plugin = { name: 'vite:legacy-post-process', enforce: 'post', apply: 'build', @@ -184,15 +186,13 @@ function viteLegacyPlugin(options = {}) { return } - /** - * @param {string | ((chunkInfo: import('rollup').PreRenderedChunk) => string)} fileNames - * @param {string?} defaultFileName - * @returns {string | ((chunkInfo: import('rollup').PreRenderedChunk) => string)} - */ const getLegacyOutputFileName = ( - fileNames, + fileNames: + | string + | ((chunkInfo: PreRenderedChunk) => string) + | undefined, defaultFileName = '[name]-legacy.[hash].js' - ) => { + ): string | ((chunkInfo: PreRenderedChunk) => string) => { if (!fileNames) { return path.posix.join(config.build.assetsDir, defaultFileName) } @@ -213,11 +213,9 @@ function viteLegacyPlugin(options = {}) { } } - /** - * @param {import('rollup').OutputOptions} options - * @returns {import('rollup').OutputOptions} - */ - const createLegacyOutput = (options = {}) => { + const createLegacyOutput = ( + options: OutputOptions = {} + ): OutputOptions => { return { ...options, format: 'system', @@ -235,9 +233,9 @@ function viteLegacyPlugin(options = {}) { } }, - renderChunk(raw, chunk, opts) { + async renderChunk(raw, chunk, opts) { if (config.build.ssr) { - return + return null } if (!isLegacyChunk(chunk, opts)) { @@ -246,7 +244,7 @@ function viteLegacyPlugin(options = {}) { !Array.isArray(options.modernPolyfills) ) { // analyze and record modern polyfills - detectPolyfills(raw, { esmodules: true }, modernPolyfills) + await detectPolyfills(raw, { esmodules: true }, modernPolyfills) } const ms = new MagicString(raw) @@ -273,11 +271,13 @@ function viteLegacyPlugin(options = {}) { map: ms.generateMap({ hires: true }) } } - return ms.toString() + return { + code: ms.toString() + } } if (!genLegacy) { - return + return null } // @ts-ignore avoid esbuild transform on legacy chunks since it produces @@ -302,12 +302,13 @@ function viteLegacyPlugin(options = {}) { // transform the legacy chunk with @babel/preset-env const sourceMaps = !!config.build.sourcemap - const { code, map } = loadBabel().transform(raw, { + const babel = await loadBabel() + const { code, map } = babel.transform(raw, { babelrc: false, configFile: false, compact: true, sourceMaps, - inputSourceMap: sourceMaps && chunk.map, + inputSourceMap: sourceMaps ? chunk.map : undefined, presets: [ // forcing our plugin to run before preset-env by wrapping it in a // preset so we can catch the injected import statements... @@ -341,7 +342,8 @@ function viteLegacyPlugin(options = {}) { ] }) - return { code, map } + if (code) return { code, map } + return null }, transformIndexHtml(html, { chunk }) { @@ -354,11 +356,8 @@ function viteLegacyPlugin(options = {}) { return } - /** - * @type {import('vite').HtmlTagDescriptor[]} - */ - const tags = [] - const htmlFilename = chunk.facadeModuleId.replace(/\?.*$/, '') + const tags: HtmlTagDescriptor[] = [] + const htmlFilename = chunk.facadeModuleId?.replace(/\?.*$/, '') // 1. inject modern polyfills const modernPolyfillFilename = facadeToModernPolyfillMap.get( @@ -473,10 +472,7 @@ function viteLegacyPlugin(options = {}) { } let envInjectionFailed = false - /** - * @type {import('vite').Plugin} - */ - const legacyEnvPlugin = { + const legacyEnvPlugin: Plugin = { name: 'vite:legacy-env', config(config, env) { @@ -484,7 +480,7 @@ function viteLegacyPlugin(options = {}) { return { define: { 'import.meta.env.LEGACY': - env.command === 'serve' || config.build.ssr + env.command === 'serve' || config.build?.ssr ? false : legacyEnvVarMarker } @@ -512,13 +508,13 @@ function viteLegacyPlugin(options = {}) { ] } -/** - * @param {string} code - * @param {any} targets - * @param {Set} list - */ -function detectPolyfills(code, targets, list) { - const { ast } = loadBabel().transform(code, { +export async function detectPolyfills( + code: string, + targets: any, + list: Set +) { + const babel = await loadBabel() + const { ast } = babel.transform(code, { ast: true, babelrc: false, configFile: false, @@ -536,7 +532,7 @@ function detectPolyfills(code, targets, list) { ] ] }) - for (const node of ast.program.body) { + for (const node of ast!.program.body) { if (node.type === 'ImportDeclaration') { const source = node.source.value if ( @@ -549,20 +545,13 @@ function detectPolyfills(code, targets, list) { } } -/** - * @param {string} name - * @param {Set} imports - * @param {import('rollup').OutputBundle} bundle - * @param {Map} facadeToChunkMap - * @param {import('vite').BuildOptions} buildOptions - */ async function buildPolyfillChunk( - name, - imports, - bundle, - facadeToChunkMap, - buildOptions, - externalSystemJS + name: string, + imports: Set, + bundle: OutputBundle, + facadeToChunkMap: Map, + buildOptions: BuildOptions, + externalSystemJS?: boolean ) { let { minify, assetsDir } = buildOptions minify = minify ? 'terser' : false @@ -607,11 +596,10 @@ async function buildPolyfillChunk( const polyfillId = '\0vite/legacy-polyfills' -/** - * @param {Set} imports - * @return {import('rollup').Plugin} - */ -function polyfillsPlugin(imports, externalSystemJS) { +function polyfillsPlugin( + imports: Set, + externalSystemJS?: boolean +): Plugin { return { name: 'vite:legacy-polyfills', resolveId(id) { @@ -630,19 +618,14 @@ function polyfillsPlugin(imports, externalSystemJS) { } } -/** - * @param {import('rollup').RenderedChunk} chunk - * @param {import('rollup').NormalizedOutputOptions} options - */ -function isLegacyChunk(chunk, options) { +function isLegacyChunk(chunk: RenderedChunk, options: NormalizedOutputOptions) { return options.format === 'system' && chunk.fileName.includes('-legacy') } -/** - * @param {import('rollup').OutputBundle} bundle - * @param {import('rollup').NormalizedOutputOptions} options - */ -function isLegacyBundle(bundle, options) { +function isLegacyBundle( + bundle: OutputBundle, + options: NormalizedOutputOptions +) { if (options.format === 'system') { const entryChunk = Object.values(bundle).find( (output) => output.type === 'chunk' && output.isEntry @@ -654,15 +637,15 @@ function isLegacyBundle(bundle, options) { return false } -/** - * @param {Set} polyfills - */ -function recordAndRemovePolyfillBabelPlugin(polyfills) { - return ({ types: t }) => ({ +function recordAndRemovePolyfillBabelPlugin( + polyfills: Set +): BabelPlugin { + return ({ types: t }): BabelPlugin => ({ name: 'vite-remove-polyfill-import', post({ path }) { path.get('body').forEach((p) => { if (t.isImportDeclaration(p)) { + // @ts-expect-error polyfills.add(p.node.source.value) p.remove() } @@ -671,8 +654,8 @@ function recordAndRemovePolyfillBabelPlugin(polyfills) { }) } -function replaceLegacyEnvBabelPlugin() { - return ({ types: t }) => ({ +function replaceLegacyEnvBabelPlugin(): BabelPlugin { + return ({ types: t }): BabelPlugin => ({ name: 'vite-replace-env-legacy', visitor: { Identifier(path) { @@ -684,8 +667,8 @@ function replaceLegacyEnvBabelPlugin() { }) } -function wrapIIFEBabelPlugin() { - return ({ types: t, template }) => { +function wrapIIFEBabelPlugin(): BabelPlugin { + return ({ types: t, template }): BabelPlugin => { const buildIIFE = template(';(function(){%%body%%})();') return { @@ -700,13 +683,11 @@ function wrapIIFEBabelPlugin() { } } -module.exports = viteLegacyPlugin - -viteLegacyPlugin.default = viteLegacyPlugin - -viteLegacyPlugin.cspHashes = [ +export const cspHashes = [ createHash('sha256').update(safari10NoModuleFix).digest('base64'), createHash('sha256').update(systemJSInlineCode).digest('base64'), createHash('sha256').update(detectDynamicImportCode).digest('base64'), createHash('sha256').update(dynamicFallbackInlineCode).digest('base64') ] + +export default viteLegacyPlugin diff --git a/packages/plugin-legacy/index.d.ts b/packages/plugin-legacy/src/types.ts similarity index 75% rename from packages/plugin-legacy/index.d.ts rename to packages/plugin-legacy/src/types.ts index 8f340f11c..3ac7c1b6e 100644 --- a/packages/plugin-legacy/index.d.ts +++ b/packages/plugin-legacy/src/types.ts @@ -1,5 +1,3 @@ -import type { Plugin } from 'vite' - export interface Options { /** * default: 'defaults' @@ -27,9 +25,3 @@ export interface Options { */ externalSystemJS?: boolean } - -declare function createPlugin(options?: Options): Plugin - -export default createPlugin - -export const cspHashes: string[] diff --git a/packages/plugin-legacy/tsconfig.json b/packages/plugin-legacy/tsconfig.json new file mode 100644 index 000000000..c20adf0da --- /dev/null +++ b/packages/plugin-legacy/tsconfig.json @@ -0,0 +1,19 @@ +{ + "include": ["src"], + "exclude": ["**/*.spec.ts"], + "compilerOptions": { + "outDir": "dist", + "target": "ES2018", + "module": "CommonJS", + "moduleResolution": "Node", + "strict": true, + "declaration": true, + "sourceMap": true, + "noUnusedLocals": true, + "esModuleInterop": true, + "paths": { + "types/*": ["../vite/types/*"], + "vite": ["../vite/src/node/index.js"] + } + } +} diff --git a/packages/plugin-react/api-extractor.json b/packages/plugin-react/api-extractor.json deleted file mode 100644 index df6d6f9a4..000000000 --- a/packages/plugin-react/api-extractor.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - - "projectFolder": ".", - - "mainEntryPointFilePath": "./temp/index.d.ts", - - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "./dist/index.d.ts" - }, - - "apiReport": { - "enabled": false - }, - - "docModel": { - "enabled": false - }, - - "tsdocMetadata": { - "enabled": false - }, - - "messages": { - "compilerMessageReporting": { - "default": { - "logLevel": "warning" - } - }, - - "extractorMessageReporting": { - "default": { - "logLevel": "warning", - "addToApiReportFile": true - }, - - "ae-missing-release-tag": { - "logLevel": "none" - } - }, - - "tsdocMessageReporting": { - "default": { - "logLevel": "warning" - }, - - "tsdoc-undefined-tag": { - "logLevel": "none" - } - } - } -} diff --git a/packages/plugin-react/build.config.ts b/packages/plugin-react/build.config.ts new file mode 100644 index 000000000..61165722c --- /dev/null +++ b/packages/plugin-react/build.config.ts @@ -0,0 +1,12 @@ +import { defineBuildConfig } from 'unbuild' + +export default defineBuildConfig({ + entries: ['src/index'], + externals: ['vite'], + clean: true, + declaration: true, + rollup: { + emitCJS: true, + inlineDependencies: true + } +}) diff --git a/packages/plugin-react/package.json b/packages/plugin-react/package.json index ca8b1d787..deed74747 100644 --- a/packages/plugin-react/package.json +++ b/packages/plugin-react/package.json @@ -10,15 +10,21 @@ "dist", "src" ], - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + } + }, "scripts": { - "dev": "tsc -p . -w --incremental", - "build": "rimraf dist && run-s build-bundle build-types", - "build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@babel/* --external:@rollup/* --external:resolve --external:react-refresh/* --outfile=dist/index.js && npm run patch-dist", - "patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js viteReact", - "build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp", - "prepublishOnly": "(cd ../vite && npm run build) && npm run build" + "dev": "unbuild --stub", + "build": "unbuild && pnpm run patch-cjs", + "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "prepublishOnly": "npm run build" }, "engines": { "node": ">=14.6.0" @@ -44,5 +50,8 @@ }, "peerDependencies": { "vite": "^2.0.0" + }, + "devDependencies": { + "vite": "workspace:*" } } diff --git a/packages/plugin-react/src/index.ts b/packages/plugin-react/src/index.ts index 4ca3e0d37..df9789952 100644 --- a/packages/plugin-react/src/index.ts +++ b/packages/plugin-react/src/index.ts @@ -2,7 +2,7 @@ import type { ParserOptions, TransformOptions, types as t } from '@babel/core' import * as babel from '@babel/core' import { createFilter } from '@rollup/pluginutils' import resolve from 'resolve' -import type { Plugin, PluginOption } from 'vite' +import type { Plugin, PluginOption, ResolvedConfig } from 'vite' import { addRefreshWrapper, isRefreshBoundary, @@ -149,7 +149,7 @@ export default function viteReact(opts: Options = {}): PluginOption[] { }, async transform(code, id, options) { const ssr = typeof options === 'boolean' ? options : options?.ssr === true - // File extension could be mocked/overriden in querystring. + // File extension could be mocked/overridden in querystring. const [filepath, querystring = ''] = id.split('?') const [extension = ''] = querystring.match(fileExtensionRE) || @@ -368,10 +368,3 @@ viteReact.preambleCode = preambleCode function loadPlugin(path: string): Promise { return import(path).then((module) => module.default || module) } - -// overwrite for cjs require('...')() usage -// The following lines are inserted by scripts/patchEsbuildDist.ts, -// this doesn't bundle correctly after esbuild 0.14.4 -// -// module.exports = viteReact -// viteReact['default'] = viteReact diff --git a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts index dbc2218d2..2c49f508c 100644 --- a/packages/plugin-react/src/jsx-runtime/restore-jsx.ts +++ b/packages/plugin-react/src/jsx-runtime/restore-jsx.ts @@ -7,6 +7,18 @@ let babelRestoreJSX: Promise | undefined const jsxNotFound: RestoredJSX = [null, false] +async function getBabelRestoreJSX() { + if (!babelRestoreJSX) + babelRestoreJSX = import('./babel-restore-jsx').then((r) => { + const fn = r.default + if ('default' in fn) + // @ts-expect-error + return fn.default + return fn + }) + return babelRestoreJSX +} + /** Restore JSX from `React.createElement` calls */ export async function restoreJSX( babel: typeof babelCore, @@ -56,8 +68,6 @@ export async function restoreJSX( return jsxNotFound } - babelRestoreJSX ||= import('./babel-restore-jsx') - const result = await babel.transformAsync(code, { babelrc: false, configFile: false, @@ -67,8 +77,7 @@ export async function restoreJSX( parserOpts: { plugins: ['jsx'] }, - // @ts-ignore - plugins: [(await babelRestoreJSX).default] + plugins: [await getBabelRestoreJSX()] }) return [result?.ast, isCommonJS] diff --git a/packages/plugin-react/tsconfig.json b/packages/plugin-react/tsconfig.json index f025178f8..c20adf0da 100644 --- a/packages/plugin-react/tsconfig.json +++ b/packages/plugin-react/tsconfig.json @@ -10,6 +10,10 @@ "declaration": true, "sourceMap": true, "noUnusedLocals": true, - "esModuleInterop": true + "esModuleInterop": true, + "paths": { + "types/*": ["../vite/types/*"], + "vite": ["../vite/src/node/index.js"] + } } } diff --git a/packages/plugin-vue-jsx/build.config.ts b/packages/plugin-vue-jsx/build.config.ts new file mode 100644 index 000000000..6dcf1a5a2 --- /dev/null +++ b/packages/plugin-vue-jsx/build.config.ts @@ -0,0 +1,10 @@ +import { defineBuildConfig } from 'unbuild' + +export default defineBuildConfig({ + entries: ['src/index'], + clean: true, + declaration: true, + rollup: { + emitCJS: true + } +}) diff --git a/packages/plugin-vue-jsx/index.d.ts b/packages/plugin-vue-jsx/index.d.ts deleted file mode 100644 index a702c09ba..000000000 --- a/packages/plugin-vue-jsx/index.d.ts +++ /dev/null @@ -1,14 +0,0 @@ -import type { Plugin } from 'vite' -import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' -import type { FilterPattern } from '@rollup/pluginutils' - -declare interface FilterOptions { - include?: FilterPattern - exclude?: FilterPattern -} - -declare function createPlugin( - options?: VueJSXPluginOptions & FilterOptions & { babelPlugins?: any[] } -): Plugin - -export default createPlugin diff --git a/packages/plugin-vue-jsx/package.json b/packages/plugin-vue-jsx/package.json index f62a6cd98..6dbd11389 100644 --- a/packages/plugin-vue-jsx/package.json +++ b/packages/plugin-vue-jsx/package.json @@ -4,11 +4,24 @@ "license": "MIT", "author": "Evan You", "files": [ - "index.js", - "index.d.ts" + "dist" ], - "main": "index.js", - "types": "index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + } + }, + "scripts": { + "dev": "unbuild --stub", + "build": "unbuild && pnpm run patch-cjs", + "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "prepublishOnly": "npm run build" + }, "engines": { "node": ">=14.6.0" }, @@ -28,6 +41,9 @@ "@rollup/pluginutils": "^4.2.1", "@vue/babel-plugin-jsx": "^1.1.1" }, + "devDependencies": { + "vite": "workspace:*" + }, "peerDependencies": { "vite": "^2.0.0", "vue": "^3.0.0" diff --git a/packages/plugin-vue-jsx/index.js b/packages/plugin-vue-jsx/src/index.ts similarity index 81% rename from packages/plugin-vue-jsx/index.js rename to packages/plugin-vue-jsx/src/index.ts index 41fcb911c..e23f0031b 100644 --- a/packages/plugin-vue-jsx/index.js +++ b/packages/plugin-vue-jsx/src/index.ts @@ -1,10 +1,16 @@ -// @ts-check -const babel = require('@babel/core') -const jsx = require('@vue/babel-plugin-jsx') -const importMeta = require('@babel/plugin-syntax-import-meta') -const { createFilter, normalizePath } = require('@rollup/pluginutils') -const { createHash } = require('crypto') -const path = require('path') +import { createHash } from 'crypto' +import path from 'path' +import type { types } from '@babel/core' +import babel from '@babel/core' +import jsx from '@vue/babel-plugin-jsx' +// @ts-expect-error missing type +import importMeta from '@babel/plugin-syntax-import-meta' +import { createFilter, normalizePath } from '@rollup/pluginutils' +import type { ComponentOptions } from 'vue' +import type { Plugin } from 'vite' +import type { Options } from './types' + +export * from './types' const ssrRegisterHelperId = '/__vue-jsx-ssr-register-helper' const ssrRegisterHelperCode = @@ -14,10 +20,8 @@ const ssrRegisterHelperCode = /** * This function is serialized with toString() and evaluated as a virtual * module during SSR - * @param {import('vue').ComponentOptions} comp - * @param {string} filename */ -function ssrRegisterHelper(comp, filename) { +function ssrRegisterHelper(comp: ComponentOptions, filename: string) { const setup = comp.setup comp.setup = (props, ctx) => { // @ts-ignore @@ -29,17 +33,7 @@ function ssrRegisterHelper(comp, filename) { } } -/** - * @typedef { import('@rollup/pluginutils').FilterPattern} FilterPattern - * @typedef { { include?: FilterPattern, exclude?: FilterPattern, babelPlugins?: any[] } } CommonOptions - */ - -/** - * - * @param {import('@vue/babel-plugin-jsx').VueJSXPluginOptions & CommonOptions} options - * @returns {import('vite').Plugin} - */ -function vueJsxPlugin(options = {}) { +function vueJsxPlugin(options: Options = {}): Plugin { let root = '' let needHmr = false let needSourceMap = true @@ -110,31 +104,28 @@ function vueJsxPlugin(options = {}) { sourceMaps: needSourceMap, sourceFileName: id, configFile: false - }) + })! if (!ssr && !needHmr) { + if (!result.code) return return { code: result.code, map: result.map } } + interface HotComponent { + local: string + exported: string + id: string + } + // check for hmr injection - /** - * @type {{ name: string }[]} - */ - const declaredComponents = [] - /** - * @type {{ - * local: string, - * exported: string, - * id: string, - * }[]} - */ - const hotComponents = [] + const declaredComponents: { name: string }[] = [] + const hotComponents: HotComponent[] = [] let hasDefault = false - for (const node of result.ast.program.body) { + for (const node of result.ast!.program.body) { if (node.type === 'VariableDeclaration') { const names = parseComponentDecls(node, code) if (names.length) { @@ -204,7 +195,7 @@ function vueJsxPlugin(options = {}) { if (hotComponents.length) { if (hasDefault && (needHmr || ssr)) { result.code = - result.code.replace( + result.code!.replace( /export default defineComponent/g, `const __default__ = defineComponent` ) + `\nexport default __default__` @@ -239,6 +230,7 @@ function vueJsxPlugin(options = {}) { } } + if (!result.code) return return { code: result.code, map: result.map @@ -248,11 +240,7 @@ function vueJsxPlugin(options = {}) { } } -/** - * @param {import('@babel/core').types.VariableDeclaration} node - * @param {string} source - */ -function parseComponentDecls(node, source) { +function parseComponentDecls(node: types.VariableDeclaration, source: string) { const names = [] for (const decl of node.declarations) { if (decl.id.type === 'Identifier' && isDefineComponentCall(decl.init)) { @@ -264,10 +252,7 @@ function parseComponentDecls(node, source) { return names } -/** - * @param {import('@babel/core').types.Node} node - */ -function isDefineComponentCall(node) { +function isDefineComponentCall(node?: types.Node | null) { return ( node && node.type === 'CallExpression' && @@ -276,13 +261,8 @@ function isDefineComponentCall(node) { ) } -/** - * @param {string} text - * @returns {string} - */ -function getHash(text) { +function getHash(text: string) { return createHash('sha256').update(text).digest('hex').substring(0, 8) } -module.exports = vueJsxPlugin -vueJsxPlugin.default = vueJsxPlugin +export default vueJsxPlugin diff --git a/packages/plugin-vue-jsx/src/types.ts b/packages/plugin-vue-jsx/src/types.ts new file mode 100644 index 000000000..aa30b7435 --- /dev/null +++ b/packages/plugin-vue-jsx/src/types.ts @@ -0,0 +1,10 @@ +import type { VueJSXPluginOptions } from '@vue/babel-plugin-jsx' +import type { FilterPattern } from '@rollup/pluginutils' + +export interface FilterOptions { + include?: FilterPattern + exclude?: FilterPattern +} + +export type Options = VueJSXPluginOptions & + FilterOptions & { babelPlugins?: any[] } diff --git a/packages/plugin-vue-jsx/tsconfig.json b/packages/plugin-vue-jsx/tsconfig.json new file mode 100644 index 000000000..c20adf0da --- /dev/null +++ b/packages/plugin-vue-jsx/tsconfig.json @@ -0,0 +1,19 @@ +{ + "include": ["src"], + "exclude": ["**/*.spec.ts"], + "compilerOptions": { + "outDir": "dist", + "target": "ES2018", + "module": "CommonJS", + "moduleResolution": "Node", + "strict": true, + "declaration": true, + "sourceMap": true, + "noUnusedLocals": true, + "esModuleInterop": true, + "paths": { + "types/*": ["../vite/types/*"], + "vite": ["../vite/src/node/index.js"] + } + } +} diff --git a/packages/plugin-vue/api-extractor.json b/packages/plugin-vue/api-extractor.json deleted file mode 100644 index df6d6f9a4..000000000 --- a/packages/plugin-vue/api-extractor.json +++ /dev/null @@ -1,53 +0,0 @@ -{ - "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", - - "projectFolder": ".", - - "mainEntryPointFilePath": "./temp/index.d.ts", - - "dtsRollup": { - "enabled": true, - "untrimmedFilePath": "./dist/index.d.ts" - }, - - "apiReport": { - "enabled": false - }, - - "docModel": { - "enabled": false - }, - - "tsdocMetadata": { - "enabled": false - }, - - "messages": { - "compilerMessageReporting": { - "default": { - "logLevel": "warning" - } - }, - - "extractorMessageReporting": { - "default": { - "logLevel": "warning", - "addToApiReportFile": true - }, - - "ae-missing-release-tag": { - "logLevel": "none" - } - }, - - "tsdocMessageReporting": { - "default": { - "logLevel": "warning" - }, - - "tsdoc-undefined-tag": { - "logLevel": "none" - } - } - } -} diff --git a/packages/plugin-vue/build.config.ts b/packages/plugin-vue/build.config.ts new file mode 100644 index 000000000..4f9d811af --- /dev/null +++ b/packages/plugin-vue/build.config.ts @@ -0,0 +1,12 @@ +import { defineBuildConfig } from 'unbuild' + +export default defineBuildConfig({ + entries: ['src/index'], + externals: ['vite', 'vue/compiler-sfc', '@vue/compiler-sfc'], + clean: true, + declaration: true, + rollup: { + emitCJS: true, + inlineDependencies: true + } +}) diff --git a/packages/plugin-vue/package.json b/packages/plugin-vue/package.json index 22ce5ad55..6a08c1dff 100644 --- a/packages/plugin-vue/package.json +++ b/packages/plugin-vue/package.json @@ -6,17 +6,21 @@ "files": [ "dist" ], - "main": "dist/index.js", - "types": "dist/index.d.ts", + "main": "./dist/index.cjs", + "module": "./dist/index.mjs", + "types": "./dist/index.d.ts", + "exports": { + ".": { + "types": "./dist/index.d.ts", + "import": "./dist/index.mjs", + "require": "./dist/index.cjs" + } + }, "scripts": { - "dev": "rimraf dist && run-p dev-types dev-watch", - "dev-types": "tsc -p . -w --incremental --emitDeclarationOnly", - "dev-watch": "esbuild src/index.ts --watch --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js", - "build": "rimraf dist && run-s build-bundle build-types", - "build-bundle": "esbuild src/index.ts --bundle --platform=node --target=node12 --external:@vue/compiler-sfc --external:vue/compiler-sfc --external:vite --outfile=dist/index.js & npm run patch-dist", - "patch-dist": "ts-node ../../scripts/patchEsbuildDist.ts dist/index.js vuePlugin", - "build-types": "tsc -p . --emitDeclarationOnly --outDir temp && api-extractor run && rimraf temp", - "prepublishOnly": "(cd ../vite && npm run build) && npm run build" + "dev": "unbuild --stub", + "build": "unbuild && pnpm run patch-cjs", + "patch-cjs": "ts-node ../../scripts/patchCJS.ts", + "prepublishOnly": "npm run build" }, "engines": { "node": ">=14.6.0" @@ -40,6 +44,7 @@ "rollup": "^2.72.1", "slash": "^4.0.0", "source-map": "^0.6.1", - "vue": "^3.2.33" + "vue": "^3.2.33", + "vite": "workspace:*" } } diff --git a/packages/plugin-vue/src/index.ts b/packages/plugin-vue/src/index.ts index 7bdf63b70..6526f9413 100644 --- a/packages/plugin-vue/src/index.ts +++ b/packages/plugin-vue/src/index.ts @@ -18,7 +18,8 @@ import { transformTemplateAsModule } from './template' import { transformStyle } from './style' import { EXPORT_HELPER_ID, helperCode } from './helper' -export { parseVueRequest, VueQuery } from './utils/query' +export { parseVueRequest } from './utils/query' +export type { VueQuery } from './utils/query' export interface Options { include?: string | RegExp | (string | RegExp)[] @@ -250,10 +251,3 @@ export default function vuePlugin(rawOptions: Options = {}): Plugin { } } } - -// overwrite for cjs require('...')() usage -// The following lines are inserted by scripts/patchEsbuildDist.ts, -// this doesn't bundle correctly after esbuild 0.14.4 -// -// module.exports = vuePlugin -// vuePlugin['default'] = vuePlugin diff --git a/packages/plugin-vue/tsconfig.json b/packages/plugin-vue/tsconfig.json index fa388fd0d..6165780e1 100644 --- a/packages/plugin-vue/tsconfig.json +++ b/packages/plugin-vue/tsconfig.json @@ -14,9 +14,8 @@ "esModuleInterop": true, "baseUrl": ".", "paths": { - // vite typings uses custom paths that is patched into relative paths during build - // this is a shim that makes even dev-time vite typings work for plugin-vue - "types/*": ["../vite/types/*"] + "types/*": ["../vite/types/*"], + "vite": ["../vite/src/node/index.js"] } } } diff --git a/packages/vite/package.json b/packages/vite/package.json index b4a914795..7fa8f652b 100644 --- a/packages/vite/package.json +++ b/packages/vite/package.json @@ -30,11 +30,10 @@ "homepage": "https://github.com/vitejs/vite/tree/main/#readme", "scripts": { "dev": "rimraf dist && rollup -c -w", - "build": "rimraf dist && npm run lint && run-s build-bundle build-types", + "build": "rimraf dist && run-s build-bundle build-types", "build-bundle": "rollup -c", "build-types": "run-s build-temp-types patch-types roll-types", "build-temp-types": "tsc --emitDeclarationOnly --outDir temp/node -p src/node", - "ci-build": "rimraf dist && run-s build-bundle build-types", "patch-types": "ts-node scripts/patchTypes.ts", "roll-types": "api-extractor run && rimraf temp", "lint": "eslint --ext .ts src/**", diff --git a/playground/react-emotion/vite.config.ts b/playground/react-emotion/vite.config.ts index 9364c8f61..197e04f87 100644 --- a/playground/react-emotion/vite.config.ts +++ b/playground/react-emotion/vite.config.ts @@ -1,7 +1,7 @@ import react from '@vitejs/plugin-react' -import type { UserConfig } from 'vite' +import { defineConfig } from 'vite' -const config: UserConfig = { +export default defineConfig({ plugins: [ react({ jsxImportSource: '@emotion/react', @@ -15,6 +15,4 @@ const config: UserConfig = { // to make tests faster minify: false } -} - -export default config +}) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 56e40b2c5..b7c68fc69 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,6 +12,7 @@ importers: specifiers: '@microsoft/api-extractor': ^7.23.1 '@types/babel__core': ^7.1.19 + '@types/babel__standalone': ^7.1.4 '@types/convert-source-map': ^1.5.2 '@types/cross-spawn': ^6.0.2 '@types/debug': ^4.1.7 @@ -57,6 +58,7 @@ importers: sirv: ^2.0.2 ts-node: ^10.7.0 typescript: ^4.6.4 + unbuild: ^0.7.4 vite: workspace:* vitepress: ^0.22.4 vitest: ^0.12.4 @@ -64,6 +66,7 @@ importers: devDependencies: '@microsoft/api-extractor': 7.23.2 '@types/babel__core': 7.1.19 + '@types/babel__standalone': 7.1.4 '@types/convert-source-map': 1.5.2 '@types/cross-spawn': 6.0.2 '@types/debug': 4.1.7 @@ -109,6 +112,7 @@ importers: sirv: 2.0.2 ts-node: 10.7.0_sm5zkxj4s52nbddwl76qwfh6ya typescript: 4.6.4 + unbuild: 0.7.4 vite: link:packages/vite vitepress: 0.22.4 vitest: 0.12.4 @@ -126,17 +130,22 @@ importers: packages/plugin-legacy: specifiers: + '@babel/core': ^7.17.10 '@babel/standalone': ^7.17.11 core-js: ^3.22.4 magic-string: ^0.26.1 regenerator-runtime: ^0.13.9 systemjs: ^6.12.1 + vite: workspace:* dependencies: '@babel/standalone': 7.17.11 core-js: 3.22.5 magic-string: 0.26.1 regenerator-runtime: 0.13.9 systemjs: 6.12.1 + devDependencies: + '@babel/core': 7.17.10 + vite: link:../vite packages/plugin-react: specifiers: @@ -148,6 +157,7 @@ importers: '@rollup/pluginutils': ^4.2.1 react-refresh: ^0.13.0 resolve: ^1.22.0 + vite: workspace:* dependencies: '@babel/core': 7.17.10 '@babel/plugin-transform-react-jsx': 7.17.3_@babel+core@7.17.10 @@ -157,6 +167,8 @@ importers: '@rollup/pluginutils': 4.2.1 react-refresh: 0.13.0 resolve: 1.22.0 + devDependencies: + vite: link:../vite packages/plugin-vue: specifiers: @@ -165,6 +177,7 @@ importers: rollup: ^2.72.1 slash: ^4.0.0 source-map: ^0.6.1 + vite: workspace:* vue: ^3.2.33 devDependencies: '@rollup/pluginutils': 4.2.1 @@ -172,6 +185,7 @@ importers: rollup: 2.72.1 slash: 4.0.0 source-map: 0.6.1 + vite: link:../vite vue: 3.2.33 packages/plugin-vue-jsx: @@ -181,12 +195,15 @@ importers: '@babel/plugin-transform-typescript': ^7.16.8 '@rollup/pluginutils': ^4.2.1 '@vue/babel-plugin-jsx': ^1.1.1 + vite: workspace:* dependencies: '@babel/core': 7.17.10 '@babel/plugin-syntax-import-meta': 7.10.4_@babel+core@7.17.10 '@babel/plugin-transform-typescript': 7.16.8_@babel+core@7.17.10 '@rollup/pluginutils': 4.2.1 '@vue/babel-plugin-jsx': 1.1.1_@babel+core@7.17.10 + devDependencies: + vite: link:../vite packages/vite: specifiers: @@ -1109,7 +1126,6 @@ packages: /@babel/compat-data/7.17.10: resolution: {integrity: sha512-GZt/TCsG70Ms19gfZO1tM4CVnXsPgEPBCpJu+Qz3L0LUDsY5nZqFZglIoPC1kIYOtNBZlrnFT+klg12vFGZXrw==} engines: {node: '>=6.9.0'} - dev: false /@babel/core/7.17.10: resolution: {integrity: sha512-liKoppandF3ZcBnIYFjfSDHZLKdLHGJRkoWtG8zQyGJBQfIYobpnVGI5+pLBNtS6psFLDzyq8+h5HiVljW9PNA==} @@ -1132,7 +1148,6 @@ packages: semver: 6.3.0 transitivePeerDependencies: - supports-color - dev: false /@babel/generator/7.17.10: resolution: {integrity: sha512-46MJZZo9y3o4kmhBVc7zW7i8dtR1oIK/sdO5NcfcZRhTGYi+KKJRtHNgsU6c4VUcJmUNV/LQdebD/9Dlv4K+Tg==} @@ -1141,7 +1156,6 @@ packages: '@babel/types': 7.17.10 '@jridgewell/gen-mapping': 0.1.1 jsesc: 2.5.2 - dev: false /@babel/helper-annotate-as-pure/7.16.7: resolution: {integrity: sha512-s6t2w/IPQVTAET1HitoowRGXooX8mCgtuP5195wD/QJPV6wYjpujCGF7JuMODVX2ZAJOf1GT6DT9MHEZvLOFSw==} @@ -1161,7 +1175,6 @@ packages: '@babel/helper-validator-option': 7.16.7 browserslist: 4.20.3 semver: 6.3.0 - dev: false /@babel/helper-create-class-features-plugin/7.17.9_@babel+core@7.17.10: resolution: {integrity: sha512-kUjip3gruz6AJKOq5i3nC6CoCEEF/oHH3cp6tOZhB+IyyyPyW0g1Gfsxn3mkk6S08pIA2y8GQh609v9G/5sHVQ==} @@ -1186,7 +1199,6 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/types': 7.17.10 - dev: false /@babel/helper-function-name/7.17.9: resolution: {integrity: sha512-7cRisGlVtiVqZ0MW0/yFB4atgpGLWEHUVYnb448hZK4x+vih0YO5UoS11XIYtZYqHd0dIPMdUSv8q5K4LdMnIg==} @@ -1194,14 +1206,12 @@ packages: dependencies: '@babel/template': 7.16.7 '@babel/types': 7.17.10 - dev: false /@babel/helper-hoist-variables/7.16.7: resolution: {integrity: sha512-m04d/0Op34H5v7pbZw6pSKP7weA6lsMvfiIAMeIvkY/R4xQtBSMFEigu9QTZ2qB/9l22vsxtM8a+Q8CzD255fg==} engines: {node: '>=6.9.0'} dependencies: '@babel/types': 7.17.10 - dev: false /@babel/helper-member-expression-to-functions/7.17.7: resolution: {integrity: sha512-thxXgnQ8qQ11W2wVUObIqDL4p148VMxkt5T/qpN5k2fboRyzFGFmKsTGViquyM5QHKUy48OZoca8kw4ajaDPyw==} @@ -1230,7 +1240,6 @@ packages: '@babel/types': 7.17.10 transitivePeerDependencies: - supports-color - dev: false /@babel/helper-optimise-call-expression/7.16.7: resolution: {integrity: sha512-EtgBhg7rd/JcnpZFXpBy0ze1YRfdm7BnBX4uKMBd3ixa3RGAE002JZB66FJyNH7g0F38U05pXmA5P8cBh7z+1w==} @@ -1261,14 +1270,12 @@ packages: engines: {node: '>=6.9.0'} dependencies: '@babel/types': 7.17.10 - dev: false /@babel/helper-split-export-declaration/7.16.7: resolution: {integrity: sha512-xbWoy/PFoxSWazIToT9Sif+jJTlrMcndIsaOKvTA6u7QEo7ilkRZpjew18/W3c7nm8fXdUDXh02VXTbZ0pGDNw==} engines: {node: '>=6.9.0'} dependencies: '@babel/types': 7.17.10 - dev: false /@babel/helper-validator-identifier/7.16.7: resolution: {integrity: sha512-hsEnFemeiW4D08A5gUAZxLBTXpZ39P+a+DGDsHw1yxqyQ/jzFEnxf5uTEGp+3bzAbNOxU1paTgYS4ECU/IgfDw==} @@ -1277,7 +1284,6 @@ packages: /@babel/helper-validator-option/7.16.7: resolution: {integrity: sha512-TRtenOuRUVo9oIQGPC5G9DgK4743cdxvtOw0weQNpZXaS16SCBi5MNjZF8vba3ETURjZpTbVn7Vvcf2eAwFozQ==} engines: {node: '>=6.9.0'} - dev: false /@babel/helpers/7.17.9: resolution: {integrity: sha512-cPCt915ShDWUEzEp3+UNRktO2n6v49l5RSnG9M5pS24hA+2FAc5si+Pn1i4VVbQQ+jh+bIZhPFQOJOzbrOYY1Q==} @@ -1288,7 +1294,6 @@ packages: '@babel/types': 7.17.10 transitivePeerDependencies: - supports-color - dev: false /@babel/highlight/7.17.9: resolution: {integrity: sha512-J9PfEKCbFIv2X5bjTMiZu6Vf341N05QIY+d6FvVKynkG1S7G0j3I0QoRtWIrXhZ+/Nlb5Q0MzqL7TokEJ5BNHg==} @@ -1428,7 +1433,6 @@ packages: /@babel/standalone/7.17.11: resolution: {integrity: sha512-47wVYBeTktYHwtzlFuK7qqV/H5X6mU4MUNqpQ9iiJOqnP8rWL0eX0GWLKRsv8D8suYzhuS1K/dtwgGr+26U7Gg==} engines: {node: '>=6.9.0'} - dev: false /@babel/template/7.16.7: resolution: {integrity: sha512-I8j/x8kHUrbYRTUxXrrMbfCa7jxkE7tZre39x3kjr9hvI82cK1FfqLygotcWN5kdPGWcLdWMHpSBavse5tWw3w==} @@ -1437,7 +1441,6 @@ packages: '@babel/code-frame': 7.16.7 '@babel/parser': 7.17.10 '@babel/types': 7.17.10 - dev: false /@babel/traverse/7.17.10: resolution: {integrity: sha512-VmbrTHQteIdUUQNTb+zE12SHS/xQVIShmBPhlNP12hD5poF2pbITW1Z4172d03HegaQWhLffdkRJYtAzp0AGcw==} @@ -1455,7 +1458,6 @@ packages: globals: 11.12.0 transitivePeerDependencies: - supports-color - dev: false /@babel/types/7.17.10: resolution: {integrity: sha512-9O26jG0mBYfGkUYCYZRnBwbVLd1UZOICEr2Em6InB6jVfsAv1GKgwXHmrSg+WFWDmeKTA6vyTZiN8tCSM5Oo3A==} @@ -1834,6 +1836,16 @@ packages: rollup: 2.72.1 dev: true + /@rollup/plugin-replace/4.0.0_rollup@2.72.1: + resolution: {integrity: sha512-+rumQFiaNac9y64OHtkHGmdjm7us9bo1PlbgQfdihQtuNxzjpaB064HbRnewUOggLQxVCCyINfStkgmBeQpv1g==} + peerDependencies: + rollup: ^1.20.0 || ^2.0.0 + dependencies: + '@rollup/pluginutils': 3.1.0_rollup@2.72.1 + magic-string: 0.25.9 + rollup: 2.72.1 + dev: true + /@rollup/plugin-typescript/8.3.2_rollup@2.72.1+tslib@2.4.0: resolution: {integrity: sha512-MtgyR5LNHZr3GyN0tM7gNO9D0CS+Y+vflS4v/PHmrX17JCkHUYKvQ5jN5o3cz1YKllM3duXUqu3yOHwMPUxhDg==} engines: {node: '>=8.0.0'} @@ -1937,6 +1949,14 @@ packages: '@babel/types': 7.17.10 dev: true + /@types/babel__standalone/7.1.4: + resolution: {integrity: sha512-HijIDmcNl3Wmo0guqjYkQvMzyRCM6zMCkYcdG8f+2X7mPBNa9ikSeaQlWs2Yg18KN1klOJzyupX5BPOf+7ahaw==} + dependencies: + '@babel/core': 7.17.10 + transitivePeerDependencies: + - supports-color + dev: true + /@types/babel__template/7.4.1: resolution: {integrity: sha512-azBFKemX6kMg5Io+/rdGT0dkGreboUVR0Cdm3fz9QJWpaQGJRQXl7C+6hOTCZcMll7KFyEQpgbYI2lHdsS4U7g==} dependencies: @@ -2686,7 +2706,6 @@ packages: escalade: 3.1.1 node-releases: 2.0.4 picocolors: 1.0.0 - dev: false /buffer-crc32/0.2.13: resolution: {integrity: sha1-DTM+PwDqxQqhRUq9MO+MKl2ackI=} @@ -2759,7 +2778,6 @@ packages: /caniuse-lite/1.0.30001339: resolution: {integrity: sha512-Es8PiVqCe+uXdms0Gu5xP5PF2bxLR7OBp3wUzUnuO7OHzhOfCyg3hdiGWVPVxhiuniOzng+hTc1u3fEQ0TlkSQ==} - dev: false /chai/4.3.6: resolution: {integrity: sha512-bbcp3YfHCUzMOvKqsztczerVgBKSsEijCySNlHHbX3VG1nskvqjz5Rfso1gGwD6w6oOV3eI60pKuMOV5MV7p3Q==} @@ -2789,6 +2807,11 @@ packages: ansi-styles: 4.3.0 supports-color: 7.2.0 + /chalk/5.0.1: + resolution: {integrity: sha512-Fo07WOYGqMfCWHOzSXOt2CxDbC6skS/jO9ynEcmpANMoPrD+W1r1K6Vx7iNm+AQmETU1Xr2t+n8nzkV9t6xh3w==} + engines: {node: ^12.17.0 || ^14.13 || >=16.0.0} + dev: true + /character-parser/2.2.0: resolution: {integrity: sha1-x84o821LzZdE5f/CxfzeHHMmH8A=} dependencies: @@ -2939,6 +2962,7 @@ packages: /commander/2.20.3: resolution: {integrity: sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==} + requiresBuild: true dev: true /commander/7.2.0: @@ -3017,6 +3041,10 @@ packages: - supports-color dev: true + /consola/2.15.3: + resolution: {integrity: sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==} + dev: true + /console-control-strings/1.1.0: resolution: {integrity: sha1-PXz0Rk22RG6mRL9LOVB/mFEAjo4=} dev: false @@ -3467,6 +3495,14 @@ packages: resolution: {integrity: sha1-yY2bzvdWdBiOEQlpFRGZ45sfppM=} dev: false + /defu/5.0.1: + resolution: {integrity: sha512-EPS1carKg+dkEVy3qNTqIdp2qV7mUP08nIsupfwQpz++slCVRw7qbQyWvSTig+kFPwz2XXp5/kIIkH+CwrJKkQ==} + dev: true + + /defu/6.0.0: + resolution: {integrity: sha512-t2MZGLf1V2rV4VBZbWIaXKdX/mUcYW0n2znQZoADBkGGxYL8EWqCuCZBmJPJ/Yy9fofJkyuuSuo5GSwo0XdEgw==} + dev: true + /delegate/3.2.0: resolution: {integrity: sha512-IofjkYBZaZivn0V8nnsMJGBr4jVLxHDheKSW88PyxS5QC4Vo9ZbZVvhzlSxY87fVq3STR6r+4cGepyHkcWOQSw==} dev: false @@ -3581,7 +3617,6 @@ packages: /electron-to-chromium/1.4.137: resolution: {integrity: sha512-0Rcpald12O11BUogJagX3HsCN3FE83DSqWjgXoHo5a72KUKMSfI39XBgJpgNNxS9fuGzytaFjE06kZkiVFy2qA==} - dev: false /emoji-regex/8.0.0: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} @@ -3653,6 +3688,10 @@ packages: resolution: {integrity: sha512-+7IwY/kiGAacQfY+YBhKMvEmyAJnw5grTUgjG85Pe7vcUI/6b7pZjZG8nQ7+48YhzEAEqrEgD2dCz/JIK+AYvw==} dev: true + /es-module-lexer/0.9.3: + resolution: {integrity: sha512-1HQ2M2sPtxwnvOvT1ZClHyQDiggdNjURWpY2we6aMKCQiUVxTmVs2UYPLIrD84sS+kMdUwfBSylbJPwNnBrnHQ==} + dev: true + /es-shim-unscopables/1.0.0: resolution: {integrity: sha512-Jm6GPcCdC30eMLbZ2x8z2WuRwAws3zTBBKuusffYVUrNj/GVSUAZ+xKMaUpfNDR5IbyNA5LJbaecoUVbmUcB1w==} dependencies: @@ -3699,6 +3738,14 @@ packages: requiresBuild: true optional: true + /esbuild-android-arm64/0.13.15: + resolution: {integrity: sha512-m602nft/XXeO8YQPUDVoHfjyRVPdPgjyyXOxZ44MK/agewFFkPa8tUo6lAzSWh5Ui5PB4KR9UIFTSBKh/RrCmg==} + cpu: [arm64] + os: [android] + requiresBuild: true + dev: true + optional: true + /esbuild-android-arm64/0.14.38: resolution: {integrity: sha512-L2NgQRWuHFI89IIZIlpAcINy9FvBk6xFVZ7xGdOwIm8VyhX1vNCEqUJO3DPSSy945Gzdg98cxtNt8Grv1CsyhA==} engines: {node: '>=12'} @@ -3707,6 +3754,14 @@ packages: requiresBuild: true optional: true + /esbuild-darwin-64/0.13.15: + resolution: {integrity: sha512-ihOQRGs2yyp7t5bArCwnvn2Atr6X4axqPpEdCFPVp7iUj4cVSdisgvEKdNR7yH3JDjW6aQDw40iQFoTqejqxvQ==} + cpu: [x64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-64/0.14.38: resolution: {integrity: sha512-5JJvgXkX87Pd1Og0u/NJuO7TSqAikAcQQ74gyJ87bqWRVeouky84ICoV4sN6VV53aTW+NE87qLdGY4QA2S7KNA==} engines: {node: '>=12'} @@ -3715,6 +3770,14 @@ packages: requiresBuild: true optional: true + /esbuild-darwin-arm64/0.13.15: + resolution: {integrity: sha512-i1FZssTVxUqNlJ6cBTj5YQj4imWy3m49RZRnHhLpefFIh0To05ow9DTrXROTE1urGTQCloFUXTX8QfGJy1P8dQ==} + cpu: [arm64] + os: [darwin] + requiresBuild: true + dev: true + optional: true + /esbuild-darwin-arm64/0.14.38: resolution: {integrity: sha512-eqF+OejMI3mC5Dlo9Kdq/Ilbki9sQBw3QlHW3wjLmsLh+quNfHmGMp3Ly1eWm981iGBMdbtSS9+LRvR2T8B3eQ==} engines: {node: '>=12'} @@ -3723,6 +3786,14 @@ packages: requiresBuild: true optional: true + /esbuild-freebsd-64/0.13.15: + resolution: {integrity: sha512-G3dLBXUI6lC6Z09/x+WtXBXbOYQZ0E8TDBqvn7aMaOCzryJs8LyVXKY4CPnHFXZAbSwkCbqiPuSQ1+HhrNk7EA==} + cpu: [x64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-64/0.14.38: resolution: {integrity: sha512-epnPbhZUt93xV5cgeY36ZxPXDsQeO55DppzsIgWM8vgiG/Rz+qYDLmh5ts3e+Ln1wA9dQ+nZmVHw+RjaW3I5Ig==} engines: {node: '>=12'} @@ -3731,6 +3802,14 @@ packages: requiresBuild: true optional: true + /esbuild-freebsd-arm64/0.13.15: + resolution: {integrity: sha512-KJx0fzEDf1uhNOZQStV4ujg30WlnwqUASaGSFPhznLM/bbheu9HhqZ6mJJZM32lkyfGJikw0jg7v3S0oAvtvQQ==} + cpu: [arm64] + os: [freebsd] + requiresBuild: true + dev: true + optional: true + /esbuild-freebsd-arm64/0.14.38: resolution: {integrity: sha512-/9icXUYJWherhk+y5fjPI5yNUdFPtXHQlwP7/K/zg8t8lQdHVj20SqU9/udQmeUo5pDFHMYzcEFfJqgOVeKNNQ==} engines: {node: '>=12'} @@ -3739,6 +3818,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-32/0.13.15: + resolution: {integrity: sha512-ZvTBPk0YWCLMCXiFmD5EUtB30zIPvC5Itxz0mdTu/xZBbbHJftQgLWY49wEPSn2T/TxahYCRDWun5smRa0Tu+g==} + cpu: [ia32] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-32/0.14.38: resolution: {integrity: sha512-QfgfeNHRFvr2XeHFzP8kOZVnal3QvST3A0cgq32ZrHjSMFTdgXhMhmWdKzRXP/PKcfv3e2OW9tT9PpcjNvaq6g==} engines: {node: '>=12'} @@ -3747,6 +3834,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-64/0.13.15: + resolution: {integrity: sha512-eCKzkNSLywNeQTRBxJRQ0jxRCl2YWdMB3+PkWFo2BBQYC5mISLIVIjThNtn6HUNqua1pnvgP5xX0nHbZbPj5oA==} + cpu: [x64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-64/0.14.38: resolution: {integrity: sha512-uuZHNmqcs+Bj1qiW9k/HZU3FtIHmYiuxZ/6Aa+/KHb/pFKr7R3aVqvxlAudYI9Fw3St0VCPfv7QBpUITSmBR1Q==} engines: {node: '>=12'} @@ -3755,6 +3850,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-arm/0.13.15: + resolution: {integrity: sha512-wUHttDi/ol0tD8ZgUMDH8Ef7IbDX+/UsWJOXaAyTdkT7Yy9ZBqPg8bgB/Dn3CZ9SBpNieozrPRHm0BGww7W/jA==} + cpu: [arm] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm/0.14.38: resolution: {integrity: sha512-FiFvQe8J3VKTDXG01JbvoVRXQ0x6UZwyrU4IaLBZeq39Bsbatd94Fuc3F1RGqPF5RbIWW7RvkVQjn79ejzysnA==} engines: {node: '>=12'} @@ -3763,6 +3866,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-arm64/0.13.15: + resolution: {integrity: sha512-bYpuUlN6qYU9slzr/ltyLTR9YTBS7qUDymO8SV7kjeNext61OdmqFAzuVZom+OLW1HPHseBfJ/JfdSlx8oTUoA==} + cpu: [arm64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-arm64/0.14.38: resolution: {integrity: sha512-HlMGZTEsBrXrivr64eZ/EO0NQM8H8DuSENRok9d+Jtvq8hOLzrxfsAT9U94K3KOGk2XgCmkaI2KD8hX7F97lvA==} engines: {node: '>=12'} @@ -3771,6 +3882,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-mips64le/0.13.15: + resolution: {integrity: sha512-KlVjIG828uFPyJkO/8gKwy9RbXhCEUeFsCGOJBepUlpa7G8/SeZgncUEz/tOOUJTcWMTmFMtdd3GElGyAtbSWg==} + cpu: [mips64el] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-mips64le/0.14.38: resolution: {integrity: sha512-qd1dLf2v7QBiI5wwfil9j0HG/5YMFBAmMVmdeokbNAMbcg49p25t6IlJFXAeLzogv1AvgaXRXvgFNhScYEUXGQ==} engines: {node: '>=12'} @@ -3779,6 +3898,14 @@ packages: requiresBuild: true optional: true + /esbuild-linux-ppc64le/0.13.15: + resolution: {integrity: sha512-h6gYF+OsaqEuBjeesTBtUPw0bmiDu7eAeuc2OEH9S6mV9/jPhPdhOWzdeshb0BskRZxPhxPOjqZ+/OqLcxQwEQ==} + cpu: [ppc64] + os: [linux] + requiresBuild: true + dev: true + optional: true + /esbuild-linux-ppc64le/0.14.38: resolution: {integrity: sha512-mnbEm7o69gTl60jSuK+nn+pRsRHGtDPfzhrqEUXyCl7CTOCLtWN2bhK8bgsdp6J/2NyS/wHBjs1x8aBWwP2X9Q==} engines: {node: '>=12'} @@ -3803,6 +3930,14 @@ packages: requiresBuild: true optional: true + /esbuild-netbsd-64/0.13.15: + resolution: {integrity: sha512-3+yE9emwoevLMyvu+iR3rsa+Xwhie7ZEHMGDQ6dkqP/ndFzRHkobHUKTe+NCApSqG5ce2z4rFu+NX/UHnxlh3w==} + cpu: [x64] + os: [netbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-netbsd-64/0.14.38: resolution: {integrity: sha512-cljBAApVwkpnJZfnRVThpRBGzCi+a+V9Ofb1fVkKhtrPLDYlHLrSYGtmnoTVWDQdU516qYI8+wOgcGZ4XIZh0Q==} engines: {node: '>=12'} @@ -3811,6 +3946,14 @@ packages: requiresBuild: true optional: true + /esbuild-openbsd-64/0.13.15: + resolution: {integrity: sha512-wTfvtwYJYAFL1fSs8yHIdf5GEE4NkbtbXtjLWjM3Cw8mmQKqsg8kTiqJ9NJQe5NX/5Qlo7Xd9r1yKMMkHllp5g==} + cpu: [x64] + os: [openbsd] + requiresBuild: true + dev: true + optional: true + /esbuild-openbsd-64/0.14.38: resolution: {integrity: sha512-CDswYr2PWPGEPpLDUO50mL3WO/07EMjnZDNKpmaxUPsrW+kVM3LoAqr/CE8UbzugpEiflYqJsGPLirThRB18IQ==} engines: {node: '>=12'} @@ -3819,6 +3962,14 @@ packages: requiresBuild: true optional: true + /esbuild-sunos-64/0.13.15: + resolution: {integrity: sha512-lbivT9Bx3t1iWWrSnGyBP9ODriEvWDRiweAs69vI+miJoeKwHWOComSRukttbuzjZ8r1q0mQJ8Z7yUsDJ3hKdw==} + cpu: [x64] + os: [sunos] + requiresBuild: true + dev: true + optional: true + /esbuild-sunos-64/0.14.38: resolution: {integrity: sha512-2mfIoYW58gKcC3bck0j7lD3RZkqYA7MmujFYmSn9l6TiIcAMpuEvqksO+ntBgbLep/eyjpgdplF7b+4T9VJGOA==} engines: {node: '>=12'} @@ -3827,6 +3978,14 @@ packages: requiresBuild: true optional: true + /esbuild-windows-32/0.13.15: + resolution: {integrity: sha512-fDMEf2g3SsJ599MBr50cY5ve5lP1wyVwTe6aLJsM01KtxyKkB4UT+fc5MXQFn3RLrAIAZOG+tHC+yXObpSn7Nw==} + cpu: [ia32] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-32/0.14.38: resolution: {integrity: sha512-L2BmEeFZATAvU+FJzJiRLFUP+d9RHN+QXpgaOrs2klshoAm1AE6Us4X6fS9k33Uy5SzScn2TpcgecbqJza1Hjw==} engines: {node: '>=12'} @@ -3835,6 +3994,14 @@ packages: requiresBuild: true optional: true + /esbuild-windows-64/0.13.15: + resolution: {integrity: sha512-9aMsPRGDWCd3bGjUIKG/ZOJPKsiztlxl/Q3C1XDswO6eNX/Jtwu4M+jb6YDH9hRSUflQWX0XKAfWzgy5Wk54JQ==} + cpu: [x64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-64/0.14.38: resolution: {integrity: sha512-Khy4wVmebnzue8aeSXLC+6clo/hRYeNIm0DyikoEqX+3w3rcvrhzpoix0S+MF9vzh6JFskkIGD7Zx47ODJNyCw==} engines: {node: '>=12'} @@ -3843,6 +4010,14 @@ packages: requiresBuild: true optional: true + /esbuild-windows-arm64/0.13.15: + resolution: {integrity: sha512-zzvyCVVpbwQQATaf3IG8mu1IwGEiDxKkYUdA4FpoCHi1KtPa13jeScYDjlW0Qh+ebWzpKfR2ZwvqAQkSWNcKjA==} + cpu: [arm64] + os: [win32] + requiresBuild: true + dev: true + optional: true + /esbuild-windows-arm64/0.14.38: resolution: {integrity: sha512-k3FGCNmHBkqdJXuJszdWciAH77PukEyDsdIryEHn9cKLQFxzhT39dSumeTuggaQcXY57UlmLGIkklWZo2qzHpw==} engines: {node: '>=12'} @@ -3851,6 +4026,30 @@ packages: requiresBuild: true optional: true + /esbuild/0.13.15: + resolution: {integrity: sha512-raCxt02HBKv8RJxE8vkTSCXGIyKHdEdGfUmiYb8wnabnaEmHzyW7DCHb5tEN0xU8ryqg5xw54mcwnYkC4x3AIw==} + hasBin: true + requiresBuild: true + optionalDependencies: + esbuild-android-arm64: 0.13.15 + esbuild-darwin-64: 0.13.15 + esbuild-darwin-arm64: 0.13.15 + esbuild-freebsd-64: 0.13.15 + esbuild-freebsd-arm64: 0.13.15 + esbuild-linux-32: 0.13.15 + esbuild-linux-64: 0.13.15 + esbuild-linux-arm: 0.13.15 + esbuild-linux-arm64: 0.13.15 + esbuild-linux-mips64le: 0.13.15 + esbuild-linux-ppc64le: 0.13.15 + esbuild-netbsd-64: 0.13.15 + esbuild-openbsd-64: 0.13.15 + esbuild-sunos-64: 0.13.15 + esbuild-windows-32: 0.13.15 + esbuild-windows-64: 0.13.15 + esbuild-windows-arm64: 0.13.15 + dev: true + /esbuild/0.14.38: resolution: {integrity: sha512-12fzJ0fsm7gVZX1YQ1InkOE5f9Tl7cgf6JPYXRJtPIoE0zkWAbHdPHVPPaLi9tYAcEBqheGzqLn/3RdTOyBfcA==} engines: {node: '>=12'} @@ -4436,7 +4635,6 @@ packages: /gensync/1.0.0-beta.2: resolution: {integrity: sha512-3hN7NaskYvMDLQY55gnW3NQ+mesEAepTqlg+VEbj7zzqEMBVNhzcGYYeqFo/TlYz6eQiFcp1HcsCZO+nGgS8zg==} engines: {node: '>=6.9.0'} - dev: false /get-caller-file/2.0.5: resolution: {integrity: sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==} @@ -4550,7 +4748,6 @@ packages: /globals/11.12.0: resolution: {integrity: sha512-WOBp/EEGUiIsJSp7wcv/y6MO+lV9UoncWqxuFfm8eBwzWNgyfBd6Gz+IeKQ9jCmyhoH99g15M3T+QaVHFjizVA==} engines: {node: '>=4'} - dev: false /globals/13.14.0: resolution: {integrity: sha512-ERO68sOYwm5UuLvSJTY7w7NP2c8S4UcXs3X1GBX8cwOr+ShOcDBbCY5mH4zxz0jsYCdJ8ve8Mv9n2YGJMB1aeg==} @@ -4664,6 +4861,10 @@ packages: react-is: 16.13.1 dev: false + /hookable/5.1.1: + resolution: {integrity: sha512-7qam9XBFb+DijNBthaL1k/7lHU2TEMZkWSyuqmU3sCQze1wFm5w9AlEx30PD7a+QVAjOy6Ec2goFwe1YVyk2uA==} + dev: true + /hosted-git-info/2.8.9: resolution: {integrity: sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==} dev: true @@ -5048,10 +5249,20 @@ packages: resolution: {integrity: sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=} dev: true + /jiti/1.13.0: + resolution: {integrity: sha512-/n9mNxZj/HDSrincJ6RP+L+yXbpnB8FybySBa+IjIaoH9FIxBbrbRT5XUbe8R7zuVM2AQqNMNDDqz0bzx3znOQ==} + hasBin: true + dev: true + /jju/1.4.0: resolution: {integrity: sha1-o6vicYryQaKykE+EpiWXDzia4yo=} dev: true + /joycon/3.1.1: + resolution: {integrity: sha512-34wB/Y7MW7bzjKRjUKTa46I2Z7eV62Rkhva+KkopW7Qvv/OSWBqvkSY7vusOPrNuZcUG3tApvdVgNB8POj3SPw==} + engines: {node: '>=10'} + dev: true + /jpeg-js/0.4.3: resolution: {integrity: sha512-ru1HWKek8octvUHFHvE5ZzQ1yAsJmIvRdGWvSoKV52XKyuyYA437QWDttXT8eZXDSbuMpHlLzPDZUPd6idIz+Q==} dev: true @@ -5074,7 +5285,6 @@ packages: resolution: {integrity: sha512-OYu7XEzjkCQ3C5Ps3QIZsQfNpqoJyZZA99wd9aWd05NCtC5pWOkShK2mkL6HXQR6/Cy2lbNdPlZBpuQHXE63gA==} engines: {node: '>=4'} hasBin: true - dev: false /json-parse-better-errors/1.0.2: resolution: {integrity: sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==} @@ -5107,6 +5317,10 @@ packages: engines: {node: '>=6'} hasBin: true + /jsonc-parser/3.0.0: + resolution: {integrity: sha512-fQzRfAbIBnR0IQvftw9FJveWiHp72Fg20giDrHz6TdfB12UH/uue0D3hm57UB5KgAVuniLMCaS8P1IMj9NR7cA==} + dev: true + /jsonfile/4.0.0: resolution: {integrity: sha1-h3Gq4HmbZAdrdmQPygWPnBDjPss=} optionalDependencies: @@ -5590,6 +5804,36 @@ packages: engines: {node: '>=10'} hasBin: true + /mkdist/0.3.10_typescript@4.6.4: + resolution: {integrity: sha512-Aoc6hjILr2JPUJU2OUvBiD5sZ/CG1FeiXwk6KKPqE0iSTjBCrjrVK/fP5ig+TB3AKHvh2aA2QXXGeXVCJBdSwg==} + hasBin: true + peerDependencies: + typescript: '>=3.7' + peerDependenciesMeta: + typescript: + optional: true + dependencies: + defu: 5.0.1 + esbuild: 0.13.15 + fs-extra: 10.1.0 + globby: 11.1.0 + jiti: 1.13.0 + mri: 1.2.0 + pathe: 0.2.0 + typescript: 4.6.4 + dev: true + + /mlly/0.3.19: + resolution: {integrity: sha512-zMq5n3cOf4fOzA4WoeulxagbAgMChdev3MgP6K51k7M0u2whTXxupfIY4VVzws4vxkiWhwH1rVQcsw7zDGfRhA==} + dev: true + + /mlly/0.5.2: + resolution: {integrity: sha512-4GTELSSErv6ZZJYU98fZNuIBJcXSz+ktHdRrCYEqU1m6ZlebOCG0jwZ+IEd9vOrbpYsVBBMC5OTrEyLnKRcauQ==} + dependencies: + pathe: 0.2.0 + pkg-types: 0.3.2 + dev: true + /modern-normalize/1.1.0: resolution: {integrity: sha512-2lMlY1Yc1+CUy0gw4H95uNN7vjbpoED7NNRSBHE25nWfLBdmMzFCsPshlzbxHz+gYMcBEUN8V4pU16prcdPSgA==} engines: {node: '>=6'} @@ -5604,6 +5848,11 @@ packages: resolution: {integrity: sha512-UgzG4rvxYpN15jgCmVJwac49h9ly9NurikMWGPdVxm8GZD6XjkKPxDTjQQ43gtGgnV3X0cAyWDdP2Wexoquifg==} dev: true + /mri/1.2.0: + resolution: {integrity: sha512-tzzskb3bG8LvYGFF/mDTpq3jpI6Q9wc3LEmBaghu+DdCssd1FakN7Bc0hVNmEyGq1bq3RgfkCb3cmQLpNPOroA==} + engines: {node: '>=4'} + dev: true + /mrmime/1.0.0: resolution: {integrity: sha512-a70zx7zFfVO7XpnQ2IX1Myh9yY4UYvfld/dikWRnsXxbyvMcfz+u6UfgNAtH+k2QqtJuzVpv6eLTx1G2+WKZbQ==} engines: {node: '>=10'} @@ -5707,7 +5956,6 @@ packages: /node-releases/2.0.4: resolution: {integrity: sha512-gbMzqQtTtDz/00jQzZ21PQzdI9PyLYqUSvD0p3naOhX4odFji0ZxYdnVwPTxmSwkmxhcFImpozceidSG+AgoPQ==} - dev: false /nopt/5.0.0: resolution: {integrity: sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==} @@ -6021,6 +6269,10 @@ packages: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} + /pathe/0.2.0: + resolution: {integrity: sha512-sTitTPYnn23esFR3RlqYBWn4c45WGeLcsKzQiUpXJAyfcWkolvlYpV8FLo7JishK946oQwMFUCHXQ9AjGPKExw==} + dev: true + /pathval/1.1.1: resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} dev: true @@ -6082,6 +6334,14 @@ packages: pngjs: 4.0.1 dev: true + /pkg-types/0.3.2: + resolution: {integrity: sha512-eBYzX/7NYsQEOR2alWY4rnQB49G62oHzFpoi9Som56aUr8vB8UGcmcIia9v8fpBeuhH3Ltentuk2OGpp4IQV3Q==} + dependencies: + jsonc-parser: 3.0.0 + mlly: 0.3.19 + pathe: 0.2.0 + dev: true + /playwright-chromium/1.21.1: resolution: {integrity: sha512-bbqFFpcTs+3amiofja/KvTmZ+FZnMNEOuGkRyJk2p6DV9EbgRYVrlzzgLtMnX2DwaX3ZZ23MukGuQ+bVKOdsnw==} engines: {node: '>=12'} @@ -6325,6 +6585,11 @@ packages: hasBin: true dev: true + /pretty-bytes/6.0.0: + resolution: {integrity: sha512-6UqkYefdogmzqAZWzJ7laYeJnaXDy2/J+ZqiiMtS7t7OfpXWTlaeGMwX8U6EFvPV/YWWEKRkS8hKS4k60WHTOg==} + engines: {node: ^14.13.1 || >=16.0.0} + dev: true + /pretty-hrtime/1.0.3: resolution: {integrity: sha1-t+PqQkNaTJsnWdmeDyAesZWALuE=} engines: {node: '>= 0.8'} @@ -6834,6 +7099,38 @@ packages: dependencies: glob: 7.2.0 + /rollup-plugin-dts/4.2.1_pz6niy2zrvqhgxfup3pdyir4yu: + resolution: {integrity: sha512-eaxQZNUJ5iQcxNGlpJ1CUgG4OSVqWjDZ3nNSWBIoGrpcote2aNphSe1RJOaSYkb8dwn3o+rYm1vvld/5z3EGSQ==} + engines: {node: '>=v12.22.11'} + peerDependencies: + rollup: ^2.70 + typescript: ^4.6 + dependencies: + magic-string: 0.26.1 + rollup: 2.72.1 + typescript: 4.6.4 + optionalDependencies: + '@babel/code-frame': 7.16.7 + dev: true + + /rollup-plugin-esbuild/4.9.1_pnyrwy4zazm4ltxxkdqkpc4vuy: + resolution: {integrity: sha512-qn/x7Wz9p3Xnva99qcb+nopH0d2VJwVnsxJTGEg+Sh2Z3tqQl33MhOwzekVo1YTKgv+yAmosjcBRJygMfGrtLw==} + engines: {node: '>=12'} + peerDependencies: + esbuild: '>=0.10.1' + rollup: ^1.20.0 || ^2.0.0 + dependencies: + '@rollup/pluginutils': 4.2.1 + debug: 4.3.4 + es-module-lexer: 0.9.3 + esbuild: 0.14.38 + joycon: 3.1.1 + jsonc-parser: 3.0.0 + rollup: 2.72.1 + transitivePeerDependencies: + - supports-color + dev: true + /rollup-plugin-license/2.7.0_rollup@2.72.1: resolution: {integrity: sha512-0H1Fbuf85rvpadpmAaairdahzQHY0zHtcXkOFV5EStjX9aMCO2Hz5AQp/zZe+K/PB3o6As7R9uzcb8Pw1K94dg==} engines: {node: '>=10.0.0'} @@ -6907,6 +7204,10 @@ packages: object-assign: 4.1.1 dev: false + /scule/0.2.1: + resolution: {integrity: sha512-M9gnWtn3J0W+UhJOHmBxBTwv8mZCan5i1Himp60t6vvZcor0wr+IM0URKmIglsWJ7bRujNAVVN77fp+uZaWoKg==} + dev: true + /select/1.1.2: resolution: {integrity: sha1-DnNQrN7ICxEIUoeG7B1EGNEbOW0=} dev: false @@ -7854,6 +8155,41 @@ packages: which-boxed-primitive: 1.0.2 dev: true + /unbuild/0.7.4: + resolution: {integrity: sha512-gJvfMw4h5Q7xieMCeW/d3wtNKZDpFyDR9651s8kL+AGp95sMNhAFRLxy24AUKC3b5EQbB74vaDoU5R+XwsZC6A==} + hasBin: true + dependencies: + '@rollup/plugin-alias': 3.1.9_rollup@2.72.1 + '@rollup/plugin-commonjs': 21.1.0_rollup@2.72.1 + '@rollup/plugin-json': 4.1.0_rollup@2.72.1 + '@rollup/plugin-node-resolve': 13.2.1_rollup@2.72.1 + '@rollup/plugin-replace': 4.0.0_rollup@2.72.1 + '@rollup/pluginutils': 4.2.1 + chalk: 5.0.1 + consola: 2.15.3 + defu: 6.0.0 + esbuild: 0.14.38 + hookable: 5.1.1 + jiti: 1.13.0 + magic-string: 0.26.1 + mkdirp: 1.0.4 + mkdist: 0.3.10_typescript@4.6.4 + mlly: 0.5.2 + mri: 1.2.0 + pathe: 0.2.0 + pkg-types: 0.3.2 + pretty-bytes: 6.0.0 + rimraf: 3.0.2 + rollup: 2.72.1 + rollup-plugin-dts: 4.2.1_pz6niy2zrvqhgxfup3pdyir4yu + rollup-plugin-esbuild: 4.9.1_pnyrwy4zazm4ltxxkdqkpc4vuy + scule: 0.2.1 + typescript: 4.6.4 + untyped: 0.4.4 + transitivePeerDependencies: + - supports-color + dev: true + /universalify/0.1.2: resolution: {integrity: sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg==} engines: {node: '>= 4.0.0'} @@ -7868,6 +8204,17 @@ packages: engines: {node: '>= 0.8'} dev: true + /untyped/0.4.4: + resolution: {integrity: sha512-sY6u8RedwfLfBis0copfU/fzROieyAndqPs8Kn2PfyzTjtA88vCk81J1b5z+8/VJc+cwfGy23/AqOCpvAbkNVw==} + dependencies: + '@babel/core': 7.17.10 + '@babel/standalone': 7.17.11 + '@babel/types': 7.17.10 + scule: 0.2.1 + transitivePeerDependencies: + - supports-color + dev: true + /uri-js/4.4.1: resolution: {integrity: sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg==} dependencies: diff --git a/scripts/patchCJS.ts b/scripts/patchCJS.ts new file mode 100644 index 000000000..76edf3fcf --- /dev/null +++ b/scripts/patchCJS.ts @@ -0,0 +1,57 @@ +/** + +It converts + +```ts +exports["default"] = vuePlugin; +exports.parseVueRequest = parseVueRequest; +``` + +to + +```ts +module.exports = vuePlugin; +module.exports["default"] = vuePlugin; +module.exports.parseVueRequest = parseVueRequest; +``` +*/ + +import { readFileSync, writeFileSync } from 'fs' +import { bold, red } from 'picocolors' + +const indexPath = 'dist/index.cjs' +let code = readFileSync(indexPath, 'utf-8') + +const matchMixed = code.match(/\nexports\["default"\] = (\w+);/) +if (matchMixed) { + const name = matchMixed[1] + + const lines = code.trimEnd().split('\n') + + // search from the end to prepend `modules.` to `export[xxx]` + for (let i = lines.length - 1; i > 0; i--) { + if (lines[i].startsWith('exports')) lines[i] = 'module.' + lines[i] + else { + // at the beginning of exports, export the default function + lines[i] += `\nmodule.exports = ${name};` + break + } + } + + writeFileSync(indexPath, lines.join('\n')) + + console.log(bold(`${indexPath} CJS patched`)) + process.exit() +} + +const matchDefault = code.match(/\nmodule.exports = (\w+);/) + +if (matchDefault) { + code += `module.exports["default"] = ${matchDefault[1]};\n` + writeFileSync(indexPath, code) + console.log(bold(`${indexPath} CJS patched`)) + process.exit() +} + +console.error(red(`${indexPath} CJS patch failed`)) +process.exit(1) diff --git a/scripts/patchEsbuildDist.ts b/scripts/patchEsbuildDist.ts deleted file mode 100644 index 6ad2803c7..000000000 --- a/scripts/patchEsbuildDist.ts +++ /dev/null @@ -1,31 +0,0 @@ -// esbuild 0.14.4 https://github.com/evanw/esbuild/blob/master/CHANGELOG.md#0144 introduced a -// change that breaks the "overwrite for cjs require('...')() usage" hack used in plugin-vue -// and plugin-react. For the moment, we can remove the extra exports code added in 0.14.4 to -// continue using it. - -import { readFileSync, writeFileSync } from 'fs' -import { bold, red } from 'picocolors' - -const indexPath = process.argv[2] -const varName = process.argv[3] - -let code = readFileSync(indexPath, 'utf-8') - -const moduleExportsLine = `module.exports = __toCommonJS(src_exports);` - -if (code.includes(moduleExportsLine)) { - // overwrite for cjs require('...')() usage - code = code.replace( - moduleExportsLine, - `module.exports = ${varName}; -${varName}['default'] = ${varName};` - ) - - writeFileSync(indexPath, code) - - console.log( - bold(`${indexPath} patched with overwrite for cjs require('...')()`) - ) -} else { - console.error(red(`${indexPath} post-esbuild bundling patch failed`)) -}