"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "packages/angular_devkit/build_angular/src/dev-server/index.ts" between
angular-cli-12.0.3.tar.gz and angular-cli-12.0.4.tar.gz

About: Angular CLI is a command line interface for Angular.

index.ts  (angular-cli-12.0.3):index.ts  (angular-cli-12.0.4)
skipping to change at line 68 skipping to change at line 68
'sourceMap', 'sourceMap',
'vendorChunk', 'vendorChunk',
'commonChunk', 'commonChunk',
'baseHref', 'baseHref',
'progress', 'progress',
'poll', 'poll',
'verbose', 'verbose',
'deployUrl', 'deployUrl',
]; ];
// Get dev-server only options.
type DevServerOptions = Partial<
Omit<
Schema,
| 'watch'
| 'optimization'
| 'aot'
| 'sourceMap'
| 'vendorChunk'
| 'commonChunk'
| 'baseHref'
| 'progress'
| 'poll'
| 'verbose'
| 'deployUrl'
>
>;
/** /**
* @experimental Direct usage of this type is considered experimental. * @experimental Direct usage of this type is considered experimental.
*/ */
export type DevServerBuilderOutput = DevServerBuildOutput & { export type DevServerBuilderOutput = DevServerBuildOutput & {
baseUrl: string; baseUrl: string;
}; };
/** /**
* Reusable implementation of the Angular Webpack development server builder. * Reusable implementation of the Angular Webpack development server builder.
* @param options Dev Server options. * @param options Dev Server options.
skipping to change at line 122 skipping to change at line 140
const overrides = (Object.keys(options) as (keyof DevServerBuilderOptions)[] ) const overrides = (Object.keys(options) as (keyof DevServerBuilderOptions)[] )
.filter((key) => options[key] !== undefined && devServerBuildOverriddenKey s.includes(key)) .filter((key) => options[key] !== undefined && devServerBuildOverriddenKey s.includes(key))
.reduce<json.JsonObject & Partial<BrowserBuilderSchema>>( .reduce<json.JsonObject & Partial<BrowserBuilderSchema>>(
(previous, key) => ({ (previous, key) => ({
...previous, ...previous,
[key]: options[key], [key]: options[key],
}), }),
{}, {},
); );
// Get dev-server only options.
type DevServerOptions = Partial<
Omit<
Schema,
| 'watch'
| 'optimization'
| 'aot'
| 'sourceMap'
| 'vendorChunk'
| 'commonChunk'
| 'baseHref'
| 'progress'
| 'poll'
| 'verbose'
| 'deployUrl'
>
>;
const devServerOptions: DevServerOptions = (Object.keys(options) as (keyof S chema)[]) const devServerOptions: DevServerOptions = (Object.keys(options) as (keyof S chema)[])
.filter((key) => !devServerBuildOverriddenKeys.includes(key) && key !== 'b rowserTarget') .filter((key) => !devServerBuildOverriddenKeys.includes(key) && key !== 'b rowserTarget')
.reduce<DevServerOptions>( .reduce<DevServerOptions>(
(previous, key) => ({ (previous, key) => ({
...previous, ...previous,
[key]: options[key], [key]: options[key],
}), }),
{}, {},
); );
// In dev server we should not have budgets because of extra libs such as so cks-js // In dev server we should not have budgets because of extra libs such as so cks-js
overrides.budgets = undefined; overrides.budgets = undefined;
if (rawBrowserOptions.outputHashing && rawBrowserOptions.outputHashing !== O utputHashing.None) { if (rawBrowserOptions.outputHashing && rawBrowserOptions.outputHashing !== O utputHashing.None) {
// Disable output hashing for dev build as this can cause memory leaks // Disable output hashing for dev build as this can cause memory leaks
// See: https://github.com/webpack/webpack-dev-server/issues/377#issuecomm ent-241258405 // See: https://github.com/webpack/webpack-dev-server/issues/377#issuecomm ent-241258405
overrides.outputHashing = OutputHashing.None; overrides.outputHashing = OutputHashing.None;
logger.warn(`Warning: 'outputHashing' option is disabled when using the de v-server.`); logger.warn(`Warning: 'outputHashing' option is disabled when using the de v-server.`);
} }
if (options.hmr) {
logger.warn(tags.stripIndents`NOTICE: Hot Module Replacement (HMR) is enab
led for the dev server.
See https://webpack.js.org/guides/hot-module-replacement for information o
n working with HMR for Webpack.`);
}
if (
!options.disableHostCheck &&
options.host &&
!/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
options.host !== 'localhost'
) {
logger.warn(tags.stripIndent`
Warning: This is a simple server for use in testing or debugging Angular
applications
locally. It hasn't been reviewed for security issues.
Binding this server to an open connection can result in compromising you
r application or
computer. Using a different host than the one passed to the "--host" fla
g might result in
websocket connection issues. You might need to use "--disableHostCheck"
if that's the
case.
`);
}
if (options.disableHostCheck) {
logger.warn(tags.oneLine`
Warning: Running a server with --disable-host-check is a security risk.
See https://medium.com/webpack/webpack-dev-server-middleware-security-is
sues-1489d950874a
for more information.
`);
}
// Webpack's live reload functionality adds the `strip-ansi` package which i s commonJS // Webpack's live reload functionality adds the `strip-ansi` package which i s commonJS
rawBrowserOptions.allowedCommonJsDependencies ??= []; rawBrowserOptions.allowedCommonJsDependencies ??= [];
rawBrowserOptions.allowedCommonJsDependencies.push('strip-ansi'); rawBrowserOptions.allowedCommonJsDependencies.push('strip-ansi');
const browserName = await context.getBuilderNameForTarget(browserTarget); const browserName = await context.getBuilderNameForTarget(browserTarget);
const browserOptions = (await context.validateOptions( const browserOptions = (await context.validateOptions(
{ ...rawBrowserOptions, ...overrides }, { ...rawBrowserOptions, ...overrides },
browserName, browserName,
)) as json.JsonObject & BrowserBuilderSchema; )) as json.JsonObject & BrowserBuilderSchema;
const { styles, scripts } = normalizeOptimization(browserOptions.optimizatio
n);
if (scripts || styles.minify) {
logger.error(tags.stripIndents`
************************************************************************
****************
This is a simple server for use in testing or debugging Angular applicat
ions locally.
It hasn't been reviewed for security issues.
DON'T USE IT FOR PRODUCTION!
************************************************************************
****************
`);
}
const { config, projectRoot, i18n } = await generateI18nBrowserWebpackConfig FromContext( const { config, projectRoot, i18n } = await generateI18nBrowserWebpackConfig FromContext(
browserOptions, browserOptions,
context, context,
(wco) => [ (wco) => [
getDevServerConfig(wco), getDevServerConfig(wco),
getCommonConfig(wco), getCommonConfig(wco),
getBrowserConfig(wco), getBrowserConfig(wco),
getStylesConfig(wco), getStylesConfig(wco),
getStatsConfig(wco), getStatsConfig(wco),
getAnalyticsConfig(wco, context), getAnalyticsConfig(wco, context),
skipping to change at line 223 skipping to change at line 266
x.includes('webpack-dev-server/client/index.js'), x.includes('webpack-dev-server/client/index.js'),
); );
if (webpackClientScriptIndex >= 0) { if (webpackClientScriptIndex >= 0) {
// Remove the webpack-dev-server/client script from array. // Remove the webpack-dev-server/client script from array.
value.splice(webpackClientScriptIndex, 1); value.splice(webpackClientScriptIndex, 1);
} }
} }
} }
} }
if (options.hmr) {
logger.warn(tags.stripIndents`NOTICE: Hot Module Replacement (HMR) is enab
led for the dev server.
See https://webpack.js.org/guides/hot-module-replacement for information o
n working with HMR for Webpack.`);
}
if (
!options.disableHostCheck &&
options.host &&
!/^127\.\d+\.\d+\.\d+/g.test(options.host) &&
options.host !== 'localhost'
) {
logger.warn(tags.stripIndent`
Warning: This is a simple server for use in testing or debugging Angular
applications
locally. It hasn't been reviewed for security issues.
Binding this server to an open connection can result in compromising you
r application or
computer. Using a different host than the one passed to the "--host" fla
g might result in
websocket connection issues. You might need to use "--disableHostCheck"
if that's the
case.
`);
}
if (options.disableHostCheck) {
logger.warn(tags.oneLine`
Warning: Running a server with --disable-host-check is a security risk.
See https://medium.com/webpack/webpack-dev-server-middleware-security-is
sues-1489d950874a
for more information.
`);
}
let locale: string | undefined; let locale: string | undefined;
if (i18n.shouldInline) { if (i18n.shouldInline) {
// Dev-server only supports one locale // Dev-server only supports one locale
locale = [...i18n.inlineLocales][0]; locale = [...i18n.inlineLocales][0];
} else if (i18n.hasDefinedSourceLocale) { } else if (i18n.hasDefinedSourceLocale) {
// use source locale if not localizing // use source locale if not localizing
locale = i18n.sourceLocale; locale = i18n.sourceLocale;
} }
let webpackConfig = config; let webpackConfig = config;
skipping to change at line 293 skipping to change at line 306
return { return {
browserOptions, browserOptions,
webpackConfig, webpackConfig,
projectRoot, projectRoot,
locale, locale,
}; };
} }
return from(setup()).pipe( return from(setup()).pipe(
switchMap(({ browserOptions, webpackConfig, projectRoot, locale }) => { switchMap(({ browserOptions, webpackConfig, projectRoot, locale }) => {
const normalizedOptimization = normalizeOptimization(browserOptions.optimi
zation);
if (browserOptions.index) { if (browserOptions.index) {
const { scripts = [], styles = [], baseHref, tsConfig } = browserOptions ; const { scripts = [], styles = [], baseHref, tsConfig } = browserOptions ;
const { options: compilerOptions } = readTsconfig(tsConfig, workspaceRoo t); const { options: compilerOptions } = readTsconfig(tsConfig, workspaceRoo t);
const target = compilerOptions.target || ts.ScriptTarget.ES5; const target = compilerOptions.target || ts.ScriptTarget.ES5;
const buildBrowserFeatures = new BuildBrowserFeatures(projectRoot); const buildBrowserFeatures = new BuildBrowserFeatures(projectRoot);
const entrypoints = generateEntryPoints({ scripts, styles }); const entrypoints = generateEntryPoints({ scripts, styles });
const moduleEntrypoints = buildBrowserFeatures.isDifferentialLoadingNeed ed(target) const moduleEntrypoints = buildBrowserFeatures.isDifferentialLoadingNeed ed(target)
? generateEntryPoints({ scripts: [], styles }) ? generateEntryPoints({ scripts: [], styles })
: []; : [];
skipping to change at line 318 skipping to change at line 329
new IndexHtmlWebpackPlugin({ new IndexHtmlWebpackPlugin({
indexPath: path.resolve(workspaceRoot, getIndexInputFile(browserOpti ons.index)), indexPath: path.resolve(workspaceRoot, getIndexInputFile(browserOpti ons.index)),
outputPath: getIndexOutputFile(browserOptions.index), outputPath: getIndexOutputFile(browserOptions.index),
baseHref, baseHref,
entrypoints, entrypoints,
moduleEntrypoints, moduleEntrypoints,
noModuleEntrypoints: ['polyfills-es5'], noModuleEntrypoints: ['polyfills-es5'],
deployUrl: browserOptions.deployUrl, deployUrl: browserOptions.deployUrl,
sri: browserOptions.subresourceIntegrity, sri: browserOptions.subresourceIntegrity,
postTransform: transforms.indexHtml, postTransform: transforms.indexHtml,
optimization: normalizedOptimization, optimization: normalizeOptimization(browserOptions.optimization),
WOFFSupportNeeded: !buildBrowserFeatures.isFeatureSupported('woff2') , WOFFSupportNeeded: !buildBrowserFeatures.isFeatureSupported('woff2') ,
crossOrigin: browserOptions.crossOrigin, crossOrigin: browserOptions.crossOrigin,
lang: locale, lang: locale,
}), }),
); );
} }
if (normalizedOptimization.scripts || normalizedOptimization.styles.minify
) {
logger.error(tags.stripIndents`
**********************************************************************
******************
This is a simple server for use in testing or debugging Angular applic
ations locally.
It hasn't been reviewed for security issues.
DON'T USE IT FOR PRODUCTION!
**********************************************************************
******************
`);
}
return runWebpackDevServer(webpackConfig, context, { return runWebpackDevServer(webpackConfig, context, {
logging: transforms.logging || createWebpackLoggingCallback(!!options.ve rbose, logger), logging: transforms.logging || createWebpackLoggingCallback(browserOptio ns, logger),
webpackFactory: require('webpack') as typeof webpack, webpackFactory: require('webpack') as typeof webpack,
webpackDevServerFactory: require('webpack-dev-server') as typeof webpack DevServer, webpackDevServerFactory: require('webpack-dev-server') as typeof webpack DevServer,
}).pipe( }).pipe(
concatMap(async (buildEvent, index) => { concatMap(async (buildEvent, index) => {
// Resolve serve address. // Resolve serve address.
const serverAddress = url.format({ const serverAddress = url.format({
protocol: options.ssl ? 'https' : 'http', protocol: options.ssl ? 'https' : 'http',
hostname: options.host === '0.0.0.0' ? 'localhost' : options.host, hostname: options.host === '0.0.0.0' ? 'localhost' : options.host,
pathname: webpackConfig.devServer?.publicPath, pathname: webpackConfig.devServer?.publicPath,
port: buildEvent.port, port: buildEvent.port,
 End of changes. 9 change blocks. 
74 lines changed or deleted 73 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)