@strapi/strapi 5.50.0 → 5.50.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/commands/export/action.d.ts.map +1 -1
- package/dist/cli/commands/import/action.d.ts.map +1 -1
- package/dist/cli/commands/transfer/action.d.ts.map +1 -1
- package/dist/cli/utils/commander.d.ts +1 -1
- package/dist/cli/utils/commander.d.ts.map +1 -1
- package/dist/cli/utils/data-transfer.d.ts +2 -1
- package/dist/cli/utils/data-transfer.d.ts.map +1 -1
- package/dist/node/core/admin-vite-alias-modules.d.ts +15 -0
- package/dist/node/core/admin-vite-alias-modules.d.ts.map +1 -0
- package/dist/node/core/admin-vite-aliases.d.ts +7 -0
- package/dist/node/core/admin-vite-aliases.d.ts.map +1 -0
- package/dist/node/core/admin-vite-optimize-exclude.d.ts +38 -0
- package/dist/node/core/admin-vite-optimize-exclude.d.ts.map +1 -0
- package/dist/node/core/resolve-module.d.ts.map +1 -1
- package/dist/node/create-build-context.d.ts.map +1 -1
- package/dist/node/vite/build.d.ts.map +1 -1
- package/dist/node/vite/config.d.ts.map +1 -1
- package/dist/node/vite/watch.d.ts.map +1 -1
- package/dist/package.json.js +1 -1
- package/dist/package.json.mjs +1 -1
- package/dist/src/cli/commands/export/action.js +4 -0
- package/dist/src/cli/commands/export/action.js.map +1 -1
- package/dist/src/cli/commands/export/action.mjs +5 -1
- package/dist/src/cli/commands/export/action.mjs.map +1 -1
- package/dist/src/cli/commands/import/action.js +4 -0
- package/dist/src/cli/commands/import/action.js.map +1 -1
- package/dist/src/cli/commands/import/action.mjs +5 -1
- package/dist/src/cli/commands/import/action.mjs.map +1 -1
- package/dist/src/cli/commands/transfer/action.js +4 -0
- package/dist/src/cli/commands/transfer/action.js.map +1 -1
- package/dist/src/cli/commands/transfer/action.mjs +5 -1
- package/dist/src/cli/commands/transfer/action.mjs.map +1 -1
- package/dist/src/cli/utils/data-transfer.js +26 -2
- package/dist/src/cli/utils/data-transfer.js.map +1 -1
- package/dist/src/cli/utils/data-transfer.mjs +26 -3
- package/dist/src/cli/utils/data-transfer.mjs.map +1 -1
- package/dist/src/node/core/admin-vite-alias-modules.js +25 -0
- package/dist/src/node/core/admin-vite-alias-modules.js.map +1 -0
- package/dist/src/node/core/admin-vite-alias-modules.mjs +22 -0
- package/dist/src/node/core/admin-vite-alias-modules.mjs.map +1 -0
- package/dist/src/node/core/admin-vite-aliases.js +16 -0
- package/dist/src/node/core/admin-vite-aliases.js.map +1 -0
- package/dist/src/node/core/admin-vite-aliases.mjs +14 -0
- package/dist/src/node/core/admin-vite-aliases.mjs.map +1 -0
- package/dist/src/node/core/admin-vite-optimize-exclude.js +158 -0
- package/dist/src/node/core/admin-vite-optimize-exclude.js.map +1 -0
- package/dist/src/node/core/admin-vite-optimize-exclude.mjs +145 -0
- package/dist/src/node/core/admin-vite-optimize-exclude.mjs.map +1 -0
- package/dist/src/node/core/resolve-module.js +14 -1
- package/dist/src/node/core/resolve-module.js.map +1 -1
- package/dist/src/node/core/resolve-module.mjs +13 -1
- package/dist/src/node/core/resolve-module.mjs.map +1 -1
- package/dist/src/node/create-build-context.js +3 -0
- package/dist/src/node/create-build-context.js.map +1 -1
- package/dist/src/node/create-build-context.mjs +3 -0
- package/dist/src/node/create-build-context.mjs.map +1 -1
- package/dist/src/node/vite/build.js +3 -0
- package/dist/src/node/vite/build.js.map +1 -1
- package/dist/src/node/vite/build.mjs +3 -0
- package/dist/src/node/vite/build.mjs.map +1 -1
- package/dist/src/node/vite/config.js +27 -36
- package/dist/src/node/vite/config.js.map +1 -1
- package/dist/src/node/vite/config.mjs +26 -31
- package/dist/src/node/vite/config.mjs.map +1 -1
- package/dist/src/node/vite/watch.js +3 -0
- package/dist/src/node/vite/watch.js.map +1 -1
- package/dist/src/node/vite/watch.mjs +3 -0
- package/dist/src/node/vite/watch.mjs.map +1 -1
- package/package.json +25 -24
- package/dist/cli/commands/plugin/init/files/typescript.d.ts +0 -22
- package/dist/cli/commands/plugin/init/files/typescript.d.ts.map +0 -1
- package/dist/test/mocks/inquirer.d.ts +0 -10
- package/dist/test/mocks/inquirer.d.ts.map +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin-vite-optimize-exclude.mjs","sources":["../../../../src/node/core/admin-vite-optimize-exclude.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\nimport readPkgUp from 'read-pkg-up';\n\nimport { ADMIN_VITE_ALIAS_MODULES } from './admin-vite-alias-modules';\nimport { getModule, type PackageJson } from './dependencies';\nimport type { PluginMeta } from './plugins';\n\nconst REACT_PEER_DEPENDENCIES = new Set(['react', 'react-dom']);\n\n/**\n * Packages explicitly pre-bundled or aliased for the admin singleton contract.\n * Never auto-exclude these — they must stay on the optimizeDeps.include / dedupe path.\n *\n * The admin entry host (@strapi/strapi) must never land in optimizeDeps.exclude (#26944, #27014).\n * CJS-only deps imported by @strapi/admin (e.g. invariant, lodash) belong in optimizeDeps.include\n * (see vite/config.ts — #26964, #26944, #27014).\n */\nconst PINNED_OPTIMIZE_MODULES = new Set<string>([...ADMIN_VITE_ALIAS_MODULES, '@strapi/strapi']);\n\nconst isOfficialStrapiPackage = (name: string): boolean => name.startsWith('@strapi/');\n\ntype PackageExportEntry =\n | string\n | {\n import?: string;\n require?: string;\n default?: string;\n };\n\nconst getRootPackageExport = (pkg: PackageJson): PackageExportEntry | undefined => {\n const exportsField = pkg.exports as Record<string, PackageExportEntry> | string | undefined;\n\n if (!exportsField || typeof exportsField === 'string') {\n return undefined;\n }\n\n return exportsField['.'];\n};\n\n/**\n * @internal exported for tests\n */\nexport const isEsmPackage = (pkg: PackageJson): boolean => {\n if (pkg.type === 'module') {\n return true;\n }\n\n const rootExport = getRootPackageExport(pkg);\n\n return (\n typeof rootExport === 'object' &&\n rootExport !== null &&\n 'import' in rootExport &&\n typeof rootExport.import === 'string'\n );\n};\n\n/**\n * @internal exported for tests\n */\nexport const hasReactPeerDependency = (pkg: PackageJson): boolean =>\n Object.keys(pkg.peerDependencies ?? {}).some((name) => REACT_PEER_DEPENDENCIES.has(name));\n\n/**\n * Targets libraries that ship a pre-built dist bundle (e.g. plugin UI kits) rather than\n * source packages like react-intl that still benefit from Vite's dep optimizer.\n *\n * @internal exported for tests\n */\nexport const shipsPreBuiltDist = (pkg: PackageJson): boolean => {\n const rootExport = getRootPackageExport(pkg);\n const exportImport =\n typeof rootExport === 'object' && rootExport !== null && 'import' in rootExport\n ? rootExport.import\n : undefined;\n\n const entryPaths = [pkg.module, pkg.main, exportImport].filter(\n (entry): entry is string => typeof entry === 'string'\n );\n\n if (\n entryPaths.some(\n (entry) =>\n entry.includes('/dist/') || entry.startsWith('./dist/') || entry.startsWith('dist/')\n )\n ) {\n return true;\n }\n\n return (\n Array.isArray(pkg.files) &&\n pkg.files.some((file) => file === 'dist' || file.startsWith('dist/'))\n );\n};\n\n/**\n * @internal exported for tests\n */\nexport const shouldExcludeFromOptimizeDeps = (pkg: PackageJson): boolean =>\n hasReactPeerDependency(pkg) && isEsmPackage(pkg) && shipsPreBuiltDist(pkg);\n\n/**\n * @internal exported for tests\n */\nexport const getPluginPackageName = (modulePath: string): string => {\n if (modulePath.startsWith('@')) {\n const [scope, name] = modulePath.split('/');\n\n return `${scope}/${name}`;\n }\n\n return modulePath.split('/')[0] ?? modulePath;\n};\n\nconst collectDependencyNames = (pkg: PackageJson): string[] => {\n const names = new Set<string>();\n\n for (const section of [pkg.dependencies, pkg.devDependencies] as const) {\n if (section) {\n for (const name of Object.keys(section)) {\n names.add(name);\n }\n }\n }\n\n return [...names];\n};\n\nconst getPluginPackageJson = async (\n plugin: PluginMeta,\n cwd: string\n): Promise<PackageJson | null> => {\n if (plugin.type === 'local' && plugin.path) {\n try {\n const content = await fs.readFile(path.join(plugin.path, 'package.json'), 'utf8');\n\n return JSON.parse(content) as PackageJson;\n } catch {\n return null;\n }\n }\n\n return getModule(getPluginPackageName(plugin.modulePath), cwd);\n};\n\nconst loadAppPackageJson = async (cwd: string): Promise<PackageJson | null> => {\n const result = await readPkgUp({ cwd });\n\n return result?.packageJson ?? null;\n};\n\n/**\n * Pre-built ESM libraries with React peers (shared plugin UI kits) are incompatible with\n * Strapi's React/design-system pre-bundling. Skip dep optimization so they resolve through\n * the admin resolve aliases instead of being re-bundled by Vite.\n *\n * Scans app and plugin dependency trees (#26944). Official @strapi/* packages and pinned\n * singletons are never auto-excluded — @strapi/strapi matches the heuristic but must stay on\n * the optimizeDeps.include path (#26944, #27014).\n *\n * @internal\n */\nexport const collectAdminOptimizeDepsExclude = async (\n cwd: string,\n plugins: PluginMeta[]\n): Promise<string[]> => {\n const candidateNames = new Set<string>();\n const appPkg = await loadAppPackageJson(cwd);\n\n if (appPkg) {\n for (const name of collectDependencyNames(appPkg)) {\n candidateNames.add(name);\n }\n }\n\n for (const plugin of plugins) {\n const pluginPkg = await getPluginPackageJson(plugin, cwd);\n\n if (pluginPkg) {\n for (const name of collectDependencyNames(pluginPkg)) {\n candidateNames.add(name);\n }\n }\n }\n\n const exclude: string[] = [];\n\n for (const name of candidateNames) {\n if (PINNED_OPTIMIZE_MODULES.has(name) || isOfficialStrapiPackage(name)) {\n continue;\n }\n\n const pkg = await getModule(name, cwd);\n\n if (pkg && shouldExcludeFromOptimizeDeps(pkg)) {\n exclude.push(name);\n }\n }\n\n return exclude.sort();\n};\n"],"names":["REACT_PEER_DEPENDENCIES","Set","PINNED_OPTIMIZE_MODULES","ADMIN_VITE_ALIAS_MODULES","isOfficialStrapiPackage","name","startsWith","getRootPackageExport","pkg","exportsField","exports","undefined","isEsmPackage","type","rootExport","import","hasReactPeerDependency","Object","keys","peerDependencies","some","has","shipsPreBuiltDist","exportImport","entryPaths","module","main","filter","entry","includes","Array","isArray","files","file","shouldExcludeFromOptimizeDeps","getPluginPackageName","modulePath","scope","split","collectDependencyNames","names","section","dependencies","devDependencies","add","getPluginPackageJson","plugin","cwd","path","content","fs","readFile","join","JSON","parse","getModule","loadAppPackageJson","result","read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AA;AACf,QAAA;AACF,IAAA;AAEA,IAAA,OAAO4D,QAAQE,IAAI,EAAA;AACrB;;;;"}
|
|
@@ -2,19 +2,32 @@
|
|
|
2
2
|
|
|
3
3
|
var path = require('node:path');
|
|
4
4
|
var readPkgUp = require('read-pkg-up');
|
|
5
|
+
var resolveFrom = require('resolve-from');
|
|
5
6
|
|
|
6
7
|
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
7
8
|
|
|
8
9
|
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
9
10
|
var readPkgUp__default = /*#__PURE__*/_interopDefault(readPkgUp);
|
|
11
|
+
var resolveFrom__default = /*#__PURE__*/_interopDefault(resolveFrom);
|
|
10
12
|
|
|
13
|
+
let adminPkgDir;
|
|
14
|
+
/**
|
|
15
|
+
* Package root of @strapi/admin — admin Vite aliases must resolve from here so pnpm
|
|
16
|
+
* workspaces cannot pick up a hoisted incompatible major from another package
|
|
17
|
+
* (e.g. @reduxjs/toolkit@2.x elsewhere while admin pins 1.9.x).
|
|
18
|
+
*/ const getAdminPkgDir = ()=>{
|
|
19
|
+
if (!adminPkgDir) {
|
|
20
|
+
adminPkgDir = path__default.default.dirname(require.resolve('@strapi/admin/package.json'));
|
|
21
|
+
}
|
|
22
|
+
return adminPkgDir;
|
|
23
|
+
};
|
|
11
24
|
/**
|
|
12
25
|
* Resolve module to package root for use in aliases.
|
|
13
26
|
* Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.
|
|
14
27
|
*
|
|
15
28
|
* @internal
|
|
16
29
|
*/ const getModulePath = (mod)=>{
|
|
17
|
-
const modulePath =
|
|
30
|
+
const modulePath = resolveFrom__default.default(getAdminPkgDir(), mod);
|
|
18
31
|
const pkg = readPkgUp__default.default.sync({
|
|
19
32
|
cwd: path__default.default.dirname(modulePath)
|
|
20
33
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-module.js","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath =
|
|
1
|
+
{"version":3,"file":"resolve-module.js","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\nimport resolveFrom from 'resolve-from';\n\nlet adminPkgDir: string | undefined;\n\n/**\n * Package root of @strapi/admin — admin Vite aliases must resolve from here so pnpm\n * workspaces cannot pick up a hoisted incompatible major from another package\n * (e.g. @reduxjs/toolkit@2.x elsewhere while admin pins 1.9.x).\n */\nconst getAdminPkgDir = (): string => {\n if (!adminPkgDir) {\n adminPkgDir = path.dirname(require.resolve('@strapi/admin/package.json'));\n }\n\n return adminPkgDir;\n};\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath = resolveFrom(getAdminPkgDir(), mod);\n const pkg = readPkgUp.sync({ cwd: path.dirname(modulePath) });\n return pkg ? path.dirname(pkg.path) : modulePath;\n};\n"],"names":["adminPkgDir","getAdminPkgDir","path","dirname","require","resolve","getModulePath","mod","modulePath","resolveFrom","pkg","readPkgUp","sync","cwd"],"mappings":";;;;;;;;;;;;AAIA,IAAIA,WAAAA;AAEJ;;;;AAIC,IACD,MAAMC,cAAAA,GAAiB,IAAA;AACrB,IAAA,IAAI,CAACD,WAAAA,EAAa;AAChBA,QAAAA,WAAAA,GAAcE,qBAAAA,CAAKC,OAAO,CAACC,OAAAA,CAAQC,OAAO,CAAC,4BAAA,CAAA,CAAA;AAC7C,IAAA;IAEA,OAAOL,WAAAA;AACT,CAAA;AAEA;;;;;IAMO,MAAMM,aAAAA,GAAgB,CAACC,GAAAA,GAAAA;IAC5B,MAAMC,UAAAA,GAAaC,6BAAYR,cAAAA,EAAAA,EAAkBM,GAAAA,CAAAA;IACjD,MAAMG,GAAAA,GAAMC,0BAAAA,CAAUC,IAAI,CAAC;QAAEC,GAAAA,EAAKX,qBAAAA,CAAKC,OAAO,CAACK,UAAAA;AAAY,KAAA,CAAA;AAC3D,IAAA,OAAOE,MAAMR,qBAAAA,CAAKC,OAAO,CAACO,GAAAA,CAAIR,IAAI,CAAA,GAAIM,UAAAA;AACxC;;;;"}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import path from 'node:path';
|
|
2
2
|
import readPkgUp from 'read-pkg-up';
|
|
3
|
+
import resolveFrom from 'resolve-from';
|
|
3
4
|
|
|
5
|
+
let adminPkgDir;
|
|
6
|
+
/**
|
|
7
|
+
* Package root of @strapi/admin — admin Vite aliases must resolve from here so pnpm
|
|
8
|
+
* workspaces cannot pick up a hoisted incompatible major from another package
|
|
9
|
+
* (e.g. @reduxjs/toolkit@2.x elsewhere while admin pins 1.9.x).
|
|
10
|
+
*/ const getAdminPkgDir = ()=>{
|
|
11
|
+
if (!adminPkgDir) {
|
|
12
|
+
adminPkgDir = path.dirname(require.resolve('@strapi/admin/package.json'));
|
|
13
|
+
}
|
|
14
|
+
return adminPkgDir;
|
|
15
|
+
};
|
|
4
16
|
/**
|
|
5
17
|
* Resolve module to package root for use in aliases.
|
|
6
18
|
* Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.
|
|
7
19
|
*
|
|
8
20
|
* @internal
|
|
9
21
|
*/ const getModulePath = (mod)=>{
|
|
10
|
-
const modulePath =
|
|
22
|
+
const modulePath = resolveFrom(getAdminPkgDir(), mod);
|
|
11
23
|
const pkg = readPkgUp.sync({
|
|
12
24
|
cwd: path.dirname(modulePath)
|
|
13
25
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolve-module.mjs","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath =
|
|
1
|
+
{"version":3,"file":"resolve-module.mjs","sources":["../../../../src/node/core/resolve-module.ts"],"sourcesContent":["import path from 'node:path';\nimport readPkgUp from 'read-pkg-up';\nimport resolveFrom from 'resolve-from';\n\nlet adminPkgDir: string | undefined;\n\n/**\n * Package root of @strapi/admin — admin Vite aliases must resolve from here so pnpm\n * workspaces cannot pick up a hoisted incompatible major from another package\n * (e.g. @reduxjs/toolkit@2.x elsewhere while admin pins 1.9.x).\n */\nconst getAdminPkgDir = (): string => {\n if (!adminPkgDir) {\n adminPkgDir = path.dirname(require.resolve('@strapi/admin/package.json'));\n }\n\n return adminPkgDir;\n};\n\n/**\n * Resolve module to package root for use in aliases.\n * Ensures pnpm's strict node_modules structure can resolve packages when bundling plugin chunks.\n *\n * @internal\n */\nexport const getModulePath = (mod: string): string => {\n const modulePath = resolveFrom(getAdminPkgDir(), mod);\n const pkg = readPkgUp.sync({ cwd: path.dirname(modulePath) });\n return pkg ? path.dirname(pkg.path) : modulePath;\n};\n"],"names":["adminPkgDir","getAdminPkgDir","path","dirname","require","resolve","getModulePath","mod","modulePath","resolveFrom","pkg","readPkgUp","sync","cwd"],"mappings":";;;;AAIA,IAAIA,WAAAA;AAEJ;;;;AAIC,IACD,MAAMC,cAAAA,GAAiB,IAAA;AACrB,IAAA,IAAI,CAACD,WAAAA,EAAa;AAChBA,QAAAA,WAAAA,GAAcE,IAAAA,CAAKC,OAAO,CAACC,OAAAA,CAAQC,OAAO,CAAC,4BAAA,CAAA,CAAA;AAC7C,IAAA;IAEA,OAAOL,WAAAA;AACT,CAAA;AAEA;;;;;IAMO,MAAMM,aAAAA,GAAgB,CAACC,GAAAA,GAAAA;IAC5B,MAAMC,UAAAA,GAAaC,YAAYR,cAAAA,EAAAA,EAAkBM,GAAAA,CAAAA;IACjD,MAAMG,GAAAA,GAAMC,SAAAA,CAAUC,IAAI,CAAC;QAAEC,GAAAA,EAAKX,IAAAA,CAAKC,OAAO,CAACK,UAAAA;AAAY,KAAA,CAAA;AAC3D,IAAA,OAAOE,MAAMR,IAAAA,CAAKC,OAAO,CAACO,GAAAA,CAAIR,IAAI,CAAA,GAAIM,UAAAA;AACxC;;;;"}
|
|
@@ -52,6 +52,9 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
|
|
|
52
52
|
STRAPI_AI_URL: process.env.STRAPI_AI_URL?.replace(/\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',
|
|
53
53
|
STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io'
|
|
54
54
|
});
|
|
55
|
+
// NOTE: Transports `admin.auth.cookie.name` into the bundle; always assigned so an
|
|
56
|
+
// ambient STRAPI_ADMIN_AUTH_COOKIE_NAME cannot make the bundle disagree with the server.
|
|
57
|
+
env$1.STRAPI_ADMIN_AUTH_COOKIE_NAME = strapiInstance.config.get('admin.auth.cookie.name') || '';
|
|
55
58
|
const envKeys = Object.keys(env$1);
|
|
56
59
|
if (envKeys.length > 0) {
|
|
57
60
|
logger.debug([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.js","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;;;;;;;;AA+CA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,iBAAAA,CAAa;;QAEXC,MAAAA,EAAQP,GAAAA;QACRQ,OAAAA,EAASN,QAAAA,EAAUO,MAAAA,CAAOL,OAAAA,CAAQM,MAAAA,IAAU,EAAA;;QAE5CC,UAAAA,EAAY,IAAA;QACZC,eAAAA,EAAiB;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAAA,GAAoBR,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAAA,GAAmBV,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,S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AK,CAAC,yBAAA,EAA2BI,mBAAAA,CAAGC,GAAG,EAAEa,gBAAAA,CAAAA;IAEhD,MAAME,MAAAA,GAASC,6BAAAA,CAAaC,UAAU,CAAC;QAAEf,IAAAA,EAAMlD;KAAI,CAAA,IAAMF,oBAAAA;IAEzD,MAAMoE,cAAAA,GAAiB,MAAMC,mCAAAA,CAAgB;AAAE5D,QAAAA,MAAAA;AAAQkD,QAAAA;AAAW,KAAA,CAAA;AAElE,IAAA,MAAMW,WAAW/D,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAC,UAAA,EAAYuD,SAAAA,CAAAA;AAEvD,IAAA,MAAM,EAAEC,OAAAA,GAAU,MAAM,EAAE,GAAGC,aAAa,GAAGnE,OAAAA;AAE7C,IAAA,MAAMoE,YAAAA,GAAe;AACnBjE,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;QACAyD,QAAAA,EAAUrD,eAAAA;AACVkD,QAAAA,OAAAA;AACAJ,QAAAA,cAAAA;AACAlE,QAAAA,GAAAA;AACAQ,QAAAA,OAAAA;AACAyC,QAAAA,QAAAA;AACAS,QAAAA,KAAAA;AACA/B,aAAAA,KAAAA;AACAyC,QAAAA,QAAAA;AACAnE,QAAAA,MAAAA;QACAG,OAAAA,EAASmE,WAAAA;QACTZ,OAAAA,EAASE,gBAAAA;AACTJ,QAAAA,UAAAA;QACAtD,MAAAA,EAAQE,cAAAA;AACR0D,QAAAA,MAAAA;AACA7D,QAAAA;AACF,KAAA;IAEA,OAAOsE,YAAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"create-build-context.js","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n // NOTE: Transports `admin.auth.cookie.name` into the bundle; always assigned so an\n // ambient STRAPI_ADMIN_AUTH_COOKIE_NAME cannot make the bundle disagree with the server.\n env.STRAPI_ADMIN_AUTH_COOKIE_NAME =\n strapiInstance.config.get<string | undefined>('admin.auth.cookie.name') || '';\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","STRAPI_ADMIN_AUTH_COOKIE_NAME","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;;;;;;;;;;AA+CA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,iBAAAA,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AA,QAAAA;AACApE,QAAAA,MAAAA;QACAG,OAAAA,EAASoE,WAAAA;QACTZ,OAAAA,EAASE,gBAAAA;AACTJ,QAAAA,UAAAA;QACAvD,MAAAA,EAAQE,cAAAA;AACR2D,QAAAA,MAAAA;AACA9D,QAAAA;AACF,KAAA;IAEA,OAAOuE,YAAAA;AACT;;;;"}
|
|
@@ -43,6 +43,9 @@ const createBuildContext = async ({ cwd, logger, tsconfig, strapi, options = {}
|
|
|
43
43
|
STRAPI_AI_URL: process.env.STRAPI_AI_URL?.replace(/\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',
|
|
44
44
|
STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io'
|
|
45
45
|
});
|
|
46
|
+
// NOTE: Transports `admin.auth.cookie.name` into the bundle; always assigned so an
|
|
47
|
+
// ambient STRAPI_ADMIN_AUTH_COOKIE_NAME cannot make the bundle disagree with the server.
|
|
48
|
+
env.STRAPI_ADMIN_AUTH_COOKIE_NAME = strapiInstance.config.get('admin.auth.cookie.name') || '';
|
|
46
49
|
const envKeys = Object.keys(env);
|
|
47
50
|
if (envKeys.length > 0) {
|
|
48
51
|
logger.debug([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.mjs","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;AA+CA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,YAAAA,CAAa;;QAEXC,MAAAA,EAAQP,GAAAA;QACRQ,OAAAA,EAASN,QAAAA,EAAUO,MAAAA,CAAOL,OAAAA,CAAQM,MAAAA,IAAU,EAAA;;QAE5CC,UAAAA,EAAY,IAAA;QACZC,eAAAA,EAAiB;AACnB,KAAA,CAAA;AAEF,IAAA,MAAMC,iBAAAA,GAAoBR,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,oBAAA,CAAA;AAC5D,IAAA,MAAMC,gBAAAA,GAAmBV,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAS,mBAAA,CAAA;AAC3D,IAAA,MAAME,SAAAA,GAAYX,cAAAA,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A,CAAGC,GAAG,EAAEa,gBAAAA,CAAAA;IAEhD,MAAME,MAAAA,GAASC,YAAAA,CAAaC,UAAU,CAAC;QAAEf,IAAAA,EAAMlD;KAAI,CAAA,IAAMF,oBAAAA;IAEzD,MAAMoE,cAAAA,GAAiB,MAAMC,eAAAA,CAAgB;AAAE5D,QAAAA,MAAAA;AAAQkD,QAAAA;AAAW,KAAA,CAAA;AAElE,IAAA,MAAMW,WAAW/D,cAAAA,CAAeI,MAAM,CAACK,GAAG,CAAC,UAAA,EAAYuD,SAAAA,CAAAA;AAEvD,IAAA,MAAM,EAAEC,OAAAA,GAAU,MAAM,EAAE,GAAGC,aAAa,GAAGnE,OAAAA;AAE7C,IAAA,MAAMoE,YAAAA,GAAe;AACnBjE,QAAAA,MAAAA;AACAS,QAAAA,SAAAA;QACAyD,QAAAA,EAAUrD,eAAAA;AACVkD,QAAAA,OAAAA;AACAJ,QAAAA,cAAAA;AACAlE,QAAAA,GAAAA;AACAQ,QAAAA,OAAAA;AACAyC,QAAAA,QAAAA;AACAS,QAAAA,KAAAA;AACA/B,QAAAA,GAAAA;AACAyC,QAAAA,QAAAA;AACAnE,QAAAA,MAAAA;QACAG,OAAAA,EAASmE,WAAAA;QACTZ,OAAAA,EAASE,gBAAAA;AACTJ,QAAAA,UAAAA;QACAtD,MAAAA,EAAQE,cAAAA;AACR0D,QAAAA,MAAAA;AACA7D,QAAAA;AACF,KAAA;IAEA,OAAOsE,YAAAA;AACT;;;;"}
|
|
1
|
+
{"version":3,"file":"create-build-context.mjs","sources":["../../../src/node/create-build-context.ts"],"sourcesContent":["import os from 'node:os';\nimport path from 'node:path';\nimport fs from 'node:fs/promises';\nimport browserslist from 'browserslist';\nimport { createStrapi } from '@strapi/core';\nimport type { Core, Modules } from '@strapi/types';\n\nimport type { CLIContext } from '../cli/types';\nimport { getStrapiAdminEnvVars, loadEnv } from './core/env';\n\nimport { PluginMeta, getEnabledPlugins, getMapOfPluginsWithAdmin } from './core/plugins';\nimport { AppFile, loadUserAppFile } from './core/admin-customisations';\nimport type { BaseContext } from './types';\n\ninterface BaseOptions {\n stats?: boolean;\n minify?: boolean;\n sourcemaps?: boolean;\n bundler?: 'webpack' | 'vite';\n open?: boolean;\n}\n\ninterface BuildContext<TOptions = unknown> extends BaseContext {\n /**\n * The customisations defined by the user in their app.js file\n */\n customisations?: AppFile;\n /**\n * Features object with future flags\n */\n features?: Modules.Features.FeaturesService['config'];\n /**\n * The build options\n */\n options: BaseOptions & TOptions;\n /**\n * The plugins to be included in the JS bundle\n * incl. internal plugins, third party plugins & local plugins\n */\n plugins: PluginMeta[];\n}\n\ninterface CreateBuildContextArgs<TOptions = unknown> extends CLIContext {\n strapi?: Core.Strapi;\n options?: TOptions;\n}\n\nconst DEFAULT_BROWSERSLIST = [\n 'last 3 major versions',\n 'Firefox ESR',\n 'last 2 Opera versions',\n 'not dead',\n];\n\nconst createBuildContext = async <TOptions extends BaseOptions>({\n cwd,\n logger,\n tsconfig,\n strapi,\n options = {} as TOptions,\n}: CreateBuildContextArgs<TOptions>): Promise<BuildContext<TOptions>> => {\n /**\n * If you make a new strapi instance when one already exists,\n * you will overwrite the global and the app will _most likely_\n * crash and die.\n */\n const strapiInstance =\n strapi ??\n createStrapi({\n // Directories\n appDir: cwd,\n distDir: tsconfig?.config.options.outDir ?? '',\n // Options\n autoReload: true,\n serveAdminPanel: false,\n });\n\n const serverAbsoluteUrl = strapiInstance.config.get<string>('server.absoluteUrl');\n const adminAbsoluteUrl = strapiInstance.config.get<string>('admin.absoluteUrl');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n // NOTE: Checks that both the server and admin will be served from the same origin (protocol, host, port)\n const sameOrigin = new URL(adminAbsoluteUrl).origin === new URL(serverAbsoluteUrl).origin;\n\n const adminPublicPath = new URL(adminAbsoluteUrl).pathname;\n const serverPublicPath = new URL(serverAbsoluteUrl).pathname;\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPublicPath,\n STRAPI_ADMIN_BACKEND_URL: sameOrigin ? serverPublicPath : serverAbsoluteUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n // TODO: Get this url from a utility/consts rather than duplicating it in AIChat constants.ts\n STRAPI_AI_URL:\n process.env.STRAPI_AI_URL?.replace(/\\/+$/, '') ?? 'https://strapi-ai.apps.strapi.io',\n STRAPI_ANALYTICS_URL: process.env.STRAPI_ANALYTICS_URL || 'https://analytics.strapi.io',\n });\n\n // NOTE: Transports `admin.auth.cookie.name` into the bundle; always assigned so an\n // ambient STRAPI_ADMIN_AUTH_COOKIE_NAME cannot make the bundle disagree with the server.\n env.STRAPI_ADMIN_AUTH_COOKIE_NAME =\n strapiInstance.config.get<string | undefined>('admin.auth.cookie.name') || '';\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.debug(\n [\n 'Including the following ENV variables as part of the JS bundle:',\n ...envKeys.map((key) => ` - ${key}`),\n ].join(os.EOL)\n );\n }\n\n const distPath = path.join(strapiInstance.dirs.dist.root, 'build');\n const distDir = path.relative(cwd, distPath);\n\n /**\n * If the distPath already exists, clean it\n */\n try {\n logger.debug(`Cleaning dist folder: ${distPath}`);\n await fs.rm(distPath, { recursive: true, force: true });\n logger.debug('Cleaned dist folder');\n } catch {\n // do nothing, it will fail if the folder does not exist\n logger.debug('There was no dist folder to clean');\n }\n\n const runtimeDir = path.join(cwd, '.strapi', 'client');\n const entry = path.relative(cwd, path.join(runtimeDir, 'app.js'));\n\n const plugins = await getEnabledPlugins({ cwd, logger, runtimeDir, strapi: strapiInstance });\n\n logger.debug('Enabled plugins', os.EOL, plugins);\n\n const pluginsWithFront = getMapOfPluginsWithAdmin(plugins);\n\n logger.debug('Enabled plugins with FE', os.EOL, pluginsWithFront);\n\n const target = browserslist.loadConfig({ path: cwd }) ?? DEFAULT_BROWSERSLIST;\n\n const customisations = await loadUserAppFile({ appDir, runtimeDir });\n\n const features = strapiInstance.config.get('features', undefined);\n\n const { bundler = 'vite', ...restOptions } = options;\n\n const buildContext = {\n appDir,\n adminPath,\n basePath: adminPublicPath,\n bundler,\n customisations,\n cwd,\n distDir,\n distPath,\n entry,\n env,\n features,\n logger,\n options: restOptions as BaseOptions & TOptions,\n plugins: pluginsWithFront,\n runtimeDir,\n strapi: strapiInstance,\n target,\n tsconfig,\n } satisfies BuildContext<TOptions>;\n\n return buildContext;\n};\n\nexport { createBuildContext };\nexport type { BuildContext, CreateBuildContextArgs };\n"],"names":["DEFAULT_BROWSERSLIST","createBuildContext","cwd","logger","tsconfig","strapi","options","strapiInstance","createStrapi","appDir","distDir","config","outDir","autoReload","serveAdminPanel","serverAbsoluteUrl","get","adminAbsoluteUrl","adminPath","sameOrigin","URL","origin","adminPublicPath","pathname","serverPublicPath","dirs","app","root","loadEnv","env","getStrapiAdminEnvVars","ADMIN_PATH","STRAPI_ADMIN_BACKEND_URL","STRAPI_TELEMETRY_DISABLED","String","telemetry","isDisabled","STRAPI_AI_URL","process","replace","STRAPI_ANALYTICS_URL","STRAPI_ADMIN_AUTH_COOKIE_NAME","envKeys","Object","keys","length","debug","map","key","join","os","EOL","distPath","path","dist","relative","fs","rm","recursive","force","runtimeDir","entry","plugins","getEnabledPlugins","pluginsWithFront","getMapOfPluginsWithAdmin","target","browserslist","loadConfig","customisations","loadUserAppFile","features","undefined","bundler","restOptions","buildContext","basePath"],"mappings":";;;;;;;;;AA+CA,MAAMA,oBAAAA,GAAuB;AAC3B,IAAA,uBAAA;AACA,IAAA,aAAA;AACA,IAAA,uBAAA;AACA,IAAA;AACD,CAAA;AAED,MAAMC,kBAAAA,GAAqB,OAAqC,EAC9DC,GAAG,EACHC,MAAM,EACNC,QAAQ,EACRC,MAAM,EACNC,OAAAA,GAAU,EAAc,EACS,GAAA;AACjC;;;;MAKA,MAAMC,cAAAA,GACJF,MAAAA,IACAG,YAAAA,CAAa;;QAEXC,MAAAA,EAAQP,GAAAA;QACRQ,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A;QACTZ,OAAAA,EAASE,gBAAAA;AACTJ,QAAAA,UAAAA;QACAvD,MAAAA,EAAQE,cAAAA;AACR2D,QAAAA,MAAAA;AACA9D,QAAAA;AACF,KAAA;IAEA,OAAOuE,YAAAA;AACT;;;;"}
|
|
@@ -5,6 +5,9 @@ var config = require('./config.js');
|
|
|
5
5
|
const build = async (ctx)=>{
|
|
6
6
|
const config$1 = await config.resolveProductionConfig(ctx);
|
|
7
7
|
const finalConfig = await config.mergeConfigWithUserConfig(config$1, ctx);
|
|
8
|
+
// Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of
|
|
9
|
+
// its CJS entry, which emits "The CJS build of Vite's Node API is deprecated".
|
|
10
|
+
// https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
|
|
8
11
|
const { build: viteBuild } = await import('vite');
|
|
9
12
|
ctx.logger.debug('Vite config', finalConfig);
|
|
10
13
|
await viteBuild(finalConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sources":["../../../../src/node/vite/build.ts"],"sourcesContent":["import { mergeConfigWithUserConfig, resolveProductionConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\nconst build = async (ctx: BuildContext) => {\n const config = await resolveProductionConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n const { build: viteBuild } = await import('vite');\n\n ctx.logger.debug('Vite config', finalConfig);\n\n await viteBuild(finalConfig);\n};\n\nexport { build };\n"],"names":["build","ctx","config","resolveProductionConfig","finalConfig","mergeConfigWithUserConfig","viteBuild","logger","debug"],"mappings":";;;;AAIA,MAAMA,QAAQ,OAAOC,GAAAA,GAAAA;IACnB,MAAMC,QAAAA,GAAS,MAAMC,8BAAAA,CAAwBF,GAAAA,CAAAA;IAC7C,MAAMG,WAAAA,GAAc,MAAMC,gCAAAA,CAA0BH,QAAAA,EAAQD,GAAAA,CAAAA
|
|
1
|
+
{"version":3,"file":"build.js","sources":["../../../../src/node/vite/build.ts"],"sourcesContent":["import { mergeConfigWithUserConfig, resolveProductionConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\nconst build = async (ctx: BuildContext) => {\n const config = await resolveProductionConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n // Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of\n // its CJS entry, which emits \"The CJS build of Vite's Node API is deprecated\".\n // https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated\n const { build: viteBuild } = await import('vite');\n\n ctx.logger.debug('Vite config', finalConfig);\n\n await viteBuild(finalConfig);\n};\n\nexport { build };\n"],"names":["build","ctx","config","resolveProductionConfig","finalConfig","mergeConfigWithUserConfig","viteBuild","logger","debug"],"mappings":";;;;AAIA,MAAMA,QAAQ,OAAOC,GAAAA,GAAAA;IACnB,MAAMC,QAAAA,GAAS,MAAMC,8BAAAA,CAAwBF,GAAAA,CAAAA;IAC7C,MAAMG,WAAAA,GAAc,MAAMC,gCAAAA,CAA0BH,QAAAA,EAAQD,GAAAA,CAAAA;;;;AAK5D,IAAA,MAAM,EAAED,KAAAA,EAAOM,SAAS,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;AAE1CL,IAAAA,GAAAA,CAAIM,MAAM,CAACC,KAAK,CAAC,aAAA,EAAeJ,WAAAA,CAAAA;AAEhC,IAAA,MAAME,SAAAA,CAAUF,WAAAA,CAAAA;AAClB;;;;"}
|
|
@@ -3,6 +3,9 @@ import { resolveProductionConfig, mergeConfigWithUserConfig } from './config.mjs
|
|
|
3
3
|
const build = async (ctx)=>{
|
|
4
4
|
const config = await resolveProductionConfig(ctx);
|
|
5
5
|
const finalConfig = await mergeConfigWithUserConfig(config, ctx);
|
|
6
|
+
// Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of
|
|
7
|
+
// its CJS entry, which emits "The CJS build of Vite's Node API is deprecated".
|
|
8
|
+
// https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
|
|
6
9
|
const { build: viteBuild } = await import('vite');
|
|
7
10
|
ctx.logger.debug('Vite config', finalConfig);
|
|
8
11
|
await viteBuild(finalConfig);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.mjs","sources":["../../../../src/node/vite/build.ts"],"sourcesContent":["import { mergeConfigWithUserConfig, resolveProductionConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\nconst build = async (ctx: BuildContext) => {\n const config = await resolveProductionConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n const { build: viteBuild } = await import('vite');\n\n ctx.logger.debug('Vite config', finalConfig);\n\n await viteBuild(finalConfig);\n};\n\nexport { build };\n"],"names":["build","ctx","config","resolveProductionConfig","finalConfig","mergeConfigWithUserConfig","viteBuild","logger","debug"],"mappings":";;AAIA,MAAMA,QAAQ,OAAOC,GAAAA,GAAAA;IACnB,MAAMC,MAAAA,GAAS,MAAMC,uBAAAA,CAAwBF,GAAAA,CAAAA;IAC7C,MAAMG,WAAAA,GAAc,MAAMC,yBAAAA,CAA0BH,MAAAA,EAAQD,GAAAA,CAAAA
|
|
1
|
+
{"version":3,"file":"build.mjs","sources":["../../../../src/node/vite/build.ts"],"sourcesContent":["import { mergeConfigWithUserConfig, resolveProductionConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\nconst build = async (ctx: BuildContext) => {\n const config = await resolveProductionConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n // Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of\n // its CJS entry, which emits \"The CJS build of Vite's Node API is deprecated\".\n // https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated\n const { build: viteBuild } = await import('vite');\n\n ctx.logger.debug('Vite config', finalConfig);\n\n await viteBuild(finalConfig);\n};\n\nexport { build };\n"],"names":["build","ctx","config","resolveProductionConfig","finalConfig","mergeConfigWithUserConfig","viteBuild","logger","debug"],"mappings":";;AAIA,MAAMA,QAAQ,OAAOC,GAAAA,GAAAA;IACnB,MAAMC,MAAAA,GAAS,MAAMC,uBAAAA,CAAwBF,GAAAA,CAAAA;IAC7C,MAAMG,WAAAA,GAAc,MAAMC,yBAAAA,CAA0BH,MAAAA,EAAQD,GAAAA,CAAAA;;;;AAK5D,IAAA,MAAM,EAAED,KAAAA,EAAOM,SAAS,EAAE,GAAG,MAAM,OAAO,MAAA,CAAA;AAE1CL,IAAAA,GAAAA,CAAIM,MAAM,CAACC,KAAK,CAAC,aAAA,EAAeJ,WAAAA,CAAAA;AAEhC,IAAA,MAAME,SAAAA,CAAUF,WAAAA,CAAAA;AAClB;;;;"}
|
|
@@ -1,22 +1,30 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var react = require('@vitejs/plugin-react-swc');
|
|
4
3
|
var config = require('../core/config.js');
|
|
5
|
-
var
|
|
4
|
+
var adminViteAliasModules = require('../core/admin-vite-alias-modules.js');
|
|
5
|
+
var adminViteAliases = require('../core/admin-vite-aliases.js');
|
|
6
|
+
var adminViteOptimizeExclude = require('../core/admin-vite-optimize-exclude.js');
|
|
6
7
|
var linkedPackages = require('../core/linked-packages.js');
|
|
7
8
|
var monorepo = require('../core/monorepo.js');
|
|
8
9
|
var aliases = require('../core/aliases.js');
|
|
9
10
|
var plugins = require('./plugins.js');
|
|
10
11
|
|
|
11
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
12
|
-
|
|
13
|
-
var react__default = /*#__PURE__*/_interopDefault(react);
|
|
14
|
-
|
|
15
12
|
const resolveBaseConfig = async (ctx)=>{
|
|
16
13
|
const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');
|
|
17
14
|
const target = browserslistToEsbuild(ctx.target);
|
|
18
15
|
const isMonorepoExampleApp = ctx.strapi.internal_config?.uuid === 'getstarted';
|
|
19
16
|
const designSystemLinked = linkedPackages.isDesignSystemLinked();
|
|
17
|
+
const pluginOptimizeDepsExclude = await adminViteOptimizeExclude.collectAdminOptimizeDepsExclude(ctx.cwd, ctx.plugins);
|
|
18
|
+
const optimizeDepsExclude = [
|
|
19
|
+
...designSystemLinked ? [
|
|
20
|
+
'@strapi/design-system'
|
|
21
|
+
] : [],
|
|
22
|
+
...pluginOptimizeDepsExclude
|
|
23
|
+
];
|
|
24
|
+
// Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of
|
|
25
|
+
// its CJS entry, which emits "The CJS build of Vite's Node API is deprecated".
|
|
26
|
+
// https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
|
|
27
|
+
const { default: react } = await import('@vitejs/plugin-react-swc');
|
|
20
28
|
return {
|
|
21
29
|
root: ctx.cwd,
|
|
22
30
|
base: ctx.basePath,
|
|
@@ -33,12 +41,14 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
33
41
|
},
|
|
34
42
|
envPrefix: 'STRAPI_ADMIN_',
|
|
35
43
|
optimizeDeps: {
|
|
44
|
+
// Contract (#26964, #26944, #27014):
|
|
45
|
+
// - CJS packages imported by @strapi/admin MUST be in optimizeDeps.include (invariant, lodash, …).
|
|
46
|
+
// - The admin entry host (@strapi/strapi) MUST NOT be in optimizeDeps.exclude.
|
|
36
47
|
// When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling
|
|
37
|
-
// so changes are reflected without clearing node_modules/.strapi/vite cache
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]
|
|
48
|
+
// so changes are reflected without clearing node_modules/.strapi/vite cache.
|
|
49
|
+
// Also skip pre-built ESM plugin UI libraries with React peers (see collectAdminOptimizeDepsExclude).
|
|
50
|
+
...optimizeDepsExclude.length > 0 && {
|
|
51
|
+
exclude: optimizeDepsExclude
|
|
42
52
|
},
|
|
43
53
|
include: [
|
|
44
54
|
// pre-bundle React dependencies to avoid React duplicates,
|
|
@@ -61,11 +71,10 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
61
71
|
'@strapi/design-system'
|
|
62
72
|
] : [],
|
|
63
73
|
'@radix-ui/react-tooltip',
|
|
64
|
-
//
|
|
65
|
-
// is CommonJS-only; pre-bundling converts it to ESM for the browser
|
|
74
|
+
// CJS-only; required for @strapi/admin in dev (#26944, #26964, #27014).
|
|
66
75
|
'lodash',
|
|
67
|
-
|
|
68
|
-
//
|
|
76
|
+
'invariant',
|
|
77
|
+
// UMD; without pre-bundling plugin chunks get empty namespace → "Prism is not defined" (#26964).
|
|
69
78
|
'prismjs',
|
|
70
79
|
/**
|
|
71
80
|
* Pre-bundle other dependencies that would otherwise cause a page reload when imported.
|
|
@@ -130,32 +139,14 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
130
139
|
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
131
140
|
// Include design-system so plugin chunks use the same instance and inherit root context
|
|
132
141
|
dedupe: [
|
|
133
|
-
|
|
134
|
-
'react-dom',
|
|
135
|
-
'react-router-dom',
|
|
136
|
-
'styled-components',
|
|
137
|
-
'react-redux',
|
|
138
|
-
'@reduxjs/toolkit',
|
|
139
|
-
'@strapi/design-system',
|
|
140
|
-
'@radix-ui/react-tooltip',
|
|
141
|
-
'lodash'
|
|
142
|
+
...adminViteAliasModules.ADMIN_VITE_DEDUPE_MODULES
|
|
142
143
|
],
|
|
143
144
|
// Explicit aliases ensure resolution under pnpm's strict dependency isolation,
|
|
144
145
|
// where packages imported by plugins may not be resolvable from plugin chunks
|
|
145
|
-
alias:
|
|
146
|
-
react: resolveModule.getModulePath('react'),
|
|
147
|
-
'react-dom': resolveModule.getModulePath('react-dom'),
|
|
148
|
-
'react-router-dom': resolveModule.getModulePath('react-router-dom'),
|
|
149
|
-
'styled-components': resolveModule.getModulePath('styled-components'),
|
|
150
|
-
'react-redux': resolveModule.getModulePath('react-redux'),
|
|
151
|
-
'@reduxjs/toolkit': resolveModule.getModulePath('@reduxjs/toolkit'),
|
|
152
|
-
'@strapi/design-system': resolveModule.getModulePath('@strapi/design-system'),
|
|
153
|
-
'@radix-ui/react-tooltip': resolveModule.getModulePath('@radix-ui/react-tooltip'),
|
|
154
|
-
lodash: resolveModule.getModulePath('lodash')
|
|
155
|
-
}
|
|
146
|
+
alias: adminViteAliases.buildAdminViteResolveAliases()
|
|
156
147
|
},
|
|
157
148
|
plugins: [
|
|
158
|
-
|
|
149
|
+
react(),
|
|
159
150
|
plugins.buildFilesPlugin(ctx)
|
|
160
151
|
]
|
|
161
152
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\nimport { getModulePath } from '../core/resolve-module';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache\n ...(designSystemLinked && { exclude: ['@strapi/design-system'] }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // Pre-bundle lodash: design-system uses named imports (e.g. assignWith) but lodash\n // is CommonJS-only; pre-bundling converts it to ESM for the browser\n 'lodash',\n // Pre-bundle prismjs so plugin chunks get a valid ESM namespace (prismjs is UMD and can\n // otherwise expose an empty object when bundled, causing \"Prism is not defined\" in admin).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [\n 'react',\n 'react-dom',\n 'react-router-dom',\n 'styled-components',\n 'react-redux',\n '@reduxjs/toolkit',\n '@strapi/design-system',\n '@radix-ui/react-tooltip',\n 'lodash',\n ],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: {\n react: getModulePath('react'),\n 'react-dom': getModulePath('react-dom'),\n 'react-router-dom': getModulePath('react-router-dom'),\n 'styled-components': getModulePath('styled-components'),\n 'react-redux': getModulePath('react-redux'),\n '@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),\n '@strapi/design-system': getModulePath('@strapi/design-system'),\n '@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),\n lodash: getModulePath('lodash'),\n },\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n /**\n * In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).\n * Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).\n */\n allowedHosts: true,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n /**\n * Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener\n * plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that\n * only expose the Strapi server port (#23491, #23008).\n */\n server: ctx.strapi.server.httpServer,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","root","cwd","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","exclude","include","resolve","dedupe","alias","react","getModulePath","lodash","plugins","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","allowedHosts","middlewareMode","open","hmr","overlay","httpServer","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;;;;;;;AAWA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAE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A,CAAkBC,GAAAA,CAAAA;IAE3C,OAAO;AACL,QAAA,GAAGyC,UAAU;QACbE,IAAAA,EAAM,aAAA;QACNd,OAAAA,EAAS;AACP,YAAA,GAAGY,WAAWZ,OAAO;YACrBE,KAAAA,EAAO;gBACL,GAAGU,UAAAA,CAAWZ,OAAO,EAAEE,KAAK;AAC5B,gBAAA,GAAGqB,0BAAAA,CAAmB;AAAEF,8BAAAA;iBAAS;AACnC;AACF,SAAA;QACAG,MAAAA,EAAQ;YACNC,IAAAA,EAAM,KAAA;AACN;;;AAGC,UACDC,YAAAA,EAAc,IAAA;YACdC,cAAAA,EAAgB,IAAA;YAChBC,IAAAA,EAAMzD,GAAAA,CAAIsC,OAAO,CAACmB,IAAI;YACtBC,GAAAA,EAAK;gBACHC,OAAAA,EAAS,KAAA;AACT;;;;AAIC,YACDN,QAAQrD,GAAAA,CAAIK,MAAM,CAACgD,MAAM,CAACO;AAC5B;AACF,SAAA;QACAC,OAAAA,EAAS;AACX,KAAA;AACF;AAEA,MAAMC,YAAAA,GAAe;AAAC,IAAA,gBAAA;AAAkB,IAAA,iBAAA;AAAmB,IAAA,gBAAA;AAAkB,IAAA;AAAkB,CAAA;AAI/F,MAAMC,yBAAAA,GAA4B,OAAOC,QAAAA,EAAsBhE,GAAAA,GAAAA;IAC7D,MAAMiE,UAAAA,GAAa,MAAMC,oBAAAA,CAA8BJ,YAAAA,EAAc9D,GAAAA,CAAAA;AAErE,IAAA,IAAIiE,UAAAA,EAAY;AACd,QAAA,OAAOA,UAAAA,CAAWD,QAAAA,CAAAA;AACpB,IAAA;IAEA,OAAOA,QAAAA;AACT;;;;;;"}
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\n\nimport { getUserConfig } from '../core/config';\nimport { ADMIN_VITE_DEDUPE_MODULES } from '../core/admin-vite-alias-modules';\nimport { buildAdminViteResolveAliases } from '../core/admin-vite-aliases';\nimport { collectAdminOptimizeDepsExclude } from '../core/admin-vite-optimize-exclude';\nimport { isDesignSystemLinked } from '../core/linked-packages';\nimport { loadStrapiMonorepo } from '../core/monorepo';\nimport { getMonorepoAliases } from '../core/aliases';\nimport type { BuildContext } from '../create-build-context';\nimport { buildFilesPlugin } from './plugins';\n\nconst resolveBaseConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const { default: browserslistToEsbuild } = await import('browserslist-to-esbuild');\n const target = browserslistToEsbuild(ctx.target);\n const isMonorepoExampleApp = (ctx.strapi as any).internal_config?.uuid === 'getstarted';\n const designSystemLinked = isDesignSystemLinked();\n const pluginOptimizeDepsExclude = await collectAdminOptimizeDepsExclude(ctx.cwd, ctx.plugins);\n const optimizeDepsExclude = [\n ...(designSystemLinked ? ['@strapi/design-system'] : []),\n ...pluginOptimizeDepsExclude,\n ];\n\n // Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of\n // its CJS entry, which emits \"The CJS build of Vite's Node API is deprecated\".\n // https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated\n const { default: react } = await import('@vitejs/plugin-react-swc');\n\n return {\n root: ctx.cwd,\n base: ctx.basePath,\n build: {\n emptyOutDir: false, // Rely on CLI to do this\n outDir: ctx.distDir,\n target,\n },\n cacheDir: 'node_modules/.strapi/vite',\n configFile: false,\n define: {\n process: {},\n 'process.env': JSON.stringify(ctx.env),\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\n // Contract (#26964, #26944, #27014):\n // - CJS packages imported by @strapi/admin MUST be in optimizeDeps.include (invariant, lodash, …).\n // - The admin entry host (@strapi/strapi) MUST NOT be in optimizeDeps.exclude.\n // When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling\n // so changes are reflected without clearing node_modules/.strapi/vite cache.\n // Also skip pre-built ESM plugin UI libraries with React peers (see collectAdminOptimizeDepsExclude).\n ...(optimizeDepsExclude.length > 0 && { exclude: optimizeDepsExclude }),\n include: [\n // pre-bundle React dependencies to avoid React duplicates,\n // even if React dependencies are not direct dependencies\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n 'react',\n `react/jsx-runtime`,\n 'react-dom/client',\n 'styled-components',\n 'react-router-dom',\n // Admin + RTK Query share react-redux context; pre-bundle so dev chunks cannot load a\n // second copy (avoids \"could not find react-redux context value\" after upgrades / hoisting).\n 'react-redux',\n '@reduxjs/toolkit',\n // Pre-bundle design-system so plugin custom field chunks (dynamic imports) resolve\n // to the same instance as the main app. Otherwise TooltipProvider/DesignSystemProvider\n // context from the root is not seen by components in plugin chunks.\n // Omit when linked so local changes are picked up (see exclude above)\n ...(!designSystemLinked ? ['@strapi/design-system'] : []),\n '@radix-ui/react-tooltip',\n // CJS-only; required for @strapi/admin in dev (#26944, #26964, #27014).\n 'lodash',\n 'invariant',\n // UMD; without pre-bundling plugin chunks get empty namespace → \"Prism is not defined\" (#26964).\n 'prismjs',\n /**\n * Pre-bundle other dependencies that would otherwise cause a page reload when imported.\n * See \"performance\" section: https://vite.dev/guide/dep-pre-bundling.html#the-why\n * Only include dependencies for our internal example apps, otherwise it will break\n * real user apps that may not have those dependencies.\n */\n ...(isMonorepoExampleApp\n ? [\n '@dnd-kit/core',\n '@dnd-kit/sortable',\n '@dnd-kit/utilities',\n '@dnd-kit/modifiers',\n '@radix-ui/react-toolbar',\n 'codemirror5',\n 'codemirror5/addon/display/placeholder',\n 'date-fns-tz',\n 'date-fns/format',\n 'date-fns/formatISO',\n 'highlight.js',\n 'lodash/capitalize',\n 'lodash/fp',\n 'lodash/groupBy',\n 'lodash/has',\n 'lodash/isNil',\n 'lodash/locale',\n 'lodash/map',\n 'lodash/mapValues',\n 'lodash/pull',\n 'lodash/size',\n 'lodash/sortBy',\n 'lodash/tail',\n 'lodash/toLower',\n 'lodash/toNumber',\n 'lodash/toString',\n 'lodash/truncate',\n 'lodash/uniq',\n 'lodash/upperFirst',\n 'markdown-it',\n 'markdown-it-abbr',\n 'markdown-it-container',\n 'markdown-it-deflist',\n 'markdown-it-emoji',\n 'markdown-it-footnote',\n 'markdown-it-ins',\n 'markdown-it-mark',\n 'markdown-it-sub',\n 'markdown-it-sup',\n 'prismjs/components/*.js',\n 'react-colorful',\n 'react-dnd-html5-backend',\n 'react-window',\n 'semver',\n 'semver/functions/lt',\n 'semver/functions/valid',\n 'slate',\n 'slate-history',\n 'slate-react',\n 'motion',\n ]\n : []),\n ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n // Include design-system so plugin chunks use the same instance and inherit root context\n dedupe: [...ADMIN_VITE_DEDUPE_MODULES],\n // Explicit aliases ensure resolution under pnpm's strict dependency isolation,\n // where packages imported by plugins may not be resolvable from plugin chunks\n alias: buildAdminViteResolveAliases(),\n },\n plugins: [react(), buildFilesPlugin(ctx)],\n };\n};\n\nconst resolveProductionConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const {\n options: { minify, sourcemaps },\n } = ctx;\n\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n logLevel: 'silent',\n mode: 'production',\n build: {\n ...baseConfig.build,\n assetsDir: '',\n minify,\n sourcemap: sourcemaps,\n rollupOptions: {\n input: {\n strapi: ctx.entry,\n },\n },\n },\n };\n};\n\nconst resolveDevelopmentConfig = async (ctx: BuildContext): Promise<InlineConfig> => {\n const monorepo = await loadStrapiMonorepo(ctx.cwd);\n const baseConfig = await resolveBaseConfig(ctx);\n\n return {\n ...baseConfig,\n mode: 'development',\n resolve: {\n ...baseConfig.resolve,\n alias: {\n ...baseConfig.resolve?.alias,\n ...getMonorepoAliases({ monorepo }),\n },\n },\n server: {\n cors: false,\n /**\n * In middleware mode Strapi forwards the browser Host from reverse proxies (nginx, Traefik).\n * Vite 5+ blocks unknown hosts unless explicitly allowed (#23491).\n */\n allowedHosts: true,\n middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n overlay: false,\n /**\n * Use Strapi's http.Server so HMR websockets reuse the app's listen port. A separate listener\n * plus clientPort pushes browsers toward host:5173-style URLs that fail behind proxies that\n * only expose the Strapi server port (#23491, #23008).\n */\n server: ctx.strapi.server.httpServer,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts', 'vite.config.mts'];\n\ntype UserViteConfig = (config: UserConfig) => UserConfig;\n\nconst mergeConfigWithUserConfig = async (config: InlineConfig, ctx: BuildContext) => {\n const userConfig = await getUserConfig<UserViteConfig>(USER_CONFIGS, ctx);\n\n if (userConfig) {\n return userConfig(config);\n }\n\n return config;\n};\n\nexport { mergeConfigWithUserConfig, resolveProductionConfig, resolveDevelopmentConfig };\n"],"names":["resolveBaseConfig","ctx","default","browserslistToEsbuild","target","isMonorepoExampleApp","strapi","internal_config","uuid","designSystemLinked","isDesignSystemLinked","pluginOptimizeDepsExclude","collectAdminOptimizeDepsExclude","cwd","plugins","optimizeDepsExclude","react","root","base","basePath","build","emptyOutDir","outDir","distDir","cacheDir","configFile","define","process","JSON","stringify","env","envPrefix","optimizeDeps","length","exclude","include","resolve","dedupe","ADMIN_VITE_DEDUPE_MODULES","alias","buildAdminViteResolveAliases","buildFilesPlugin","resolveProductionConfig","options","minify","sourcemaps","baseConfig","logLevel","mode","assetsDir","sourcemap","rollupOptions","input","entry","resolveDevelopmentConfig","monorepo","loadStrapiMonorepo","getMonorepoAliases","server","cors","allowedHosts","middlewareMode","open","hmr","overlay","httpServer","appType","USER_CONFIGS","mergeConfigWithUserConfig","config","userConfig","getUserConfig"],"mappings":";;;;;;;;;;;AAYA,MAAMA,oBAAoB,OAAOC,GAAAA,GAAAA;AAC/B,IAAA,MAAM,EAAEC,OAAAA,EAASC,qBAAqB,EAAE,GAAG,MAAM,OAAO,yBAAA,CAAA;IACxD,MAAMC,MAAAA,GAASD,qBAAAA,CAAsBF,GAAAA,CAAIG,MAAM,CAAA;AAC/C,IAAA,MAAMC,uBAAuB,GAACJ,CAAIK,MAAM,CAASC,eAAe,EAAEC,IAAAA,KAAS,YAA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;;;AAIC,YACDN,QAAQzD,GAAAA,CAAIK,MAAM,CAACoD,MAAM,CAACO;AAC5B;AACF,SAAA;QACAC,OAAAA,EAAS;AACX,KAAA;AACF;AAEA,MAAMC,YAAAA,GAAe;AAAC,IAAA,gBAAA;AAAkB,IAAA,iBAAA;AAAmB,IAAA,gBAAA;AAAkB,IAAA;AAAkB,CAAA;AAI/F,MAAMC,yBAAAA,GAA4B,OAAOC,QAAAA,EAAsBpE,GAAAA,GAAAA;IAC7D,MAAMqE,UAAAA,GAAa,MAAMC,oBAAAA,CAA8BJ,YAAAA,EAAclE,GAAAA,CAAAA;AAErE,IAAA,IAAIqE,UAAAA,EAAY;AACd,QAAA,OAAOA,UAAAA,CAAWD,QAAAA,CAAAA;AACpB,IAAA;IAEA,OAAOA,QAAAA;AACT;;;;;;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import react from '@vitejs/plugin-react-swc';
|
|
2
1
|
import { getUserConfig } from '../core/config.mjs';
|
|
3
|
-
import {
|
|
2
|
+
import { ADMIN_VITE_DEDUPE_MODULES } from '../core/admin-vite-alias-modules.mjs';
|
|
3
|
+
import { buildAdminViteResolveAliases } from '../core/admin-vite-aliases.mjs';
|
|
4
|
+
import { collectAdminOptimizeDepsExclude } from '../core/admin-vite-optimize-exclude.mjs';
|
|
4
5
|
import { isDesignSystemLinked } from '../core/linked-packages.mjs';
|
|
5
6
|
import { loadStrapiMonorepo } from '../core/monorepo.mjs';
|
|
6
7
|
import { getMonorepoAliases } from '../core/aliases.mjs';
|
|
@@ -11,6 +12,17 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
11
12
|
const target = browserslistToEsbuild(ctx.target);
|
|
12
13
|
const isMonorepoExampleApp = ctx.strapi.internal_config?.uuid === 'getstarted';
|
|
13
14
|
const designSystemLinked = isDesignSystemLinked();
|
|
15
|
+
const pluginOptimizeDepsExclude = await collectAdminOptimizeDepsExclude(ctx.cwd, ctx.plugins);
|
|
16
|
+
const optimizeDepsExclude = [
|
|
17
|
+
...designSystemLinked ? [
|
|
18
|
+
'@strapi/design-system'
|
|
19
|
+
] : [],
|
|
20
|
+
...pluginOptimizeDepsExclude
|
|
21
|
+
];
|
|
22
|
+
// Imported dynamically so this file's CJS build resolves Vite's ESM Node API instead of
|
|
23
|
+
// its CJS entry, which emits "The CJS build of Vite's Node API is deprecated".
|
|
24
|
+
// https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated
|
|
25
|
+
const { default: react } = await import('@vitejs/plugin-react-swc');
|
|
14
26
|
return {
|
|
15
27
|
root: ctx.cwd,
|
|
16
28
|
base: ctx.basePath,
|
|
@@ -27,12 +39,14 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
27
39
|
},
|
|
28
40
|
envPrefix: 'STRAPI_ADMIN_',
|
|
29
41
|
optimizeDeps: {
|
|
42
|
+
// Contract (#26964, #26944, #27014):
|
|
43
|
+
// - CJS packages imported by @strapi/admin MUST be in optimizeDeps.include (invariant, lodash, …).
|
|
44
|
+
// - The admin entry host (@strapi/strapi) MUST NOT be in optimizeDeps.exclude.
|
|
30
45
|
// When design-system is linked (portal:, file:, yarn link), exclude from pre-bundling
|
|
31
|
-
// so changes are reflected without clearing node_modules/.strapi/vite cache
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
]
|
|
46
|
+
// so changes are reflected without clearing node_modules/.strapi/vite cache.
|
|
47
|
+
// Also skip pre-built ESM plugin UI libraries with React peers (see collectAdminOptimizeDepsExclude).
|
|
48
|
+
...optimizeDepsExclude.length > 0 && {
|
|
49
|
+
exclude: optimizeDepsExclude
|
|
36
50
|
},
|
|
37
51
|
include: [
|
|
38
52
|
// pre-bundle React dependencies to avoid React duplicates,
|
|
@@ -55,11 +69,10 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
55
69
|
'@strapi/design-system'
|
|
56
70
|
] : [],
|
|
57
71
|
'@radix-ui/react-tooltip',
|
|
58
|
-
//
|
|
59
|
-
// is CommonJS-only; pre-bundling converts it to ESM for the browser
|
|
72
|
+
// CJS-only; required for @strapi/admin in dev (#26944, #26964, #27014).
|
|
60
73
|
'lodash',
|
|
61
|
-
|
|
62
|
-
//
|
|
74
|
+
'invariant',
|
|
75
|
+
// UMD; without pre-bundling plugin chunks get empty namespace → "Prism is not defined" (#26964).
|
|
63
76
|
'prismjs',
|
|
64
77
|
/**
|
|
65
78
|
* Pre-bundle other dependencies that would otherwise cause a page reload when imported.
|
|
@@ -124,29 +137,11 @@ const resolveBaseConfig = async (ctx)=>{
|
|
|
124
137
|
// https://react.dev/warnings/invalid-hook-call-warning#duplicate-react
|
|
125
138
|
// Include design-system so plugin chunks use the same instance and inherit root context
|
|
126
139
|
dedupe: [
|
|
127
|
-
|
|
128
|
-
'react-dom',
|
|
129
|
-
'react-router-dom',
|
|
130
|
-
'styled-components',
|
|
131
|
-
'react-redux',
|
|
132
|
-
'@reduxjs/toolkit',
|
|
133
|
-
'@strapi/design-system',
|
|
134
|
-
'@radix-ui/react-tooltip',
|
|
135
|
-
'lodash'
|
|
140
|
+
...ADMIN_VITE_DEDUPE_MODULES
|
|
136
141
|
],
|
|
137
142
|
// Explicit aliases ensure resolution under pnpm's strict dependency isolation,
|
|
138
143
|
// where packages imported by plugins may not be resolvable from plugin chunks
|
|
139
|
-
alias:
|
|
140
|
-
react: getModulePath('react'),
|
|
141
|
-
'react-dom': getModulePath('react-dom'),
|
|
142
|
-
'react-router-dom': getModulePath('react-router-dom'),
|
|
143
|
-
'styled-components': getModulePath('styled-components'),
|
|
144
|
-
'react-redux': getModulePath('react-redux'),
|
|
145
|
-
'@reduxjs/toolkit': getModulePath('@reduxjs/toolkit'),
|
|
146
|
-
'@strapi/design-system': getModulePath('@strapi/design-system'),
|
|
147
|
-
'@radix-ui/react-tooltip': getModulePath('@radix-ui/react-tooltip'),
|
|
148
|
-
lodash: getModulePath('lodash')
|
|
149
|
-
}
|
|
144
|
+
alias: buildAdminViteResolveAliases()
|
|
150
145
|
},
|
|
151
146
|
plugins: [
|
|
152
147
|
react(),
|