@strapi/strapi 5.0.0-rc.0 → 5.0.0-rc.1
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/admin.d.ts.map +1 -1
- package/dist/admin.js +0 -1
- package/dist/admin.js.map +1 -1
- package/dist/admin.mjs +0 -1
- package/dist/admin.mjs.map +1 -1
- package/dist/node/create-build-context.d.ts +4 -0
- package/dist/node/create-build-context.d.ts.map +1 -1
- package/dist/node/create-build-context.js.map +1 -1
- package/dist/node/create-build-context.mjs.map +1 -1
- package/dist/node/vite/config.d.ts.map +1 -1
- package/dist/node/vite/config.js +4 -1
- package/dist/node/vite/config.js.map +1 -1
- package/dist/node/vite/config.mjs +4 -1
- package/dist/node/vite/config.mjs.map +1 -1
- package/dist/node/vite/watch.d.ts.map +1 -1
- package/dist/node/vite/watch.js +31 -0
- package/dist/node/vite/watch.js.map +1 -1
- package/dist/node/vite/watch.mjs +30 -0
- package/dist/node/vite/watch.mjs.map +1 -1
- package/package.json +23 -23
package/dist/admin.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAU1E,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,
|
|
1
|
+
{"version":3,"file":"admin.d.ts","sourceRoot":"","sources":["../src/admin.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAe,MAAM,4BAA4B,CAAC;AAU1E,QAAA,MAAM,MAAM,cAAe,WAAW,GAAG,IAAI,4BAA4B,eAAe,kBAiBvF,CAAC;AAEF,OAAO,EAAE,MAAM,IAAI,WAAW,EAAE,CAAC;AACjC,YAAY,EAAE,eAAe,EAAE,CAAC;AAEhC,cAAc,4BAA4B,CAAC"}
|
package/dist/admin.js
CHANGED
|
@@ -20,7 +20,6 @@ const render = (mountNode, { plugins, ...restArgs }) => {
|
|
|
20
20
|
return strapiAdmin.renderAdmin(mountNode, {
|
|
21
21
|
...restArgs,
|
|
22
22
|
plugins: {
|
|
23
|
-
// @ts-expect-error – TODO: fix this
|
|
24
23
|
"content-manager": contentManager__default.default,
|
|
25
24
|
"content-type-builder": contentTypeBuilder__default.default,
|
|
26
25
|
// @ts-expect-error – TODO: fix this
|
package/dist/admin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n
|
|
1
|
+
{"version":3,"file":"admin.js","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n"],"names":["renderAdmin","contentManager","contentTypeBuilder","email","upload","contentReleases","i18n","reviewWorkflows"],"mappings":";;;;;;;;;;;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAOA,YAAAA,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmBC,wBAAA;AAAA,MACnB,wBAAwBC,4BAAA;AAAA;AAAA,MAAA,OAExBC,eAAA;AAAA,MAAA,QACAC,gBAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MAAA,MACAC,cAAA;AAAA;AAAA,MAAA,iBAEAC,yBAAA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;;;;;;;;;"}
|
package/dist/admin.mjs
CHANGED
|
@@ -11,7 +11,6 @@ const render = (mountNode, { plugins, ...restArgs }) => {
|
|
|
11
11
|
return renderAdmin(mountNode, {
|
|
12
12
|
...restArgs,
|
|
13
13
|
plugins: {
|
|
14
|
-
// @ts-expect-error – TODO: fix this
|
|
15
14
|
"content-manager": contentManager,
|
|
16
15
|
"content-type-builder": contentTypeBuilder,
|
|
17
16
|
// @ts-expect-error – TODO: fix this
|
package/dist/admin.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n
|
|
1
|
+
{"version":3,"file":"admin.mjs","sources":["../src/admin.ts"],"sourcesContent":["import { RenderAdminArgs, renderAdmin } from '@strapi/admin/strapi-admin';\nimport contentTypeBuilder from '@strapi/content-type-builder/strapi-admin';\nimport contentManager from '@strapi/content-manager/strapi-admin';\nimport email from '@strapi/email/strapi-admin';\n// @ts-expect-error – No types, yet.\nimport upload from '@strapi/upload/strapi-admin';\nimport i18n from '@strapi/i18n/strapi-admin';\nimport contentReleases from '@strapi/content-releases/strapi-admin';\nimport reviewWorkflows from '@strapi/review-workflows/strapi-admin';\n\nconst render = (mountNode: HTMLElement | null, { plugins, ...restArgs }: RenderAdminArgs) => {\n return renderAdmin(mountNode, {\n ...restArgs,\n plugins: {\n 'content-manager': contentManager,\n 'content-type-builder': contentTypeBuilder,\n // @ts-expect-error – TODO: fix this\n email,\n upload,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n contentReleases,\n i18n,\n // @ts-expect-error – TODO: fix this, the \"types\" folder has it wrong.\n reviewWorkflows,\n ...plugins,\n },\n });\n};\n\nexport { render as renderAdmin };\nexport type { RenderAdminArgs };\n\nexport * from '@strapi/admin/strapi-admin';\n"],"names":[],"mappings":";;;;;;;;;AAUA,MAAM,SAAS,CAAC,WAA+B,EAAE,SAAS,GAAG,eAAgC;AAC3F,SAAO,YAAY,WAAW;AAAA,IAC5B,GAAG;AAAA,IACH,SAAS;AAAA,MACP,mBAAmB;AAAA,MACnB,wBAAwB;AAAA;AAAA,MAExB;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA;AAAA;AAAA,MAEA;AAAA,MACA,GAAG;AAAA,IACL;AAAA,EAAA,CACD;AACH;"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
1
2
|
import { Core, Modules } from '@strapi/types';
|
|
3
|
+
import type { Server } from 'node:http';
|
|
2
4
|
import type { CLIContext } from '../cli/types';
|
|
3
5
|
import { PluginMeta } from './core/plugins';
|
|
4
6
|
import { AppFile } from './core/admin-customisations';
|
|
@@ -9,6 +11,8 @@ interface BaseOptions {
|
|
|
9
11
|
sourcemaps?: boolean;
|
|
10
12
|
bundler?: 'webpack' | 'vite';
|
|
11
13
|
open?: boolean;
|
|
14
|
+
hmrServer?: Server;
|
|
15
|
+
hmrClientPort?: number;
|
|
12
16
|
}
|
|
13
17
|
interface BuildContext<TOptions = unknown> extends BaseContext {
|
|
14
18
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-build-context.d.ts","sourceRoot":"","sources":["../../src/node/create-build-context.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"create-build-context.d.ts","sourceRoot":"","sources":["../../src/node/create-build-context.ts"],"names":[],"mappings":";AAKA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AAExC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAG/C,OAAO,EAAE,UAAU,EAA+C,MAAM,gBAAgB,CAAC;AACzF,OAAO,EAAE,OAAO,EAAmB,MAAM,6BAA6B,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAE3C,UAAU,WAAW;IACnB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,CAAC,EAAE,SAAS,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,YAAY,CAAC,QAAQ,GAAG,OAAO,CAAE,SAAQ,WAAW;IAC5D;;OAEG;IACH,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB;;OAEG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAC,QAAQ,CAAC,CAAC;IACtD;;OAEG;IACH,OAAO,EAAE,WAAW,GAAG,QAAQ,CAAC;IAChC;;;OAGG;IACH,OAAO,EAAE,UAAU,EAAE,CAAC;CACvB;AAED,UAAU,sBAAsB,CAAC,QAAQ,GAAG,OAAO,CAAE,SAAQ,UAAU;IACrE,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC;IACrB,OAAO,CAAC,EAAE,QAAQ,CAAC;CACpB;AASD,QAAA,MAAM,kBAAkB,8EAMrB,uBAAuB,QAAQ,CAAC,KAAG,QAAQ,aAAa,QAAQ,CAAC,CAgGnE,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC;AAC9B,YAAY,EAAE,YAAY,EAAE,sBAAsB,EAAE,CAAC"}
|
|
@@ -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 { 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 serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPath,\n STRAPI_ADMIN_BACKEND_URL: serverUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\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 basePath: `${adminPath}/`,\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":["createStrapi","loadEnv","env","getStrapiAdminEnvVars","os","path","fs","plugins","getEnabledPlugins","getMapOfPluginsWithAdmin","browserslist","loadUserAppFile"],"mappings":";;;;;;;;;;;;;;;
|
|
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 { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\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 hmrServer?: Server;\n hmrClientPort?: number;\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 serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPath,\n STRAPI_ADMIN_BACKEND_URL: serverUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\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 basePath: `${adminPath}/`,\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":["createStrapi","loadEnv","env","getStrapiAdminEnvVars","os","path","fs","plugins","getEnabledPlugins","getMapOfPluginsWithAdmin","browserslist","loadUserAppFile"],"mappings":";;;;;;;;;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAC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KAAK,YAAY,QAAQ,CAAC;AAE1D,QAAAE,YAAU,MAAMC,QAAkB,kBAAA,EAAE,KAAK,QAAQ,YAAY,QAAQ,eAAA,CAAgB;AAE3F,SAAO,MAAM,mBAAmBJ,YAAG,QAAA,KAAKG,SAAO;AAEzC,QAAA,mBAAmBE,iCAAyBF,SAAO;AAEzD,SAAO,MAAM,2BAA2BH,YAAG,QAAA,KAAK,gBAAgB;AAEhE,QAAM,SAASM,sBAAAA,QAAa,WAAW,EAAE,MAAM,IAAA,CAAK,KAAK;AAEzD,QAAM,iBAAiB,MAAMC,oBAAA,gBAAgB,EAAE,QAAQ,WAAY,CAAA;AAEnE,QAAM,WAAW,eAAe,OAAO,IAAI,YAAY,MAAS;AAEhE,QAAM,EAAE,UAAU,QAAQ,GAAG,gBAAgB;AAE7C,QAAM,eAAe;AAAA,IACnB;AAAA,IACA,UAAU,GAAG,SAAS;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IAAA,KACAT;AAAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EAAA;AAGK,SAAA;AACT;;"}
|
|
@@ -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 { 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 serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPath,\n STRAPI_ADMIN_BACKEND_URL: serverUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\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 basePath: `${adminPath}/`,\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":[],"mappings":";;;;;;;;
|
|
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 { Core, Modules } from '@strapi/types';\nimport type { Server } from 'node:http';\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 hmrServer?: Server;\n hmrClientPort?: number;\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 serverUrl = strapiInstance.config.get<string>('server.url');\n const adminPath = strapiInstance.config.get<string>('admin.path');\n\n const appDir = strapiInstance.dirs.app.root;\n\n await loadEnv(cwd);\n\n const env = getStrapiAdminEnvVars({\n ADMIN_PATH: adminPath,\n STRAPI_ADMIN_BACKEND_URL: serverUrl,\n STRAPI_TELEMETRY_DISABLED: String(strapiInstance.telemetry.isDisabled),\n });\n\n const envKeys = Object.keys(env);\n\n if (envKeys.length > 0) {\n logger.info(\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 basePath: `${adminPath}/`,\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":[],"mappings":";;;;;;;;AAkDA,MAAM,uBAAuB;AAAA,EAC3B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAEA,MAAM,qBAAqB,OAAqC;AAAA,EAC9D;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,UAAU,CAAC;AACb,MAAyE;AAMjE,QAAA,iBACJ,UACA,aAAa;AAAA;AAAA,IAEX,QAAQ;AAAA,IACR,SAAS,UAAU,OAAO,QAAQ,UAAU;AAAA;AAAA,IAE5C,YAAY;AAAA,IACZ,iBAAiB;AAAA,EAAA,CAClB;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E,QAAQ,WAAY,CAAA;AAEnE,QAAM,WAAW,eAAe,OAAO,IAAI,YAAY,MAAS;AAEhE,QAAM,EAAE,UAAU,QAAQ,GAAG,gBAAgB;AAE7C,QAAM,eAAe;AAAA,IACnB;AAAA,IACA,UAAU,GAAG,SAAS;AAAA,IACtB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA,SAAS;AAAA,IACT,SAAS;AAAA,IACT;AAAA,IACA,QAAQ;AAAA,IACR;AAAA,IACA;AAAA,EAAA;AAGK,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/node/vite/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAuC5D,QAAA,MAAM,uBAAuB,QAAe,YAAY,KAAG,QAAQ,YAAY,CAwB9E,CAAC;AAEF,QAAA,MAAM,wBAAwB,QAAe,YAAY,KAAG,QAAQ,YAAY,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/node/vite/config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAOrD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAuC5D,QAAA,MAAM,uBAAuB,QAAe,YAAY,KAAG,QAAQ,YAAY,CAwB9E,CAAC;AAEF,QAAA,MAAM,wBAAwB,QAAe,YAAY,KAAG,QAAQ,YAAY,CAwB/E,CAAC;AAMF,QAAA,MAAM,yBAAyB,WAAkB,YAAY,OAAO,YAAY,wBAQ/E,CAAC;AAEF,OAAO,EAAE,yBAAyB,EAAE,uBAAuB,EAAE,wBAAwB,EAAE,CAAC"}
|
package/dist/node/vite/config.js
CHANGED
|
@@ -83,7 +83,10 @@ const resolveDevelopmentConfig = async (ctx) => {
|
|
|
83
83
|
server: {
|
|
84
84
|
middlewareMode: true,
|
|
85
85
|
open: ctx.options.open,
|
|
86
|
-
hmr: {
|
|
86
|
+
hmr: {
|
|
87
|
+
server: ctx.options.hmrServer,
|
|
88
|
+
clientPort: ctx.options.hmrClientPort
|
|
89
|
+
}
|
|
87
90
|
},
|
|
88
91
|
appType: "custom"
|
|
89
92
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sources":["../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\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 target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\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.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\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 ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\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 base: ctx.basePath,\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 middlewareMode: true,\n open: ctx.options.open,\n hmr: {
|
|
1
|
+
{"version":3,"file":"config.js","sources":["../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\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 target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\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.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\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 ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\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 base: ctx.basePath,\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 middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\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":["browserslistToEsbuild","react","buildFilesPlugin","monorepo","loadStrapiMonorepo","getMonorepoAliases","config","getUserConfig"],"mappings":";;;;;;;;;;;AAUA,MAAM,oBAAoB,OAAO,QAA6C;AACtE,QAAA,SAASA,+BAAAA,QAAsB,IAAI,MAAM;AAExC,SAAA;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mB,EAAEF,UAAAA,YAAU;AAAA,MACpC;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,gBAAgB;AAAA,MAChB,MAAM,IAAI,QAAQ;AAAA,MAClB,KAAK;AAAA,QACH,QAAQ,IAAI,QAAQ;AAAA,QACpB,YAAY,IAAI,QAAQ;AAAA,MAC1B;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;AAEA,MAAM,eAAe,CAAC,kBAAkB,mBAAmB,gBAAgB;AAIrE,MAAA,4BAA4B,OAAOG,UAAsB,QAAsB;AACnF,QAAM,aAAa,MAAMC,OAAAA,cAA8B,cAAc,GAAG;AAExE,MAAI,YAAY;AACd,WAAO,WAAWD,QAAM;AAAA,EAC1B;AAEO,SAAAA;AACT;;;;"}
|
|
@@ -78,7 +78,10 @@ const resolveDevelopmentConfig = async (ctx) => {
|
|
|
78
78
|
server: {
|
|
79
79
|
middlewareMode: true,
|
|
80
80
|
open: ctx.options.open,
|
|
81
|
-
hmr: {
|
|
81
|
+
hmr: {
|
|
82
|
+
server: ctx.options.hmrServer,
|
|
83
|
+
clientPort: ctx.options.hmrClientPort
|
|
84
|
+
}
|
|
82
85
|
},
|
|
83
86
|
appType: "custom"
|
|
84
87
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.mjs","sources":["../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\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 target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\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.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\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 ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\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 base: ctx.basePath,\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 middlewareMode: true,\n open: ctx.options.open,\n hmr: {
|
|
1
|
+
{"version":3,"file":"config.mjs","sources":["../../../src/node/vite/config.ts"],"sourcesContent":["import type { InlineConfig, UserConfig } from 'vite';\nimport browserslistToEsbuild from 'browserslist-to-esbuild';\nimport react from '@vitejs/plugin-react-swc';\n\nimport { getUserConfig } from '../core/config';\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 target = browserslistToEsbuild(ctx.target);\n\n return {\n root: ctx.cwd,\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.env': ctx.env,\n },\n envPrefix: 'STRAPI_ADMIN_',\n optimizeDeps: {\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 ],\n },\n resolve: {\n // https://react.dev/warnings/invalid-hook-call-warning#duplicate-react\n dedupe: ['react', 'react-dom', 'react-router-dom', 'styled-components'],\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 base: ctx.basePath,\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 middlewareMode: true,\n open: ctx.options.open,\n hmr: {\n server: ctx.options.hmrServer,\n clientPort: ctx.options.hmrClientPort,\n },\n },\n appType: 'custom',\n };\n};\n\nconst USER_CONFIGS = ['vite.config.js', 'vite.config.mjs', 'vite.config.ts'];\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":[],"mappings":";;;;;;AAUA,MAAM,oBAAoB,OAAO,QAA6C;AACtE,QAAA,SAAS,sBAAsB,IAAI,MAAM;AAExC,SAAA;AAAA,IACL,MAAM,IAAI;AAAA,IACV,OAAO;AAAA,MACL,aAAa;AAAA;AAAA,MACb,QAAQ,IAAI;AAAA,MACZ;AAAA,IACF;AAAA,IACA,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,QAAQ;AAAA,MACN,eAAe,IAAI;AAAA,IACrB;AAAA,IACA,WAAW;AAAA,IACX,cAAc;AAAA,MACZ,SAAS;AAAA;AAAA;AAAA;AAAA,QAIP;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,QACA;AAAA,MACF;AAAA,IACF;AAAA,IACA,SAAS;AAAA;AAAA,MAEP,QAAQ,CAAC,SAAS,aAAa,oBAAoB,mBAAmB;AAAA,IACxE;AAAA,IACA,SAAS,CAAC,MAAA,GAAS,iBAAiB,GAAG,CAAC;AAAA,EAAA;AAE5C;AAEM,MAAA,0BAA0B,OAAO,QAA6C;AAC5E,QAAA;AAAA,IACJ,SAAS,EAAE,QAAQ,WAAW;AAAA,EAC5B,IAAA;AAEE,QAAA,aAAa,MAAM,kBAAkB,GAAG;AAEvC,SAAA;AAAA,IACL,GAAG;AAAA,IACH,MAAM,IAAI;AAAA,IACV,UAAU;AAAA,IACV,MAAM;AAAA,IACN,OAAO;AAAA,MACL,GAAG,WAAW;AAAA,MACd,WAAW;AAAA,MACX;AAAA,MACA,WAAW;AAAA,MACX,eAAe;AAAA,QACb,OAAO;AAAA,UACL,QAAQ,IAAI;AAAA,QACd;AAAA,MACF;AAAA,IACF;AAAA,EAAA;AAEJ;AAEM,MAAA,2BAA2B,OAAO,QAA6C;AACnF,QAAM,WAAW,MAAM,mBAAmB,IAAI,GAAG;AAC3C,QAAA,aAAa,MAAM,kBAAkB,GAAG;AAEvC,SAAA;AAAA,IACL,GAAG;AAAA,IACH,MAAM;AAAA,IACN,SAAS;AAAA,MACP,GAAG,WAAW;AAAA,MACd,OAAO;AAAA,QACL,GAAG,WAAW,SAAS;AAAA,QACvB,GAAG,mBAAmB,EAAE,UAAU;AAAA,MACpC;AAAA,IACF;AAAA,IACA,QAAQ;AAAA,MACN,gBAAgB;AAAA,MAChB,MAAM,IAAI,QAAQ;AAAA,MAClB,KAAK;AAAA,QACH,QAAQ,IAAI,QAAQ;AAAA,QACpB,YAAY,IAAI,QAAQ;AAAA,MAC1B;AAAA,IACF;AAAA,IACA,SAAS;AAAA,EAAA;AAEb;AAEA,MAAM,eAAe,CAAC,kBAAkB,mBAAmB,gBAAgB;AAIrE,MAAA,4BAA4B,OAAO,QAAsB,QAAsB;AACnF,QAAM,aAAa,MAAM,cAA8B,cAAc,GAAG;AAExE,MAAI,YAAY;AACd,WAAO,WAAW,MAAM;AAAA,EAC1B;AAEO,SAAA;AACT;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/node/vite/watch.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.d.ts","sourceRoot":"","sources":["../../../src/node/vite/watch.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,yBAAyB,CAAC;AAE5D,UAAU,WAAW;IACnB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CACxB;AAqBD,QAAA,MAAM,KAAK,QAAe,YAAY,KAAG,QAAQ,WAAW,CAgF3D,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,CAAC;AACjB,YAAY,EAAE,WAAW,EAAE,CAAC"}
|
package/dist/node/vite/watch.js
CHANGED
|
@@ -23,14 +23,40 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
23
|
));
|
|
24
24
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
25
25
|
const path = require("node:path");
|
|
26
|
+
const http = require("node:http");
|
|
26
27
|
const fs = require("node:fs/promises");
|
|
27
28
|
const config = require("./config.js");
|
|
28
29
|
const _interopDefault = (e) => e && e.__esModule ? e : { default: e };
|
|
29
30
|
const path__default = /* @__PURE__ */ _interopDefault(path);
|
|
31
|
+
const http__default = /* @__PURE__ */ _interopDefault(http);
|
|
30
32
|
const fs__default = /* @__PURE__ */ _interopDefault(fs);
|
|
33
|
+
const HMR_DEFAULT_PORT = 5173;
|
|
34
|
+
const createHMRServer = () => {
|
|
35
|
+
return http__default.default.createServer(
|
|
36
|
+
// http server request handler. keeps the same with
|
|
37
|
+
// https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96
|
|
38
|
+
(_, res) => {
|
|
39
|
+
const body = http__default.default.STATUS_CODES[426];
|
|
40
|
+
res.writeHead(426, {
|
|
41
|
+
"Content-Length": body?.length ?? 0,
|
|
42
|
+
"Content-Type": "text/plain"
|
|
43
|
+
});
|
|
44
|
+
res.end(body);
|
|
45
|
+
}
|
|
46
|
+
);
|
|
47
|
+
};
|
|
31
48
|
const watch = async (ctx) => {
|
|
49
|
+
const hmrServer = createHMRServer();
|
|
50
|
+
ctx.options.hmrServer = hmrServer;
|
|
51
|
+
ctx.options.hmrClientPort = HMR_DEFAULT_PORT;
|
|
32
52
|
const config$1 = await config.resolveDevelopmentConfig(ctx);
|
|
33
53
|
const finalConfig = await config.mergeConfigWithUserConfig(config$1, ctx);
|
|
54
|
+
const hmrConfig = config$1.server?.hmr;
|
|
55
|
+
if (typeof hmrConfig === "object" && hmrConfig.server === hmrServer) {
|
|
56
|
+
strapi.server.httpServer.on("listening", async () => {
|
|
57
|
+
hmrServer.listen(hmrConfig.clientPort ?? hmrConfig.port ?? HMR_DEFAULT_PORT);
|
|
58
|
+
});
|
|
59
|
+
}
|
|
34
60
|
ctx.logger.debug("Vite config", finalConfig);
|
|
35
61
|
const { createServer } = await import("vite");
|
|
36
62
|
const vite = await createServer(finalConfig);
|
|
@@ -70,6 +96,11 @@ const watch = async (ctx) => {
|
|
|
70
96
|
return {
|
|
71
97
|
async close() {
|
|
72
98
|
await vite.close();
|
|
99
|
+
if (hmrServer.listening) {
|
|
100
|
+
await new Promise((resolve, reject) => {
|
|
101
|
+
hmrServer.close((err) => err ? reject(err) : resolve());
|
|
102
|
+
});
|
|
103
|
+
}
|
|
73
104
|
}
|
|
74
105
|
};
|
|
75
106
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.js","sources":["../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const config = await resolveDevelopmentConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n ctx.strapi.server.app.use((ctx, next) => {\n return new Promise((resolve, reject) => {\n vite.middlewares(ctx.req, ctx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n resolve(next());\n }\n });\n });\n });\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n let template = await fs.readFile(path.relative(ctx.cwd, '.strapi/client/index.html'), 'utf-8');\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n };\n\n ctx.strapi.server.routes([\n {\n method: 'GET',\n path: `${ctx.basePath}:path*`,\n handler: serveAdmin,\n config: { auth: false },\n },\n ]);\n\n return {\n async close() {\n await vite.close();\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["config","resolveDevelopmentConfig","mergeConfigWithUserConfig","ctx","fs","path"],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.js","sources":["../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport http from 'node:http';\nimport fs from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst HMR_DEFAULT_PORT = 5173;\n\nconst createHMRServer = () => {\n return http.createServer(\n // http server request handler. keeps the same with\n // https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96\n (_, res) => {\n const body = http.STATUS_CODES[426]; // Upgrade Required\n\n res.writeHead(426, {\n 'Content-Length': body?.length ?? 0,\n 'Content-Type': 'text/plain',\n });\n\n res.end(body);\n }\n );\n};\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const hmrServer = createHMRServer();\n\n ctx.options.hmrServer = hmrServer;\n ctx.options.hmrClientPort = HMR_DEFAULT_PORT;\n\n const config = await resolveDevelopmentConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n const hmrConfig = config.server?.hmr;\n\n // If the server used for Vite hmr is the one we've created (<> no user override)\n if (typeof hmrConfig === 'object' && hmrConfig.server === hmrServer) {\n // Only restart the hmr server when Strapi's server is listening\n strapi.server.httpServer.on('listening', async () => {\n hmrServer.listen(hmrConfig.clientPort ?? hmrConfig.port ?? HMR_DEFAULT_PORT);\n });\n }\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n ctx.strapi.server.app.use((ctx, next) => {\n return new Promise((resolve, reject) => {\n vite.middlewares(ctx.req, ctx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n resolve(next());\n }\n });\n });\n });\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n let template = await fs.readFile(path.relative(ctx.cwd, '.strapi/client/index.html'), 'utf-8');\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n };\n\n ctx.strapi.server.routes([\n {\n method: 'GET',\n path: `${ctx.basePath}:path*`,\n handler: serveAdmin,\n config: { auth: false },\n },\n ]);\n\n return {\n async close() {\n await vite.close();\n\n if (hmrServer.listening) {\n // Manually close the hmr server\n // /!\\ This operation MUST be done after calling .close() on the vite\n // instance to avoid flaky behaviors with attached clients\n await new Promise<void>((resolve, reject) => {\n hmrServer.close((err) => (err ? reject(err) : resolve()));\n });\n }\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["http","config","resolveDevelopmentConfig","mergeConfigWithUserConfig","ctx","fs","path"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAaA,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB,MAAM;AAC5B,SAAOA,cAAK,QAAA;AAAA;AAAA;AAAA,IAGV,CAAC,GAAG,QAAQ;AACJ,YAAA,OAAOA,cAAAA,QAAK,aAAa,GAAG;AAElC,UAAI,UAAU,KAAK;AAAA,QACjB,kBAAkB,MAAM,UAAU;AAAA,QAClC,gBAAgB;AAAA,MAAA,CACjB;AAED,UAA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,OAAO;AACd,WAAO,OAAO;AAAA,EAAA;AAGZ,MAAA,OAAO,OAAO,OAAO;AAAA,IACvB;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,GAAG,IAAI,QAAQ;AAAA,MACrB,SAAS;AAAA,MACT,QAAQ,EAAE,MAAM,MAAM;AAAA,IACxB;AAAA,EAAA,CACD;AAEM,SAAA;AAAA,IACL,MAAM,QAAQ;AACZ,YAAM,KAAK;AAEX,UAAI,UAAU,WAAW;AAIvB,cAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACjC,oBAAA,MAAM,CAAC,QAAS,MAAM,OAAO,GAAG,IAAI,SAAU;AAAA,QAAA,CACzD;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;;"}
|
package/dist/node/vite/watch.mjs
CHANGED
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import http from "node:http";
|
|
2
3
|
import fs from "node:fs/promises";
|
|
3
4
|
import { resolveDevelopmentConfig, mergeConfigWithUserConfig } from "./config.mjs";
|
|
5
|
+
const HMR_DEFAULT_PORT = 5173;
|
|
6
|
+
const createHMRServer = () => {
|
|
7
|
+
return http.createServer(
|
|
8
|
+
// http server request handler. keeps the same with
|
|
9
|
+
// https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96
|
|
10
|
+
(_, res) => {
|
|
11
|
+
const body = http.STATUS_CODES[426];
|
|
12
|
+
res.writeHead(426, {
|
|
13
|
+
"Content-Length": body?.length ?? 0,
|
|
14
|
+
"Content-Type": "text/plain"
|
|
15
|
+
});
|
|
16
|
+
res.end(body);
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
};
|
|
4
20
|
const watch = async (ctx) => {
|
|
21
|
+
const hmrServer = createHMRServer();
|
|
22
|
+
ctx.options.hmrServer = hmrServer;
|
|
23
|
+
ctx.options.hmrClientPort = HMR_DEFAULT_PORT;
|
|
5
24
|
const config = await resolveDevelopmentConfig(ctx);
|
|
6
25
|
const finalConfig = await mergeConfigWithUserConfig(config, ctx);
|
|
26
|
+
const hmrConfig = config.server?.hmr;
|
|
27
|
+
if (typeof hmrConfig === "object" && hmrConfig.server === hmrServer) {
|
|
28
|
+
strapi.server.httpServer.on("listening", async () => {
|
|
29
|
+
hmrServer.listen(hmrConfig.clientPort ?? hmrConfig.port ?? HMR_DEFAULT_PORT);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
7
32
|
ctx.logger.debug("Vite config", finalConfig);
|
|
8
33
|
const { createServer } = await import("vite");
|
|
9
34
|
const vite = await createServer(finalConfig);
|
|
@@ -43,6 +68,11 @@ const watch = async (ctx) => {
|
|
|
43
68
|
return {
|
|
44
69
|
async close() {
|
|
45
70
|
await vite.close();
|
|
71
|
+
if (hmrServer.listening) {
|
|
72
|
+
await new Promise((resolve, reject) => {
|
|
73
|
+
hmrServer.close((err) => err ? reject(err) : resolve());
|
|
74
|
+
});
|
|
75
|
+
}
|
|
46
76
|
}
|
|
47
77
|
};
|
|
48
78
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch.mjs","sources":["../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport fs from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const config = await resolveDevelopmentConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n ctx.strapi.server.app.use((ctx, next) => {\n return new Promise((resolve, reject) => {\n vite.middlewares(ctx.req, ctx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n resolve(next());\n }\n });\n });\n });\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n let template = await fs.readFile(path.relative(ctx.cwd, '.strapi/client/index.html'), 'utf-8');\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n };\n\n ctx.strapi.server.routes([\n {\n method: 'GET',\n path: `${ctx.basePath}:path*`,\n handler: serveAdmin,\n config: { auth: false },\n },\n ]);\n\n return {\n async close() {\n await vite.close();\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["ctx"],"mappings":"
|
|
1
|
+
{"version":3,"file":"watch.mjs","sources":["../../../src/node/vite/watch.ts"],"sourcesContent":["import path from 'node:path';\nimport http from 'node:http';\nimport fs from 'node:fs/promises';\nimport type { Core } from '@strapi/types';\n\nimport { mergeConfigWithUserConfig, resolveDevelopmentConfig } from './config';\n\nimport type { BuildContext } from '../create-build-context';\n\ninterface ViteWatcher {\n close(): Promise<void>;\n}\n\nconst HMR_DEFAULT_PORT = 5173;\n\nconst createHMRServer = () => {\n return http.createServer(\n // http server request handler. keeps the same with\n // https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96\n (_, res) => {\n const body = http.STATUS_CODES[426]; // Upgrade Required\n\n res.writeHead(426, {\n 'Content-Length': body?.length ?? 0,\n 'Content-Type': 'text/plain',\n });\n\n res.end(body);\n }\n );\n};\n\nconst watch = async (ctx: BuildContext): Promise<ViteWatcher> => {\n const hmrServer = createHMRServer();\n\n ctx.options.hmrServer = hmrServer;\n ctx.options.hmrClientPort = HMR_DEFAULT_PORT;\n\n const config = await resolveDevelopmentConfig(ctx);\n const finalConfig = await mergeConfigWithUserConfig(config, ctx);\n\n const hmrConfig = config.server?.hmr;\n\n // If the server used for Vite hmr is the one we've created (<> no user override)\n if (typeof hmrConfig === 'object' && hmrConfig.server === hmrServer) {\n // Only restart the hmr server when Strapi's server is listening\n strapi.server.httpServer.on('listening', async () => {\n hmrServer.listen(hmrConfig.clientPort ?? hmrConfig.port ?? HMR_DEFAULT_PORT);\n });\n }\n\n ctx.logger.debug('Vite config', finalConfig);\n\n const { createServer } = await import('vite');\n\n const vite = await createServer(finalConfig);\n\n ctx.strapi.server.app.use((ctx, next) => {\n return new Promise((resolve, reject) => {\n vite.middlewares(ctx.req, ctx.res, (err: unknown) => {\n if (err) {\n reject(err);\n } else {\n resolve(next());\n }\n });\n });\n });\n\n const serveAdmin: Core.MiddlewareHandler = async (koaCtx, next) => {\n await next();\n\n if (koaCtx.method !== 'HEAD' && koaCtx.method !== 'GET') {\n return;\n }\n\n if (koaCtx.body != null || koaCtx.status !== 404) {\n return;\n }\n\n const url = koaCtx.originalUrl;\n\n let template = await fs.readFile(path.relative(ctx.cwd, '.strapi/client/index.html'), 'utf-8');\n template = await vite.transformIndexHtml(url, template);\n\n koaCtx.type = 'html';\n koaCtx.body = template;\n };\n\n ctx.strapi.server.routes([\n {\n method: 'GET',\n path: `${ctx.basePath}:path*`,\n handler: serveAdmin,\n config: { auth: false },\n },\n ]);\n\n return {\n async close() {\n await vite.close();\n\n if (hmrServer.listening) {\n // Manually close the hmr server\n // /!\\ This operation MUST be done after calling .close() on the vite\n // instance to avoid flaky behaviors with attached clients\n await new Promise<void>((resolve, reject) => {\n hmrServer.close((err) => (err ? reject(err) : resolve()));\n });\n }\n },\n };\n};\n\nexport { watch };\nexport type { ViteWatcher };\n"],"names":["ctx"],"mappings":";;;;AAaA,MAAM,mBAAmB;AAEzB,MAAM,kBAAkB,MAAM;AAC5B,SAAO,KAAK;AAAA;AAAA;AAAA,IAGV,CAAC,GAAG,QAAQ;AACJ,YAAA,OAAO,KAAK,aAAa,GAAG;AAElC,UAAI,UAAU,KAAK;AAAA,QACjB,kBAAkB,MAAM,UAAU;AAAA,QAClC,gBAAg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D,WAAO,OAAO;AACd,WAAO,OAAO;AAAA,EAAA;AAGZ,MAAA,OAAO,OAAO,OAAO;AAAA,IACvB;AAAA,MACE,QAAQ;AAAA,MACR,MAAM,GAAG,IAAI,QAAQ;AAAA,MACrB,SAAS;AAAA,MACT,QAAQ,EAAE,MAAM,MAAM;AAAA,IACxB;AAAA,EAAA,CACD;AAEM,SAAA;AAAA,IACL,MAAM,QAAQ;AACZ,YAAM,KAAK;AAEX,UAAI,UAAU,WAAW;AAIvB,cAAM,IAAI,QAAc,CAAC,SAAS,WAAW;AACjC,oBAAA,MAAM,CAAC,QAAS,MAAM,OAAO,GAAG,IAAI,SAAU;AAAA,QAAA,CACzD;AAAA,MACH;AAAA,IACF;AAAA,EAAA;AAEJ;"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@strapi/strapi",
|
|
3
|
-
"version": "5.0.0-rc.
|
|
3
|
+
"version": "5.0.0-rc.1",
|
|
4
4
|
"description": "An open source headless CMS solution to create and manage your own API. It provides a powerful dashboard and features to make your life easier. Databases supported: MySQL, MariaDB, PostgreSQL, SQLite",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"strapi",
|
|
@@ -109,26 +109,26 @@
|
|
|
109
109
|
},
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@pmmmwh/react-refresh-webpack-plugin": "0.5.11",
|
|
112
|
-
"@strapi/admin": "5.0.0-rc.
|
|
113
|
-
"@strapi/cloud-cli": "5.0.0-rc.
|
|
114
|
-
"@strapi/content-manager": "5.0.0-rc.
|
|
115
|
-
"@strapi/content-releases": "5.0.0-rc.
|
|
116
|
-
"@strapi/content-type-builder": "5.0.0-rc.
|
|
117
|
-
"@strapi/core": "5.0.0-rc.
|
|
118
|
-
"@strapi/data-transfer": "5.0.0-rc.
|
|
119
|
-
"@strapi/database": "5.0.0-rc.
|
|
120
|
-
"@strapi/email": "5.0.0-rc.
|
|
121
|
-
"@strapi/generate-new": "5.0.0-rc.
|
|
122
|
-
"@strapi/generators": "5.0.0-rc.
|
|
123
|
-
"@strapi/i18n": "5.0.0-rc.
|
|
124
|
-
"@strapi/logger": "5.0.0-rc.
|
|
112
|
+
"@strapi/admin": "5.0.0-rc.1",
|
|
113
|
+
"@strapi/cloud-cli": "5.0.0-rc.1",
|
|
114
|
+
"@strapi/content-manager": "5.0.0-rc.1",
|
|
115
|
+
"@strapi/content-releases": "5.0.0-rc.1",
|
|
116
|
+
"@strapi/content-type-builder": "5.0.0-rc.1",
|
|
117
|
+
"@strapi/core": "5.0.0-rc.1",
|
|
118
|
+
"@strapi/data-transfer": "5.0.0-rc.1",
|
|
119
|
+
"@strapi/database": "5.0.0-rc.1",
|
|
120
|
+
"@strapi/email": "5.0.0-rc.1",
|
|
121
|
+
"@strapi/generate-new": "5.0.0-rc.1",
|
|
122
|
+
"@strapi/generators": "5.0.0-rc.1",
|
|
123
|
+
"@strapi/i18n": "5.0.0-rc.1",
|
|
124
|
+
"@strapi/logger": "5.0.0-rc.1",
|
|
125
125
|
"@strapi/pack-up": "5.0.0",
|
|
126
|
-
"@strapi/permissions": "5.0.0-rc.
|
|
127
|
-
"@strapi/review-workflows": "5.0.0-rc.
|
|
128
|
-
"@strapi/types": "5.0.0-rc.
|
|
129
|
-
"@strapi/typescript-utils": "5.0.0-rc.
|
|
130
|
-
"@strapi/upload": "5.0.0-rc.
|
|
131
|
-
"@strapi/utils": "5.0.0-rc.
|
|
126
|
+
"@strapi/permissions": "5.0.0-rc.1",
|
|
127
|
+
"@strapi/review-workflows": "5.0.0-rc.1",
|
|
128
|
+
"@strapi/types": "5.0.0-rc.1",
|
|
129
|
+
"@strapi/typescript-utils": "5.0.0-rc.1",
|
|
130
|
+
"@strapi/upload": "5.0.0-rc.1",
|
|
131
|
+
"@strapi/utils": "5.0.0-rc.1",
|
|
132
132
|
"@types/nodemon": "1.19.6",
|
|
133
133
|
"@vitejs/plugin-react-swc": "3.6.0",
|
|
134
134
|
"boxen": "5.1.2",
|
|
@@ -183,10 +183,10 @@
|
|
|
183
183
|
"@types/node": "18.19.24",
|
|
184
184
|
"@types/webpack-bundle-analyzer": "4.7.0",
|
|
185
185
|
"@types/webpack-hot-middleware": "2.25.9",
|
|
186
|
-
"eslint-config-custom": "5.0.0-rc.
|
|
186
|
+
"eslint-config-custom": "5.0.0-rc.1",
|
|
187
187
|
"react": "18.3.1",
|
|
188
188
|
"react-dom": "18.3.1",
|
|
189
|
-
"tsconfig": "5.0.0-rc.
|
|
189
|
+
"tsconfig": "5.0.0-rc.1"
|
|
190
190
|
},
|
|
191
191
|
"peerDependencies": {
|
|
192
192
|
"react": "^17.0.0 || ^18.0.0",
|
|
@@ -198,5 +198,5 @@
|
|
|
198
198
|
"node": ">=18.0.0 <=20.x.x",
|
|
199
199
|
"npm": ">=6.0.0"
|
|
200
200
|
},
|
|
201
|
-
"gitHead": "
|
|
201
|
+
"gitHead": "603c6d2b0ff8a7f655eae18706a2214eb17be2d7"
|
|
202
202
|
}
|