mirror of
https://github.com/strapi/strapi.git
synced 2025-09-09 08:39:45 +00:00
feat(pack-up): enable preserve modules (#18358)
This commit is contained in:
parent
fb3a0b8248
commit
bb9a6788a7
@ -89,6 +89,14 @@ interface ConfigOptions {
|
||||
*/
|
||||
externals?: string[];
|
||||
minify?: boolean;
|
||||
/**
|
||||
* @alpha
|
||||
*
|
||||
* @description Instead of creating as few chunks as possible, this mode
|
||||
* will create separate chunks for all modules using the original module
|
||||
* names as file names
|
||||
*/
|
||||
preserveModules?: boolean;
|
||||
sourcemap?: boolean;
|
||||
runtime?: Runtime;
|
||||
}
|
||||
|
@ -2,6 +2,8 @@ import react from '@vitejs/plugin-react';
|
||||
import path from 'path';
|
||||
import { InlineConfig, createLogger } from 'vite';
|
||||
|
||||
import { resolveConfigProperty } from '../../core/config';
|
||||
|
||||
import type { ViteBaseTask } from './types';
|
||||
import type { BuildContext } from '../../createBuildContext';
|
||||
|
||||
@ -9,7 +11,7 @@ import type { BuildContext } from '../../createBuildContext';
|
||||
* @internal
|
||||
*/
|
||||
const resolveViteConfig = (ctx: BuildContext, task: ViteBaseTask) => {
|
||||
const { cwd, distPath, targets, external, extMap, pkg, config: packUpConfig } = ctx;
|
||||
const { cwd, distPath, targets, external, extMap, pkg } = ctx;
|
||||
const { entries, format, output, runtime } = task;
|
||||
const outputExt = extMap[pkg.type || 'commonjs'][format];
|
||||
const outDir = path.relative(cwd, distPath);
|
||||
@ -28,8 +30,8 @@ const resolveViteConfig = (ctx: BuildContext, task: ViteBaseTask) => {
|
||||
clearScreen: false,
|
||||
customLogger,
|
||||
build: {
|
||||
minify: packUpConfig?.minify ?? false,
|
||||
sourcemap: packUpConfig?.sourcemap ?? true,
|
||||
minify: resolveConfigProperty(ctx.config.minify, false),
|
||||
sourcemap: resolveConfigProperty(ctx.config.sourcemap, true),
|
||||
/**
|
||||
* The task runner will clear this for us
|
||||
*/
|
||||
@ -50,6 +52,7 @@ const resolveViteConfig = (ctx: BuildContext, task: ViteBaseTask) => {
|
||||
rollupOptions: {
|
||||
external,
|
||||
output: {
|
||||
preserveModules: resolveConfigProperty(ctx.config.preserveModules, false),
|
||||
/**
|
||||
* Mimic TypeScript's behavior, by setting the value to "auto" to control
|
||||
* how Rollup handles default, namespace and dynamic imports from external
|
||||
|
Loading…
x
Reference in New Issue
Block a user