1 | ;
|
2 | /**
|
3 | * @license
|
4 | * Copyright Google LLC 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 | exports.BuildOptimizerWebpackPlugin = void 0;
|
11 | class BuildOptimizerWebpackPlugin {
|
12 | apply(compiler) {
|
13 | compiler.hooks.normalModuleFactory.tap('BuildOptimizerWebpackPlugin', (nmf) => {
|
14 | nmf.hooks.module.tap('BuildOptimizerWebpackPlugin', (module, data) => {
|
15 | var _a;
|
16 | if ((_a = data.resourceResolveData) === null || _a === void 0 ? void 0 : _a.descriptionFileData) {
|
17 | // Only TS packages should use Build Optimizer.
|
18 | // Notes:
|
19 | // - a TS package might not have defined typings but still use .d.ts files next to their
|
20 | // .js files. We don't cover that case because the Angular Package Format (APF) calls for
|
21 | // using the Typings field and Build Optimizer is geared towards APF. Maybe we could
|
22 | // provide configuration options to the plugin to cover that case if there's demand.
|
23 | // - a JS-only package that also happens to provides typings will also be flagged by this
|
24 | // check. Not sure there's a good way to skip those.
|
25 | const skipBuildOptimizer = !data.resourceResolveData.descriptionFileData.typings;
|
26 | module.factoryMeta = { ...module.factoryMeta, skipBuildOptimizer };
|
27 | }
|
28 | return module;
|
29 | });
|
30 | });
|
31 | }
|
32 | }
|
33 | exports.BuildOptimizerWebpackPlugin = BuildOptimizerWebpackPlugin;
|