diff --git a/examples/vue/modern.config.ts b/examples/vue/modern.config.ts index 34ec9012..34c40e4e 100644 --- a/examples/vue/modern.config.ts +++ b/examples/vue/modern.config.ts @@ -1,5 +1,5 @@ import { appTools, defineConfig } from '@modern-js/app-tools'; -import { isDev, webxPlugin } from '@webx-kit/modernjs-plugin'; +import { webxPlugin } from '@webx-kit/modernjs-plugin'; import { builderPluginVue } from '@modern-js/builder-plugin-vue'; // https://modernjs.dev/en/configure/app/usage @@ -12,12 +12,6 @@ export default defineConfig({ }), ], builderPlugins: [builderPluginVue()], - source: { - define: { - // TODO: remove next line after https://github.com/web-infra-dev/modern.js/pull/5185 is merged - __VUE_PROD_HYDRATION_MISMATCH_DETAILS__: JSON.stringify(false), - }, - }, output: { copy: [ { diff --git a/package.json b/package.json index d599c9ad..aa69febf 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "engines": { "node": ">=18" }, - "packageManager": "pnpm@8.15.1", + "packageManager": "pnpm@8.15.3", "scripts": { "lint:type": "turbo lint:type", "build": "turbo build", diff --git a/packages/modernjs-plugin/src/plugins/background/index.ts b/packages/modernjs-plugin/src/plugins/background/index.ts index 63a8b1d3..7697cc0d 100644 --- a/packages/modernjs-plugin/src/plugins/background/index.ts +++ b/packages/modernjs-plugin/src/plugins/background/index.ts @@ -1,5 +1,3 @@ -import type { webpack as webpackNS } from '@modern-js/app-tools'; -import { isDev, type WebpackChain } from '@modern-js/utils'; import { RsbuildPlugin } from '@rsbuild/shared'; import { BackgroundReloadPlugin } from './live-reload-plugin'; @@ -38,16 +36,12 @@ export const backgroundPlugin = ({ background, backgroundLiveReload = true }: Ba const entry: BackgroundEntry = typeof background === 'string' ? { name: DEFAULT_BACKGROUND_NAME, import: background } : background; - api.modifyWebpackChain((chain: WebpackChain) => { - chain.entryPoints.set(entry.name, { - values: () => - ({ - import: entry.import, - library: { type: 'module' }, - } satisfies webpackNS.EntryObject[string]), - } as any); - - if (isDev()) + api.modifyWebpackChain((chain, { isProd }) => { + chain.entry(entry.name).add({ + import: entry.import, + library: { type: 'module' }, + }); + if (!isProd) chain.plugin('BackgroundReloadPlugin').use(BackgroundReloadPlugin, [entry.name, backgroundLiveReload]); }); }, diff --git a/packages/modernjs-plugin/src/plugins/content-scripts/hmr-plugin.ts b/packages/modernjs-plugin/src/plugins/content-scripts/hmr-plugin.ts index eeef215a..d8259f7b 100644 --- a/packages/modernjs-plugin/src/plugins/content-scripts/hmr-plugin.ts +++ b/packages/modernjs-plugin/src/plugins/content-scripts/hmr-plugin.ts @@ -22,14 +22,10 @@ function patchLoadScriptRuntimeModule( module.generate = function (this: webpackNS.RuntimeModule) { return webpack.Template.asString([ // jsonp will cause cross-context issues in the isolated content-script environment - `${RuntimeGlobals.loadScript} = async function (url, done, key, chunkId) { + `${RuntimeGlobals.loadScript} = async function (url, done) { await import(url); done(null); };`, - - ` - window.location.reload = () => { debugger; } - `, ]); }; } diff --git a/packages/modernjs-plugin/src/plugins/content-scripts/index.ts b/packages/modernjs-plugin/src/plugins/content-scripts/index.ts index 8ab0c26c..01bab1d4 100644 --- a/packages/modernjs-plugin/src/plugins/content-scripts/index.ts +++ b/packages/modernjs-plugin/src/plugins/content-scripts/index.ts @@ -1,4 +1,3 @@ -import { WebpackChain, isDev } from '@modern-js/utils'; import { RsbuildPlugin } from '@rsbuild/shared'; import { ContentScriptHMRPlugin } from './hmr-plugin'; import { ContentScriptPublicPathPlugin } from './public-path-plugin'; @@ -33,11 +32,11 @@ export const contentScriptsPlugin = ({ contentScripts }: ContentScriptsOptions): ? contentScripts : [{ name: DEFAULT_CONTENT_SCRIPT_NAME, import: contentScripts }]; - api.modifyWebpackChain((chain: WebpackChain) => { + api.modifyWebpackChain((chain, { isProd }) => { entries.forEach((entry) => chain.entry(entry.name).add(entry.import)); const contentScriptNames = new Set(getContentScriptEntryNames({ contentScripts })); - if (isDev()) { + if (!isProd) { chain.plugin('ContentScriptHMRPlugin').use(ContentScriptHMRPlugin, [contentScriptNames]); chain.plugin('ContentScriptShadowRootPlugin').use(ContentScriptShadowRootPlugin, [contentScriptNames]); } else {