Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
],
);
setWebpackServerFileLoaderEmitFile(universalOptions, serverOptions, browserOptions, serverConfig);
setWebpackServerExternals(universalOptions, serverConfig);
const config = await applyWebpackPartialConfig(
serverConfig,
universalOptions.partialServerConfig as string,
);
const tsConfig = readTsconfig(serverOptions.tsConfig, context.workspaceRoot);
const target = tsConfig.options.target || ScriptTarget.ES5;
if (serverOptions.deleteOutputPath) {
deleteOutputDir(
context.workspaceRoot,
serverOptions.outputPath,
);
}
return {
options: serverOptions,
config,
projectRoot,
projectSourceRoot,
i18n,
target,
};
}
export function deleteConfigOutputPath(
root: string,
host: virtualFs.Host,
config: webpack.Configuration,
) {
if (!config.output || !config.output.path) {
return Promise.resolve();
}
return deleteOutputDir(
normalize(root),
normalize(config.output.path),
host,
).toPromise();
}
const tsConfig = readTsconfig(browserOptions.tsConfig, context.workspaceRoot);
const target = tsConfig.options.target || ScriptTarget.ES5;
const buildBrowserFeatures = new BuildBrowserFeatures(projectRoot, target);
const isDifferentialLoadingNeeded = buildBrowserFeatures.isDifferentialLoadingNeeded();
const useBundleDownleveling = isDifferentialLoadingNeeded && !browserOptions.watch;
if (target > ScriptTarget.ES2015 && isDifferentialLoadingNeeded) {
context.logger.warn(tags.stripIndent`
WARNING: Using differential loading with targets ES5 and ES2016 or higher may
cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
referenced with script[type="module"] but they may not support ES2016+ syntax.
`);
}
if (browserOptions.deleteOutputPath) {
deleteOutputDir(
context.workspaceRoot,
browserOptions.outputPath,
);
}
return {
options: browserOptions,
config,
projectRoot,
projectSourceRoot,
i18n,
isDifferentialLoadingNeeded,
target,
useBundleDownleveling,
};
}