diff --git a/packages/babel-plugin-add-react-display-name/package.json b/packages/babel-plugin-add-react-display-name/package.json index 6f439662..a9533ef0 100644 --- a/packages/babel-plugin-add-react-display-name/package.json +++ b/packages/babel-plugin-add-react-display-name/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/babel-plugin-debug-react-component-file-name/package.json b/packages/babel-plugin-debug-react-component-file-name/package.json index 3e68e749..3aac976a 100644 --- a/packages/babel-plugin-debug-react-component-file-name/package.json +++ b/packages/babel-plugin-debug-react-component-file-name/package.json @@ -3,12 +3,12 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./useComponentFile": "./dist/useComponentFile.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/babel-utils/package.json b/packages/babel-utils/package.json index f605bcaa..bdd71dfe 100644 --- a/packages/babel-utils/package.json +++ b/packages/babel-utils/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-babel/package.json b/packages/cli-babel/package.json index 87f8980e..03e0a4b2 100644 --- a/packages/cli-babel/package.json +++ b/packages/cli-babel/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-build/package.json b/packages/cli-build/package.json index 831ea649..354a08d5 100644 --- a/packages/cli-build/package.json +++ b/packages/cli-build/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-dev/package.json b/packages/cli-dev/package.json index bd4afe5d..c7f7eb22 100644 --- a/packages/cli-dev/package.json +++ b/packages/cli-dev/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-lint/package.json b/packages/cli-lint/package.json index a5c1bd1f..19866112 100644 --- a/packages/cli-lint/package.json +++ b/packages/cli-lint/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-play/package.json b/packages/cli-play/package.json index d41146e6..e9ea6fbf 100644 --- a/packages/cli-play/package.json +++ b/packages/cli-play/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli-test/package.json b/packages/cli-test/package.json index fa7e23ae..f2ddc28d 100644 --- a/packages/cli-test/package.json +++ b/packages/cli-test/package.json @@ -4,11 +4,10 @@ "license": "MIT", "type": "module", "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/cli/package.json b/packages/cli/package.json index f5ed457f..b65c36a6 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/config-babel/package.json b/packages/config-babel/package.json index fe7b1700..ee714bdc 100644 --- a/packages/config-babel/package.json +++ b/packages/config-babel/package.json @@ -3,12 +3,12 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./willBreakingInternalUseOnly": "./dist/internal.cjs" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/config-lint/package.json b/packages/config-lint/package.json index b76995fb..6b86d165 100644 --- a/packages/config-lint/package.json +++ b/packages/config-lint/package.json @@ -3,13 +3,13 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js", "./patch": "./config/patch.cjs", "./config/*": "./config/*.cjs" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/config-webpack-dev-server/package.json b/packages/config-webpack-dev-server/package.json index 6474d3dc..d3372843 100644 --- a/packages/config-webpack-dev-server/package.json +++ b/packages/config-webpack-dev-server/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/config-webpack/package.json b/packages/config-webpack/package.json index acf043fc..7724f6df 100644 --- a/packages/config-webpack/package.json +++ b/packages/config-webpack/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/core/package.json b/packages/core/package.json index 9ec07a7f..ffe13408 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "commonjs", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/plugin-qiankun/jest.config.js b/packages/plugin-qiankun/jest.config.js deleted file mode 100644 index 1e88ad02..00000000 --- a/packages/plugin-qiankun/jest.config.js +++ /dev/null @@ -1,9 +0,0 @@ -module.exports = { - preset: 'ts-jest/presets/default', - testMatch: ['**/__tests__/**/*.test.ts'], - testEnvironment: 'node', - transformIgnorePatterns: [ - '\\/dist\\/', - 'node_modules', - ], -}; diff --git a/packages/plugin-qiankun/package.json b/packages/plugin-qiankun/package.json index 094927e4..c5e1557f 100644 --- a/packages/plugin-qiankun/package.json +++ b/packages/plugin-qiankun/package.json @@ -2,9 +2,12 @@ "name": "@reskript/plugin-qiankun", "version": "3.0.6", "license": "MIT", - "type": "commonjs", + "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, "engines": { "node": ">=14.18.0" }, @@ -18,18 +21,19 @@ "clean": "rm -rf dist", "build": "tsc -p tsconfig.build.json", "lint": "eslint --max-warnings=0 src", - "test": "jest" + "test": "vitest run" }, "devDependencies": { "@types/dedent": "^0.7.0", - "@types/jest": "^27.0.3", "@types/node": "^17.0.4", + "c8": "^7.10.0", "eslint": "^8.6.0", - "jest": "^27.4.5", - "ts-jest": "^27.1.2", - "typescript": "4.6.0-dev.20220105" + "typescript": "4.6.0-dev.20220105", + "vite": "^2.7.7", + "vitest": "^0.0.115" }, "dependencies": { + "@reskript/core": "3.0.6", "@reskript/settings": "3.0.6", "dedent": "^0.7.0", "esbuild": "^0.14.8", diff --git a/packages/plugin-qiankun/src/__tests__/index.test.ts b/packages/plugin-qiankun/src/__tests__/index.test.ts index 9b2b2db1..1a927224 100644 --- a/packages/plugin-qiankun/src/__tests__/index.test.ts +++ b/packages/plugin-qiankun/src/__tests__/index.test.ts @@ -1,3 +1,4 @@ +import {test, expect} from 'vitest'; import {fillProjectSettings} from '@reskript/settings'; import plugin from '../index'; diff --git a/packages/plugin-qiankun/src/__tests__/runtimeEntry.test.ts b/packages/plugin-qiankun/src/__tests__/runtimeEntry.test.ts index 748cd7ce..4b8e03d7 100644 --- a/packages/plugin-qiankun/src/__tests__/runtimeEntry.test.ts +++ b/packages/plugin-qiankun/src/__tests__/runtimeEntry.test.ts @@ -1,3 +1,4 @@ +import {test, expect} from 'vitest'; import runtimeEntry from '../runtimeEntry'; test('output bundle', async () => { diff --git a/packages/plugin-qiankun/src/htmlEntry.ts b/packages/plugin-qiankun/src/htmlEntry.ts index 7c6d01cb..391861e5 100644 --- a/packages/plugin-qiankun/src/htmlEntry.ts +++ b/packages/plugin-qiankun/src/htmlEntry.ts @@ -1,6 +1,7 @@ import fs from 'fs/promises'; +// @ts-expect-error import dedent from 'dedent'; -import {Options, TemplateConfig, PlaceholderConfig} from './interface'; +import {Options, TemplateConfig, PlaceholderConfig} from './interface.js'; const DEFAULT_BACKGROUND_COLOR = '#f5f5f5'; diff --git a/packages/plugin-qiankun/src/index.ts b/packages/plugin-qiankun/src/index.ts index 2e668f6d..03c70401 100644 --- a/packages/plugin-qiankun/src/index.ts +++ b/packages/plugin-qiankun/src/index.ts @@ -1,8 +1,8 @@ import {SettingsPlugin, BuildSettings, DevServerSettings} from '@reskript/settings'; import {Request, Response} from 'webpack-dev-server'; -import {Options} from './interface'; -import htmlEntry from './htmlEntry'; -import runtimeEntry from './runtimeEntry'; +import {Options} from './interface.js'; +import htmlEntry from './htmlEntry.js'; +import runtimeEntry from './runtimeEntry.js'; export default (appName: string, options?: Options): SettingsPlugin => { const finalizeBuild: BuildSettings['finalize'] = config => { diff --git a/packages/plugin-qiankun/src/runtimeEntry.ts b/packages/plugin-qiankun/src/runtimeEntry.ts index 3ef682e3..98967391 100644 --- a/packages/plugin-qiankun/src/runtimeEntry.ts +++ b/packages/plugin-qiankun/src/runtimeEntry.ts @@ -1,5 +1,7 @@ import {build, BuildOptions} from 'esbuild'; +// @ts-expect-error import dedent from 'dedent'; +import {dirFromImportMeta} from '@reskript/core'; const content = (appName: string) => dedent` import {registerMicroApps, start} from 'qiankun'; @@ -20,14 +22,15 @@ export default async (appName: string) => { const options: BuildOptions = { stdin: { contents: content(appName), - resolveDir: __dirname, + resolveDir: dirFromImportMeta(import.meta.url), }, bundle: true, format: 'iife', write: false, sourcemap: false, define: { - 'process.env.NODE_ENV': '"development"', + // 为了避免在UT的时候被`vitest`给替换成`"test": '"development"'`这样子,增加一些动态计算 + ['0process.env.NODE_ENV0'.slice(1, -1)]: '"development"', }, }; const bundle = await build(options); diff --git a/packages/plugin-sass/package.json b/packages/plugin-sass/package.json index db1691ba..e437a8dd 100644 --- a/packages/plugin-sass/package.json +++ b/packages/plugin-sass/package.json @@ -2,9 +2,12 @@ "name": "@reskript/plugin-sass", "version": "3.0.6", "license": "MIT", - "type": "commonjs", + "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, "engines": { "node": ">=14.18.0" }, diff --git a/packages/plugin-sass/src/index.ts b/packages/plugin-sass/src/index.ts index e82b2dba..437e743f 100644 --- a/packages/plugin-sass/src/index.ts +++ b/packages/plugin-sass/src/index.ts @@ -2,7 +2,7 @@ import resolve from 'resolve'; import sass from 'sass'; import {normalizeRuleMatch} from '@reskript/core'; import {SettingsPlugin, BuildSettings, LoaderType} from '@reskript/settings'; -import {SassLoaderOptions} from './interface'; +import {SassLoaderOptions} from './interface.js'; export default (options: SassLoaderOptions = {}): SettingsPlugin => { const finalizeBuild: BuildSettings['finalize'] = (config, entry, internals) => { diff --git a/packages/plugin-workspace-no-build/package.json b/packages/plugin-workspace-no-build/package.json index e015e7dd..cfc532ee 100644 --- a/packages/plugin-workspace-no-build/package.json +++ b/packages/plugin-workspace-no-build/package.json @@ -2,9 +2,12 @@ "name": "@reskript/plugin-workspace-no-build", "version": "3.0.6", "license": "MIT", - "type": "commonjs", + "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, "engines": { "node": ">=14.18.0" }, diff --git a/packages/plugin-workspace-no-build/src/index.ts b/packages/plugin-workspace-no-build/src/index.ts index c4e2e031..04d5094b 100644 --- a/packages/plugin-workspace-no-build/src/index.ts +++ b/packages/plugin-workspace-no-build/src/index.ts @@ -1,8 +1,14 @@ import path from 'path'; import {logger, isMonorepo, normalizeRuleMatch} from '@reskript/core'; import {SettingsPlugin} from '@reskript/settings'; -import {Options, LocalPackageInfo} from './interface'; -import {resolveParticipant, findSiblingPackages, buildPackageInfo, buildPeerAlias, checkDependencyGraph} from './utils'; +import {Options, LocalPackageInfo} from './interface.js'; +import { + resolveParticipant, + findSiblingPackages, + buildPackageInfo, + buildPeerAlias, + checkDependencyGraph, +} from './utils.js'; export default (options: Options = {}): SettingsPlugin => async (settings, {cwd}) => { const isWorkspace = await isMonorepo(cwd); diff --git a/packages/plugin-workspace-no-build/src/utils.ts b/packages/plugin-workspace-no-build/src/utils.ts index 52216a80..8ac86712 100644 --- a/packages/plugin-workspace-no-build/src/utils.ts +++ b/packages/plugin-workspace-no-build/src/utils.ts @@ -1,7 +1,7 @@ import path from 'path'; import {findMonorepoRoot, resolveMonorepoPackageDirectories, logger, readPackageConfig, pMap} from '@reskript/core'; import {minVersion, satisfies} from 'semver'; -import {Options, LocalPackageInfo} from './interface'; +import {Options, LocalPackageInfo} from './interface.js'; export const resolveParticipant = (defaults: LocalPackageInfo[], {includes, excludes}: Options) => { // 如果2个都没有,就用默认的 diff --git a/packages/webpack-plugin-extra-script/package.json b/packages/webpack-plugin-extra-script/package.json index 211708ad..e7d5130e 100644 --- a/packages/webpack-plugin-extra-script/package.json +++ b/packages/webpack-plugin-extra-script/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/packages/webpack-plugin-interpolate-html/package.json b/packages/webpack-plugin-interpolate-html/package.json index 058026e1..2dcfcb74 100644 --- a/packages/webpack-plugin-interpolate-html/package.json +++ b/packages/webpack-plugin-interpolate-html/package.json @@ -3,11 +3,11 @@ "version": "3.0.6", "license": "MIT", "type": "module", + "main": "./dist/index.js", + "types": "./dist/index.d.ts", "exports": { ".": "./dist/index.js" }, - "main": "./dist/index.js", - "types": "./dist/index.d.ts", "engines": { "node": ">=14.18.0" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index bee4ab7e..4f59bebe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -922,19 +922,21 @@ importers: packages/plugin-qiankun: specifiers: + '@reskript/core': 3.0.6 '@reskript/settings': 3.0.6 '@types/dedent': ^0.7.0 - '@types/jest': ^27.0.3 '@types/node': ^17.0.4 + c8: ^7.10.0 dedent: ^0.7.0 esbuild: ^0.14.8 eslint: ^8.6.0 - jest: ^27.4.5 qiankun: ^2.6.3 - ts-jest: ^27.1.2 typescript: 4.6.0-dev.20220105 + vite: ^2.7.7 + vitest: ^0.0.115 webpack-dev-server: ^4.7.1 dependencies: + '@reskript/core': link:../core '@reskript/settings': link:../settings dedent: 0.7.0 esbuild: 0.14.12 @@ -942,12 +944,12 @@ importers: webpack-dev-server: 4.7.3 devDependencies: '@types/dedent': 0.7.0 - '@types/jest': 27.4.0 '@types/node': 17.0.10 + c8: 7.11.0 eslint: 8.7.0 - jest: 27.4.7 - ts-jest: 27.1.3_d942bc5a97139ac151bf4977be3d5e20 typescript: 4.6.0-dev.20220105 + vite: 2.7.13 + vitest: 0.0.115_c8@7.11.0+vite@2.7.13 packages/plugin-sass: specifiers: @@ -16570,41 +16572,6 @@ packages: resolution: {integrity: sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==} dev: false - /ts-jest/27.1.3_d942bc5a97139ac151bf4977be3d5e20: - resolution: {integrity: sha512-6Nlura7s6uM9BVUAoqLH7JHyMXjz8gluryjpPXxr3IxZdAXnU6FhjvVLHFtfd1vsE1p8zD1OJfskkc0jhTSnkA==} - engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} - hasBin: true - peerDependencies: - '@babel/core': '>=7.0.0-beta.0 <8' - '@types/jest': ^27.0.0 - babel-jest: '>=27.0.0 <28' - esbuild: ~0.14.0 - jest: ^27.0.0 - typescript: '>=3.8 <5.0' - peerDependenciesMeta: - '@babel/core': - optional: true - '@types/jest': - optional: true - babel-jest: - optional: true - esbuild: - optional: true - dependencies: - '@types/jest': 27.4.0 - bs-logger: 0.2.6 - esbuild: 0.14.12 - fast-json-stable-stringify: 2.1.0 - jest: 27.4.7 - jest-util: 27.4.2 - json5: 2.2.0 - lodash.memoize: 4.1.2 - make-error: 1.3.6 - semver: 7.3.5 - typescript: 4.6.0-dev.20220105 - yargs-parser: 20.2.9 - dev: true - /ts-jest/27.1.3_e73e9da3c5fd460fb2dd381d0863ff42: resolution: {integrity: sha512-6Nlura7s6uM9BVUAoqLH7JHyMXjz8gluryjpPXxr3IxZdAXnU6FhjvVLHFtfd1vsE1p8zD1OJfskkc0jhTSnkA==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} diff --git a/showcase/todo/reskript.config.ts b/showcase/todo/reskript.config.ts index 2096ba84..ed758a2e 100644 --- a/showcase/todo/reskript.config.ts +++ b/showcase/todo/reskript.config.ts @@ -1,9 +1,7 @@ import path from 'path'; import {configure} from '@reskript/settings'; import ExtraScriptPlugin from '@reskript/webpack-plugin-extra-script'; -import qiankunExports from '@reskript/plugin-qiankun'; - -const {default: qiankun} = qiankunExports as any; +import qiankun from '@reskript/plugin-qiankun'; const EXTERNAL_NONE = 'https://code.bdstatic.com/npm/none@1.0.0/dist/none.min.js';