@angular-devkit/build-angular 0.800.2 → 0.800.3
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/package.json +7 -7
- package/src/angular-cli-files/models/safari-nomodule.js +3 -17
- package/src/angular-cli-files/models/webpack-configs/common.js +25 -21
- package/src/angular-cli-files/models/webpack-configs/typescript.d.ts +1 -1
- package/src/angular-cli-files/models/webpack-configs/typescript.js +5 -5
- package/src/angular-cli-files/models/webpack-configs/utils.d.ts +0 -1
- package/src/angular-cli-files/models/webpack-configs/utils.js +0 -4
- package/src/angular-cli-files/utilities/package-chunk-sort.js +1 -0
- package/src/browser/index.js +3 -3
- package/src/extract-i18n/index.js +1 -0
- package/src/utils/build-browser-features.d.ts +35 -0
- package/src/utils/build-browser-features.js +74 -0
- package/src/utils/index.d.ts +1 -1
- package/src/utils/index.js +5 -5
- package/src/utils/webpack-browser-config.js +5 -3
- package/src/utils/differential-loading.d.ts +0 -10
- package/src/utils/differential-loading.js +0 -24
package/package.json
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@angular-devkit/build-angular",
|
|
3
|
-
"version": "0.800.
|
|
3
|
+
"version": "0.800.3",
|
|
4
4
|
"description": "Angular Webpack Build Facade",
|
|
5
5
|
"experimental": true,
|
|
6
6
|
"main": "src/index.js",
|
|
7
7
|
"typings": "src/index.d.ts",
|
|
8
8
|
"builders": "builders.json",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@angular-devkit/architect": "0.800.
|
|
11
|
-
"@angular-devkit/build-optimizer": "0.800.
|
|
12
|
-
"@angular-devkit/build-webpack": "0.800.
|
|
13
|
-
"@angular-devkit/core": "8.0.
|
|
14
|
-
"@ngtools/webpack": "8.0.
|
|
10
|
+
"@angular-devkit/architect": "0.800.3",
|
|
11
|
+
"@angular-devkit/build-optimizer": "0.800.3",
|
|
12
|
+
"@angular-devkit/build-webpack": "0.800.3",
|
|
13
|
+
"@angular-devkit/core": "8.0.3",
|
|
14
|
+
"@ngtools/webpack": "8.0.3",
|
|
15
15
|
"ajv": "6.10.0",
|
|
16
16
|
"autoprefixer": "9.5.1",
|
|
17
17
|
"browserslist": "4.5.5",
|
|
18
|
-
"caniuse-
|
|
18
|
+
"caniuse-lite": "1.0.30000974",
|
|
19
19
|
"circular-dependency-plugin": "5.0.2",
|
|
20
20
|
"clean-css": "4.2.1",
|
|
21
21
|
"copy-webpack-plugin": "5.0.2",
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
* Safari 10.1 supports modules, but does not support the `nomodule` attribute - it will
|
|
3
|
-
* load <script nomodule> anyway. This snippet solve this problem, but only for script
|
|
4
|
-
* tags that load external code, e.g.: <script nomodule src="nomodule.js"></script>
|
|
5
|
-
*
|
|
6
|
-
* Again: this will **not** prevent inline script, e.g.:
|
|
7
|
-
* <script nomodule>alert('no modules');</script>.
|
|
8
|
-
*
|
|
9
|
-
* This workaround is possible because Safari supports the non-standard 'beforeload' event.
|
|
10
|
-
* This allows us to trap the module and nomodule load.
|
|
11
|
-
*
|
|
12
|
-
* Note also that `nomodule` is supported in later versions of Safari - it's just 10.1 that
|
|
13
|
-
* omits this attribute.
|
|
14
|
-
*/
|
|
15
|
-
(function() {
|
|
1
|
+
(function () {
|
|
16
2
|
var check = document.createElement('script');
|
|
17
3
|
if (!('noModule' in check) && 'onbeforeload' in check) {
|
|
18
4
|
var support = false;
|
|
19
|
-
document.addEventListener('beforeload', function(e) {
|
|
5
|
+
document.addEventListener('beforeload', function (e) {
|
|
20
6
|
if (e.target === check) {
|
|
21
7
|
support = true;
|
|
22
8
|
} else if (!e.target.hasAttribute('nomodule') || !support) {
|
|
@@ -30,4 +16,4 @@
|
|
|
30
16
|
document.head.appendChild(check);
|
|
31
17
|
check.remove();
|
|
32
18
|
}
|
|
33
|
-
}());
|
|
19
|
+
}());
|
|
@@ -12,7 +12,7 @@ const CopyWebpackPlugin = require("copy-webpack-plugin");
|
|
|
12
12
|
const path = require("path");
|
|
13
13
|
const typescript_1 = require("typescript");
|
|
14
14
|
const webpack_1 = require("webpack");
|
|
15
|
-
const
|
|
15
|
+
const build_browser_features_1 = require("../../../utils/build-browser-features");
|
|
16
16
|
const bundle_budget_1 = require("../../plugins/bundle-budget");
|
|
17
17
|
const cleancss_webpack_plugin_1 = require("../../plugins/cleancss-webpack-plugin");
|
|
18
18
|
const named_chunks_plugin_1 = require("../../plugins/named-chunks-plugin");
|
|
@@ -31,7 +31,7 @@ exports.buildOptimizerLoader = g['_DevKitIsLocal']
|
|
|
31
31
|
: '@angular-devkit/build-optimizer/webpack-loader';
|
|
32
32
|
// tslint:disable-next-line:no-big-function
|
|
33
33
|
function getCommonConfig(wco) {
|
|
34
|
-
const { root, projectRoot, buildOptions } = wco;
|
|
34
|
+
const { root, projectRoot, buildOptions, tsConfig } = wco;
|
|
35
35
|
const { styles: stylesOptimization, scripts: scriptsOptimization } = buildOptions.optimization;
|
|
36
36
|
const { styles: stylesSourceMap, scripts: scriptsSourceMap, vendor: vendorSourceMap, } = buildOptions.sourceMap;
|
|
37
37
|
const nodeModules = find_up_1.findUp('node_modules', projectRoot);
|
|
@@ -46,27 +46,31 @@ function getCommonConfig(wco) {
|
|
|
46
46
|
entryPoints['main'] = [path.resolve(root, buildOptions.main)];
|
|
47
47
|
}
|
|
48
48
|
if (wco.buildOptions.platform !== 'server') {
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
49
|
+
const buildBrowserFeatures = new build_browser_features_1.BuildBrowserFeatures(projectRoot, tsConfig.options.target || typescript_1.ScriptTarget.ES5);
|
|
50
|
+
if ((buildOptions.scriptTargetOverride || tsConfig.options.target) === typescript_1.ScriptTarget.ES5) {
|
|
51
|
+
if (buildOptions.es5BrowserSupport ||
|
|
52
|
+
(buildOptions.es5BrowserSupport === undefined &&
|
|
53
|
+
buildBrowserFeatures.isEs5SupportNeeded())) {
|
|
54
|
+
// The nomodule polyfill needs to be inject prior to any script and be
|
|
55
|
+
// outside of webpack compilation because otherwise webpack will cause the
|
|
56
|
+
// script to be wrapped in window["webpackJsonp"] which causes this to fail.
|
|
57
|
+
if (buildBrowserFeatures.isNoModulePolyfillNeeded()) {
|
|
58
|
+
const noModuleScript = {
|
|
59
|
+
bundleName: 'polyfills-nomodule-es5',
|
|
60
|
+
input: path.join(__dirname, '..', 'safari-nomodule.js'),
|
|
61
|
+
};
|
|
62
|
+
buildOptions.scripts = buildOptions.scripts
|
|
63
|
+
? [...buildOptions.scripts, noModuleScript]
|
|
64
|
+
: [noModuleScript];
|
|
60
65
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
entryPoints['polyfills-es5'] = [es5Polyfills];
|
|
66
|
+
// For differential loading we don't need to generate a seperate polyfill file
|
|
67
|
+
// because they will be loaded exclusivly based on module and nomodule
|
|
68
|
+
const polyfillsChunkName = buildBrowserFeatures.isDifferentialLoadingNeeded()
|
|
69
|
+
? 'polyfills'
|
|
70
|
+
: 'polyfills-es5';
|
|
71
|
+
entryPoints[polyfillsChunkName] = [path.join(__dirname, '..', 'es5-polyfills.js')];
|
|
68
72
|
if (!buildOptions.aot) {
|
|
69
|
-
entryPoints[
|
|
73
|
+
entryPoints[polyfillsChunkName].push(path.join(__dirname, '..', 'es5-jit-polyfills.js'));
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
}
|
|
@@ -9,7 +9,7 @@ export declare function getNonAotConfig(wco: WebpackConfigOptions): {
|
|
|
9
9
|
};
|
|
10
10
|
plugins: AngularCompilerPlugin[];
|
|
11
11
|
};
|
|
12
|
-
export declare function getAotConfig(wco: WebpackConfigOptions,
|
|
12
|
+
export declare function getAotConfig(wco: WebpackConfigOptions, i18nExtract?: boolean): {
|
|
13
13
|
module: {
|
|
14
14
|
rules: {
|
|
15
15
|
test: RegExp;
|
|
@@ -34,12 +34,12 @@ function _pluginOptionsOverrides(buildOptions, pluginOptions) {
|
|
|
34
34
|
compilerOptions
|
|
35
35
|
};
|
|
36
36
|
}
|
|
37
|
-
function _createAotPlugin(wco, options,
|
|
37
|
+
function _createAotPlugin(wco, options, i18nExtract = false) {
|
|
38
38
|
const { root, buildOptions } = wco;
|
|
39
39
|
const i18nInFile = buildOptions.i18nFile
|
|
40
40
|
? path.resolve(root, buildOptions.i18nFile)
|
|
41
41
|
: undefined;
|
|
42
|
-
const i18nFileAndFormat =
|
|
42
|
+
const i18nFileAndFormat = i18nExtract
|
|
43
43
|
? {
|
|
44
44
|
i18nOutFile: buildOptions.i18nFile,
|
|
45
45
|
i18nOutFormat: buildOptions.i18nFormat,
|
|
@@ -54,7 +54,7 @@ function _createAotPlugin(wco, options, useMain = true, extract = false) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
let pluginOptions = {
|
|
57
|
-
mainPath:
|
|
57
|
+
mainPath: path.join(root, buildOptions.main),
|
|
58
58
|
...i18nFileAndFormat,
|
|
59
59
|
locale: buildOptions.i18nLocale,
|
|
60
60
|
platform: buildOptions.platform === 'server' ? webpack_1.PLATFORM.Server : webpack_1.PLATFORM.Browser,
|
|
@@ -79,7 +79,7 @@ function getNonAotConfig(wco) {
|
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
exports.getNonAotConfig = getNonAotConfig;
|
|
82
|
-
function getAotConfig(wco,
|
|
82
|
+
function getAotConfig(wco, i18nExtract = false) {
|
|
83
83
|
const { tsConfigPath, buildOptions } = wco;
|
|
84
84
|
const loaders = [webpack_1.NgToolsLoader];
|
|
85
85
|
if (buildOptions.buildOptimizer) {
|
|
@@ -91,7 +91,7 @@ function getAotConfig(wco, extract = false) {
|
|
|
91
91
|
const test = /(?:\.ngfactory\.js|\.ngstyle\.js|\.tsx?)$/;
|
|
92
92
|
return {
|
|
93
93
|
module: { rules: [{ test, use: loaders }] },
|
|
94
|
-
plugins: [_createAotPlugin(wco, { tsConfigPath },
|
|
94
|
+
plugins: [_createAotPlugin(wco, { tsConfigPath }, i18nExtract)]
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
exports.getAotConfig = getAotConfig;
|
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
import { ExtraEntryPoint, ExtraEntryPointClass } from '../../../browser/schema';
|
|
9
9
|
import { SourceMapDevToolPlugin } from 'webpack';
|
|
10
10
|
import { ScriptTarget } from 'typescript';
|
|
11
|
-
export declare const ngAppResolve: (resolvePath: string) => string;
|
|
12
11
|
export interface HashFormat {
|
|
13
12
|
chunk: string;
|
|
14
13
|
extract: string;
|
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
// tslint:disable
|
|
10
10
|
// TODO: cleanup this file, it's copied as is from Angular CLI.
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
const path = require("path");
|
|
13
12
|
const core_1 = require("@angular-devkit/core");
|
|
14
13
|
const webpack_1 = require("webpack");
|
|
15
14
|
const typescript_1 = require("typescript");
|
|
16
|
-
exports.ngAppResolve = (resolvePath) => {
|
|
17
|
-
return path.resolve(process.cwd(), resolvePath);
|
|
18
|
-
};
|
|
19
15
|
function getOutputHashFormat(option, length = 20) {
|
|
20
16
|
/* tslint:disable:max-line-length */
|
|
21
17
|
const hashFormats = {
|
package/src/browser/index.js
CHANGED
|
@@ -108,9 +108,9 @@ function buildWebpackBrowser(options, context, transforms = {}) {
|
|
|
108
108
|
const projectRoot = core_1.resolve(workspace.root, core_1.normalize(workspace.getProject(projectName).root));
|
|
109
109
|
const tsConfigPath = path.resolve(core_1.getSystemPath(workspace.root), options.tsConfig);
|
|
110
110
|
const tsConfig = read_tsconfig_1.readTsconfig(tsConfigPath);
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
111
|
+
const target = tsConfig.options.target || typescript_1.ScriptTarget.ES5;
|
|
112
|
+
const buildBrowserFeatures = new utils_1.BuildBrowserFeatures(core_1.getSystemPath(projectRoot), target);
|
|
113
|
+
if (target > typescript_1.ScriptTarget.ES2015 && buildBrowserFeatures.isDifferentialLoadingNeeded()) {
|
|
114
114
|
context.logger.warn(core_1.tags.stripIndent `
|
|
115
115
|
WARNING: Using differential loading with targets ES5 and ES2016 or higher may
|
|
116
116
|
cause problems. Browsers with support for ES2015 will load the ES2016+ scripts
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
+
*
|
|
5
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
+
* found in the LICENSE file at https://angular.io/license
|
|
7
|
+
*/
|
|
8
|
+
import * as ts from 'typescript';
|
|
9
|
+
export declare class BuildBrowserFeatures {
|
|
10
|
+
private projectRoot;
|
|
11
|
+
private scriptTarget;
|
|
12
|
+
private readonly _supportedBrowsers;
|
|
13
|
+
private readonly _es6TargetOrLater;
|
|
14
|
+
constructor(projectRoot: string, scriptTarget: ts.ScriptTarget);
|
|
15
|
+
/**
|
|
16
|
+
* True, when one or more browsers requires ES5
|
|
17
|
+
* support and the scirpt target is ES2015 or greater.
|
|
18
|
+
*/
|
|
19
|
+
isDifferentialLoadingNeeded(): boolean;
|
|
20
|
+
/**
|
|
21
|
+
* True, when one or more browsers requires ES5 support
|
|
22
|
+
*/
|
|
23
|
+
isEs5SupportNeeded(): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Safari 10.1 and iOS Safari 10.3 supports modules,
|
|
26
|
+
* but does not support the `nomodule` attribute.
|
|
27
|
+
* While return `true`, when support for Safari 10.1 and iOS Safari 10.3
|
|
28
|
+
* is required and in differential loading is enabled.
|
|
29
|
+
*/
|
|
30
|
+
isNoModulePolyfillNeeded(): boolean;
|
|
31
|
+
/**
|
|
32
|
+
* True, when a browser feature is supported partially or fully.
|
|
33
|
+
*/
|
|
34
|
+
isFeatureSupported(featureId: string): boolean;
|
|
35
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @license
|
|
4
|
+
* Copyright Google Inc. All Rights Reserved.
|
|
5
|
+
*
|
|
6
|
+
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
+
* found in the LICENSE file at https://angular.io/license
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
const browserslist = require("browserslist");
|
|
11
|
+
const caniuse_lite_1 = require("caniuse-lite");
|
|
12
|
+
const ts = require("typescript");
|
|
13
|
+
class BuildBrowserFeatures {
|
|
14
|
+
constructor(projectRoot, scriptTarget) {
|
|
15
|
+
this.projectRoot = projectRoot;
|
|
16
|
+
this.scriptTarget = scriptTarget;
|
|
17
|
+
this._supportedBrowsers = browserslist(undefined, { path: this.projectRoot });
|
|
18
|
+
this._es6TargetOrLater = this.scriptTarget > ts.ScriptTarget.ES5;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* True, when one or more browsers requires ES5
|
|
22
|
+
* support and the scirpt target is ES2015 or greater.
|
|
23
|
+
*/
|
|
24
|
+
isDifferentialLoadingNeeded() {
|
|
25
|
+
return this._es6TargetOrLater && this.isEs5SupportNeeded();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* True, when one or more browsers requires ES5 support
|
|
29
|
+
*/
|
|
30
|
+
isEs5SupportNeeded() {
|
|
31
|
+
return !this.isFeatureSupported('es6-module');
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Safari 10.1 and iOS Safari 10.3 supports modules,
|
|
35
|
+
* but does not support the `nomodule` attribute.
|
|
36
|
+
* While return `true`, when support for Safari 10.1 and iOS Safari 10.3
|
|
37
|
+
* is required and in differential loading is enabled.
|
|
38
|
+
*/
|
|
39
|
+
isNoModulePolyfillNeeded() {
|
|
40
|
+
if (!this.isDifferentialLoadingNeeded()) {
|
|
41
|
+
return false;
|
|
42
|
+
}
|
|
43
|
+
const safariBrowsers = [
|
|
44
|
+
'safari 10.1',
|
|
45
|
+
'ios_saf 10.3',
|
|
46
|
+
];
|
|
47
|
+
return this._supportedBrowsers.some(browser => safariBrowsers.includes(browser));
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* True, when a browser feature is supported partially or fully.
|
|
51
|
+
*/
|
|
52
|
+
isFeatureSupported(featureId) {
|
|
53
|
+
// y: feature is fully available
|
|
54
|
+
// n: feature is unavailable
|
|
55
|
+
// a: feature is partially supported
|
|
56
|
+
// x: feature is prefixed
|
|
57
|
+
const criteria = [
|
|
58
|
+
'y',
|
|
59
|
+
'a',
|
|
60
|
+
];
|
|
61
|
+
const data = caniuse_lite_1.feature(caniuse_lite_1.features[featureId]);
|
|
62
|
+
return !this._supportedBrowsers
|
|
63
|
+
.some(browser => {
|
|
64
|
+
const [agentId, version] = browser.split(' ');
|
|
65
|
+
const browserData = data.stats[agentId];
|
|
66
|
+
const featureStatus = (browserData && browserData[version]);
|
|
67
|
+
// We are only interested in the first character
|
|
68
|
+
// Ex: when 'a #4 #5', we only need to check for 'a'
|
|
69
|
+
// as for such cases we should polyfill these features as needed
|
|
70
|
+
return !featureStatus || !criteria.includes(featureStatus.charAt(0));
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
exports.BuildBrowserFeatures = BuildBrowserFeatures;
|
package/src/utils/index.d.ts
CHANGED
|
@@ -5,9 +5,9 @@
|
|
|
5
5
|
* Use of this source code is governed by an MIT-style license that can be
|
|
6
6
|
* found in the LICENSE file at https://angular.io/license
|
|
7
7
|
*/
|
|
8
|
+
export * from './build-browser-features';
|
|
8
9
|
export * from './default-progress';
|
|
9
10
|
export * from './delete-output-dir';
|
|
10
|
-
export * from './differential-loading';
|
|
11
11
|
export * from './run-module-as-observable-fork';
|
|
12
12
|
export * from './normalize-file-replacements';
|
|
13
13
|
export * from './normalize-asset-patterns';
|
package/src/utils/index.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
function __export(m) {
|
|
3
|
-
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
4
|
-
}
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
2
|
/**
|
|
7
3
|
* @license
|
|
8
4
|
* Copyright Google Inc. All Rights Reserved.
|
|
@@ -10,9 +6,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
10
6
|
* Use of this source code is governed by an MIT-style license that can be
|
|
11
7
|
* found in the LICENSE file at https://angular.io/license
|
|
12
8
|
*/
|
|
9
|
+
function __export(m) {
|
|
10
|
+
for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
|
|
11
|
+
}
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__export(require("./build-browser-features"));
|
|
13
14
|
__export(require("./default-progress"));
|
|
14
15
|
__export(require("./delete-output-dir"));
|
|
15
|
-
__export(require("./differential-loading"));
|
|
16
16
|
__export(require("./run-module-as-observable-fork"));
|
|
17
17
|
__export(require("./normalize-file-replacements"));
|
|
18
18
|
__export(require("./normalize-asset-patterns"));
|
|
@@ -6,7 +6,7 @@ const path = require("path");
|
|
|
6
6
|
const webpack_configs_1 = require("../angular-cli-files/models/webpack-configs");
|
|
7
7
|
const read_tsconfig_1 = require("../angular-cli-files/utilities/read-tsconfig");
|
|
8
8
|
const utils_1 = require("../utils");
|
|
9
|
-
const
|
|
9
|
+
const build_browser_features_1 = require("./build-browser-features");
|
|
10
10
|
const SpeedMeasurePlugin = require('speed-measure-webpack-plugin');
|
|
11
11
|
const webpackMerge = require('webpack-merge');
|
|
12
12
|
async function generateWebpackConfig(context, workspaceRoot, projectRoot, sourceRoot, options, webpackPartialGenerator, logger) {
|
|
@@ -20,9 +20,11 @@ async function generateWebpackConfig(context, workspaceRoot, projectRoot, source
|
|
|
20
20
|
const ts = await Promise.resolve().then(() => require('typescript'));
|
|
21
21
|
// At the moment, only the browser builder supports differential loading
|
|
22
22
|
// However this config generation is used by multiple builders such as dev-server
|
|
23
|
-
const scriptTarget = tsConfig.options.target;
|
|
23
|
+
const scriptTarget = tsConfig.options.target || ts.ScriptTarget.ES5;
|
|
24
|
+
const buildBrowserFeatures = new build_browser_features_1.BuildBrowserFeatures(projectRoot, scriptTarget);
|
|
24
25
|
const differentialLoading = context.builder.builderName === 'browser'
|
|
25
|
-
&&
|
|
26
|
+
&& !options.watch
|
|
27
|
+
&& buildBrowserFeatures.isDifferentialLoadingNeeded();
|
|
26
28
|
const scriptTargets = [scriptTarget];
|
|
27
29
|
if (differentialLoading) {
|
|
28
30
|
scriptTargets.unshift(ts.ScriptTarget.ES5);
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @license
|
|
3
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
4
|
-
*
|
|
5
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
6
|
-
* found in the LICENSE file at https://angular.io/license
|
|
7
|
-
*/
|
|
8
|
-
import { ScriptTarget } from 'typescript';
|
|
9
|
-
export declare function isDifferentialLoadingNeeded(projectRoot: string, target?: ScriptTarget): boolean;
|
|
10
|
-
export declare function isEs5SupportNeeded(projectRoot: string): boolean;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @license
|
|
4
|
-
* Copyright Google Inc. All Rights Reserved.
|
|
5
|
-
*
|
|
6
|
-
* Use of this source code is governed by an MIT-style license that can be
|
|
7
|
-
* found in the LICENSE file at https://angular.io/license
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
const browserslist = require("browserslist");
|
|
11
|
-
const caniuse = require("caniuse-api");
|
|
12
|
-
const typescript_1 = require("typescript");
|
|
13
|
-
function isDifferentialLoadingNeeded(projectRoot, target = typescript_1.ScriptTarget.ES5) {
|
|
14
|
-
const supportES2015 = target !== typescript_1.ScriptTarget.ES3 && target !== typescript_1.ScriptTarget.ES5;
|
|
15
|
-
return supportES2015 && isEs5SupportNeeded(projectRoot);
|
|
16
|
-
}
|
|
17
|
-
exports.isDifferentialLoadingNeeded = isDifferentialLoadingNeeded;
|
|
18
|
-
function isEs5SupportNeeded(projectRoot) {
|
|
19
|
-
const browsersList = browserslist(undefined, {
|
|
20
|
-
path: projectRoot,
|
|
21
|
-
});
|
|
22
|
-
return !caniuse.isSupported('es6-module', browsersList.join(', '));
|
|
23
|
-
}
|
|
24
|
-
exports.isEs5SupportNeeded = isEs5SupportNeeded;
|