diff --git a/packages/babel-plugin-add-react-display-name/package.json b/packages/babel-plugin-add-react-display-name/package.json index 0591f1db..367ff777 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.2", "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 663a0dbd..db661897 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.2", "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 537483ab..6e22e796 100644 --- a/packages/babel-utils/package.json +++ b/packages/babel-utils/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 291c7f00..c763b978 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 c873779d..8d95ef4f 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 f51a8986..b5dd0a0e 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 d83db9b4..ea89069c 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 81359607..6e411018 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 43dff494..aaa3ed07 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 872527cf..de82b234 100644 --- a/packages/cli/package.json +++ b/packages/cli/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 3026e914..8838f077 100644 --- a/packages/config-babel/package.json +++ b/packages/config-babel/package.json @@ -3,12 +3,12 @@ "version": "3.0.2", "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 28f2d0dc..d323b893 100644 --- a/packages/config-lint/package.json +++ b/packages/config-lint/package.json @@ -3,13 +3,13 @@ "version": "3.0.2", "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 d05d04d5..a94ea984 100644 --- a/packages/config-webpack-dev-server/package.json +++ b/packages/config-webpack-dev-server/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 639c1b84..ce178c70 100644 --- a/packages/config-webpack/package.json +++ b/packages/config-webpack/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 41b8d300..d1d8a148 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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/package.json b/packages/plugin-qiankun/package.json index 96d610ae..7b39f608 100644 --- a/packages/plugin-qiankun/package.json +++ b/packages/plugin-qiankun/package.json @@ -2,9 +2,12 @@ "name": "@reskript/plugin-qiankun", "version": "3.0.2", "license": "MIT", - "type": "commonjs", + "type": "module", "main": "./dist/index.js", "types": "./dist/index.d.ts", + "exports": { + ".": "./dist/index.js" + }, "engines": { "node": ">=14.18.0" }, @@ -30,6 +33,7 @@ "typescript": "4.6.0-dev.20220105" }, "dependencies": { + "@reskript/core": "3.0.2", "@reskript/settings": "3.0.2", "dedent": "^0.7.0", "esbuild": "^0.14.8", 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..0b23ad8e 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,7 +22,7 @@ export default async (appName: string) => { const options: BuildOptions = { stdin: { contents: content(appName), - resolveDir: __dirname, + resolveDir: dirFromImportMeta(import.meta.url), }, bundle: true, format: 'iife', diff --git a/packages/plugin-sass/package.json b/packages/plugin-sass/package.json index f351dee7..85721c42 100644 --- a/packages/plugin-sass/package.json +++ b/packages/plugin-sass/package.json @@ -2,9 +2,12 @@ "name": "@reskript/plugin-sass", "version": "3.0.2", "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 7ecfcc50..32a29e9a 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.2", "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 11a8a992..5d7ca9c6 100644 --- a/packages/webpack-plugin-extra-script/package.json +++ b/packages/webpack-plugin-extra-script/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 7d66f0e6..eaa4d8ac 100644 --- a/packages/webpack-plugin-interpolate-html/package.json +++ b/packages/webpack-plugin-interpolate-html/package.json @@ -3,11 +3,11 @@ "version": "3.0.2", "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 4b12bc23..d4202752 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -928,6 +928,7 @@ importers: packages/plugin-qiankun: specifiers: + '@reskript/core': 3.0.2 '@reskript/settings': 3.0.2 '@types/dedent': ^0.7.0 '@types/jest': ^27.0.3 @@ -941,6 +942,7 @@ importers: typescript: 4.6.0-dev.20220105 webpack-dev-server: ^4.7.1 dependencies: + '@reskript/core': link:../core '@reskript/settings': link:../settings dedent: 0.7.0 esbuild: 0.14.11 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';