@angular-devkit/build-angular 17.1.0-next.1 → 17.1.0-next.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.
Files changed (51) hide show
  1. package/package.json +18 -18
  2. package/src/builders/application/build-action.d.ts +4 -3
  3. package/src/builders/application/build-action.js +24 -14
  4. package/src/builders/application/execute-build.js +3 -3
  5. package/src/builders/application/index.d.ts +20 -10
  6. package/src/builders/application/index.js +38 -26
  7. package/src/builders/application/options.d.ts +11 -3
  8. package/src/builders/application/options.js +39 -26
  9. package/src/builders/application/schema.d.ts +32 -2
  10. package/src/builders/application/schema.json +40 -2
  11. package/src/builders/browser-esbuild/builder-status-warnings.js +1 -3
  12. package/src/builders/browser-esbuild/index.js +8 -4
  13. package/src/builders/dev-server/builder.js +5 -0
  14. package/src/builders/dev-server/vite-server.js +16 -16
  15. package/src/builders/karma/index.js +4 -1
  16. package/src/builders/karma/schema.d.ts +6 -2
  17. package/src/builders/karma/schema.json +12 -2
  18. package/src/builders/ssr-dev-server/index.js +17 -31
  19. package/src/tools/esbuild/angular/angular-host.js +7 -1
  20. package/src/tools/esbuild/angular/compiler-plugin.js +11 -27
  21. package/src/tools/esbuild/angular/component-stylesheets.d.ts +3 -6
  22. package/src/tools/esbuild/angular/component-stylesheets.js +42 -47
  23. package/src/tools/esbuild/angular/jit-plugin-callbacks.d.ts +2 -1
  24. package/src/tools/esbuild/angular/jit-plugin-callbacks.js +16 -16
  25. package/src/tools/esbuild/angular/source-file-cache.js +0 -1
  26. package/src/tools/esbuild/bundler-context.d.ts +1 -1
  27. package/src/tools/esbuild/bundler-context.js +18 -2
  28. package/src/tools/esbuild/compiler-plugin-options.js +5 -3
  29. package/src/tools/esbuild/global-styles.js +4 -2
  30. package/src/tools/esbuild/index-html-generator.js +3 -1
  31. package/src/tools/esbuild/stylesheets/bundle-options.d.ts +4 -1
  32. package/src/tools/esbuild/stylesheets/bundle-options.js +11 -6
  33. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.d.ts +25 -0
  34. package/src/tools/esbuild/stylesheets/css-inline-fonts-plugin.js +57 -0
  35. package/src/tools/esbuild/stylesheets/stylesheet-plugin-factory.js +9 -1
  36. package/src/tools/esbuild/utils.d.ts +2 -2
  37. package/src/tools/esbuild/utils.js +61 -74
  38. package/src/tools/esbuild/watcher.js +56 -121
  39. package/src/utils/check-port.js +15 -29
  40. package/src/utils/delete-output-dir.d.ts +1 -1
  41. package/src/utils/delete-output-dir.js +11 -2
  42. package/src/utils/index-file/index-html-generator.js +15 -28
  43. package/src/utils/index-file/inline-fonts.d.ts +6 -1
  44. package/src/utils/index-file/inline-fonts.js +30 -14
  45. package/src/utils/index.d.ts +1 -0
  46. package/src/utils/index.js +1 -0
  47. package/src/{builders/dev-server → utils}/load-proxy-config.js +2 -2
  48. package/src/utils/server-rendering/esm-in-memory-loader/node-18-utils.js +6 -5
  49. package/src/tools/esbuild/normalize-path.d.ts +0 -8
  50. package/src/tools/esbuild/normalize-path.js +0 -22
  51. /package/src/{builders/dev-server → utils}/load-proxy-config.d.ts +0 -0
@@ -6,13 +6,11 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
- var __importDefault = (this && this.__importDefault) || function (mod) {
10
- return (mod && mod.__esModule) ? mod : { "default": mod };
11
- };
12
9
  Object.defineProperty(exports, "__esModule", { value: true });
13
10
  exports.setupJitPluginCallbacks = void 0;
14
11
  const promises_1 = require("node:fs/promises");
15
- const node_path_1 = __importDefault(require("node:path"));
12
+ const node_path_1 = require("node:path");
13
+ const load_result_cache_1 = require("../load-result-cache");
16
14
  const uri_1 = require("./uri");
17
15
  /**
18
16
  * Loads/extracts the contents from a load callback Angular JIT entry.
@@ -27,7 +25,7 @@ const uri_1 = require("./uri");
27
25
  */
28
26
  async function loadEntry(entry, root, skipRead) {
29
27
  if (entry.startsWith('file:')) {
30
- const specifier = node_path_1.default.join(root, entry.slice(5));
28
+ const specifier = (0, node_path_1.join)(root, entry.slice(5));
31
29
  return {
32
30
  path: specifier,
33
31
  contents: skipRead ? undefined : await (0, promises_1.readFile)(specifier, 'utf-8'),
@@ -36,7 +34,7 @@ async function loadEntry(entry, root, skipRead) {
36
34
  else if (entry.startsWith('inline:')) {
37
35
  const [importer, data] = entry.slice(7).split(';', 2);
38
36
  return {
39
- path: node_path_1.default.join(root, importer),
37
+ path: (0, node_path_1.join)(root, importer),
40
38
  contents: Buffer.from(data, 'base64').toString(),
41
39
  };
42
40
  }
@@ -53,7 +51,7 @@ async function loadEntry(entry, root, skipRead) {
53
51
  * @param styleOptions The options to use when bundling stylesheets.
54
52
  * @param additionalResultFiles A Map where stylesheet resources will be added.
55
53
  */
56
- function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles, inlineStyleLanguage) {
54
+ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles, inlineStyleLanguage, loadCache) {
57
55
  const root = build.initialOptions.absWorkingDir ?? '';
58
56
  // Add a resolve callback to capture and parse any JIT URIs that were added by the
59
57
  // JIT resource TypeScript transformer.
@@ -68,13 +66,13 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
68
66
  return {
69
67
  // Use a relative path to prevent fully resolved paths in the metafile (JSON stats file).
70
68
  // This is only necessary for custom namespaces. esbuild will handle the file namespace.
71
- path: 'file:' + node_path_1.default.relative(root, node_path_1.default.join(node_path_1.default.dirname(args.importer), specifier)),
69
+ path: 'file:' + (0, node_path_1.relative)(root, (0, node_path_1.join)((0, node_path_1.dirname)(args.importer), specifier)),
72
70
  namespace,
73
71
  };
74
72
  }
75
73
  else {
76
74
  // Inline data may need the importer to resolve imports/references within the content
77
- const importer = node_path_1.default.relative(root, args.importer);
75
+ const importer = (0, node_path_1.relative)(root, args.importer);
78
76
  return {
79
77
  path: `inline:${importer};${specifier}`,
80
78
  namespace,
@@ -82,7 +80,7 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
82
80
  }
83
81
  });
84
82
  // Add a load callback to handle Component stylesheets (both inline and external)
85
- build.onLoad({ filter: /./, namespace: uri_1.JIT_STYLE_NAMESPACE }, async (args) => {
83
+ build.onLoad({ filter: /./, namespace: uri_1.JIT_STYLE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
86
84
  // skipRead is used here because the stylesheet bundling will read a file stylesheet
87
85
  // directly either via a preprocessor or esbuild itself.
88
86
  const entry = await loadEntry(args.path, root, true /* skipRead */);
@@ -94,24 +92,26 @@ function setupJitPluginCallbacks(build, stylesheetBundler, additionalResultFiles
94
92
  else {
95
93
  stylesheetResult = await stylesheetBundler.bundleInline(entry.contents, entry.path, inlineStyleLanguage);
96
94
  }
97
- const { contents, resourceFiles, errors, warnings, metafile } = stylesheetResult;
98
- additionalResultFiles.set(entry.path, { outputFiles: resourceFiles, metafile });
95
+ const { contents, outputFiles, errors, warnings, metafile, referencedFiles } = stylesheetResult;
96
+ additionalResultFiles.set(entry.path, { outputFiles, metafile });
99
97
  return {
100
98
  errors,
101
99
  warnings,
102
100
  contents,
103
101
  loader: 'text',
102
+ watchFiles: referencedFiles && [...referencedFiles],
104
103
  };
105
- });
104
+ }));
106
105
  // Add a load callback to handle Component templates
107
106
  // NOTE: While this callback supports both inline and external templates, the transformer
108
107
  // currently only supports generating URIs for external templates.
109
- build.onLoad({ filter: /./, namespace: uri_1.JIT_TEMPLATE_NAMESPACE }, async (args) => {
110
- const { contents } = await loadEntry(args.path, root);
108
+ build.onLoad({ filter: /./, namespace: uri_1.JIT_TEMPLATE_NAMESPACE }, (0, load_result_cache_1.createCachedLoad)(loadCache, async (args) => {
109
+ const { contents, path } = await loadEntry(args.path, root);
111
110
  return {
112
111
  contents,
113
112
  loader: 'text',
113
+ watchFiles: [path],
114
114
  };
115
- });
115
+ }));
116
116
  }
117
117
  exports.setupJitPluginCallbacks = setupJitPluginCallbacks;
@@ -52,7 +52,6 @@ class SourceFileCache extends Map {
52
52
  }
53
53
  for (let file of files) {
54
54
  file = path.normalize(file);
55
- this.typeScriptFileCache.delete(file);
56
55
  this.loadResultCache.invalidate(file);
57
56
  // Normalize separators to allow matching TypeScript Host paths
58
57
  if (USING_WINDOWS) {
@@ -20,6 +20,7 @@ export type BundleContextResult = {
20
20
  server?: Set<string>;
21
21
  browser?: Set<string>;
22
22
  };
23
+ externalConfiguration?: string[];
23
24
  };
24
25
  export interface InitialFileRecord {
25
26
  entrypoint: boolean;
@@ -35,7 +36,6 @@ export declare enum BuildOutputFileType {
35
36
  }
36
37
  export interface BuildOutputFile extends OutputFile {
37
38
  type: BuildOutputFileType;
38
- fullOutputPath: string;
39
39
  clone: () => BuildOutputFile;
40
40
  }
41
41
  export type BundlerOptionsFactory<T extends BuildOptions = BuildOptions> = (loadCache: LoadResultCache | undefined) => T;
@@ -6,9 +6,13 @@
6
6
  * Use of this source code is governed by an MIT-style license that can be
7
7
  * found in the LICENSE file at https://angular.io/license
8
8
  */
9
+ var __importDefault = (this && this.__importDefault) || function (mod) {
10
+ return (mod && mod.__esModule) ? mod : { "default": mod };
11
+ };
9
12
  Object.defineProperty(exports, "__esModule", { value: true });
10
13
  exports.BundlerContext = exports.BuildOutputFileType = void 0;
11
14
  const esbuild_1 = require("esbuild");
15
+ const node_assert_1 = __importDefault(require("node:assert"));
12
16
  const node_path_1 = require("node:path");
13
17
  const load_result_cache_1 = require("./load-result-cache");
14
18
  const utils_1 = require("./utils");
@@ -71,6 +75,7 @@ class BundlerContext {
71
75
  const externalImportsBrowser = new Set();
72
76
  const externalImportsServer = new Set();
73
77
  const outputFiles = [];
78
+ let externalConfiguration;
74
79
  for (const result of individualResults) {
75
80
  warnings.push(...result.warnings);
76
81
  if (result.errors) {
@@ -87,6 +92,12 @@ class BundlerContext {
87
92
  outputFiles.push(...result.outputFiles);
88
93
  result.externalImports.browser?.forEach((value) => externalImportsBrowser.add(value));
89
94
  result.externalImports.server?.forEach((value) => externalImportsServer.add(value));
95
+ if (result.externalConfiguration) {
96
+ externalConfiguration ??= new Set();
97
+ for (const value of result.externalConfiguration) {
98
+ externalConfiguration.add(value);
99
+ }
100
+ }
90
101
  }
91
102
  if (errors !== undefined) {
92
103
  return { errors, warnings };
@@ -101,6 +112,7 @@ class BundlerContext {
101
112
  browser: externalImportsBrowser,
102
113
  server: externalImportsServer,
103
114
  },
115
+ externalConfiguration: externalConfiguration ? [...externalConfiguration] : undefined,
104
116
  };
105
117
  }
106
118
  /**
@@ -250,10 +262,13 @@ class BundlerContext {
250
262
  externalImports.add(importData.path);
251
263
  }
252
264
  }
253
- const platformIsServer = this.#esbuildOptions?.platform === 'node';
265
+ (0, node_assert_1.default)(this.#esbuildOptions, 'esbuild options cannot be undefined.');
266
+ const { platform, assetNames = '' } = this.#esbuildOptions;
267
+ const platformIsServer = platform === 'node';
268
+ const mediaDirname = (0, node_path_1.dirname)(assetNames);
254
269
  const outputFiles = result.outputFiles.map((file) => {
255
270
  let fileType;
256
- if ((0, node_path_1.dirname)(file.path) === 'media') {
271
+ if ((0, node_path_1.dirname)(file.path) === mediaDirname) {
257
272
  fileType = BuildOutputFileType.Media;
258
273
  }
259
274
  else {
@@ -269,6 +284,7 @@ class BundlerContext {
269
284
  externalImports: {
270
285
  [platformIsServer ? 'server' : 'browser']: externalImports,
271
286
  },
287
+ externalConfiguration: this.#esbuildOptions.external,
272
288
  errors: undefined,
273
289
  };
274
290
  }
@@ -9,7 +9,7 @@
9
9
  Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.createCompilerPluginOptions = void 0;
11
11
  function createCompilerPluginOptions(options, target, sourceFileCache) {
12
- const { workspaceRoot, optimizationOptions, sourcemapOptions, tsconfig, outputNames, fileReplacements, externalDependencies, preserveSymlinks, stylePreprocessorOptions, advancedOptimizations, inlineStyleLanguage, jit, tailwindConfiguration, } = options;
12
+ const { workspaceRoot, optimizationOptions, sourcemapOptions, tsconfig, outputNames, fileReplacements, externalDependencies, preserveSymlinks, stylePreprocessorOptions, advancedOptimizations, inlineStyleLanguage, jit, cacheOptions, tailwindConfiguration, publicPath, } = options;
13
13
  return {
14
14
  // JS/TS options
15
15
  pluginOptions: {
@@ -26,12 +26,13 @@ function createCompilerPluginOptions(options, target, sourceFileCache) {
26
26
  // Component stylesheet options
27
27
  styleOptions: {
28
28
  workspaceRoot,
29
+ inlineFonts: !!optimizationOptions.fonts.inline,
29
30
  optimization: !!optimizationOptions.styles.minify,
30
31
  sourcemap:
31
32
  // Hidden component stylesheet sourcemaps are inaccessible which is effectively
32
33
  // the same as being disabled. Disabling has the advantage of avoiding the overhead
33
34
  // of sourcemap processing.
34
- !!sourcemapOptions.styles && (sourcemapOptions.hidden ? false : 'inline'),
35
+ sourcemapOptions.styles && !sourcemapOptions.hidden ? 'linked' : false,
35
36
  outputNames,
36
37
  includePaths: stylePreprocessorOptions?.includePaths,
37
38
  externalDependencies,
@@ -39,7 +40,8 @@ function createCompilerPluginOptions(options, target, sourceFileCache) {
39
40
  inlineStyleLanguage,
40
41
  preserveSymlinks,
41
42
  tailwindConfiguration,
42
- publicPath: options.publicPath,
43
+ cacheOptions,
44
+ publicPath,
43
45
  },
44
46
  };
45
47
  }
@@ -15,7 +15,7 @@ const node_assert_1 = __importDefault(require("node:assert"));
15
15
  const bundle_options_1 = require("./stylesheets/bundle-options");
16
16
  const virtual_module_plugin_1 = require("./virtual-module-plugin");
17
17
  function createGlobalStylesBundleOptions(options, target, initial) {
18
- const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, tailwindConfiguration, } = options;
18
+ const { workspaceRoot, optimizationOptions, sourcemapOptions, outputNames, globalStyles, preserveSymlinks, externalDependencies, stylePreprocessorOptions, tailwindConfiguration, cacheOptions, publicPath, } = options;
19
19
  const namespace = 'angular:styles/global';
20
20
  const entryPoints = {};
21
21
  let found = false;
@@ -33,6 +33,7 @@ function createGlobalStylesBundleOptions(options, target, initial) {
33
33
  const buildOptions = (0, bundle_options_1.createStylesheetBundleOptions)({
34
34
  workspaceRoot,
35
35
  optimization: !!optimizationOptions.styles.minify,
36
+ inlineFonts: !!optimizationOptions.fonts.inline,
36
37
  sourcemap: !!sourcemapOptions.styles,
37
38
  preserveSymlinks,
38
39
  target,
@@ -45,7 +46,8 @@ function createGlobalStylesBundleOptions(options, target, initial) {
45
46
  },
46
47
  includePaths: stylePreprocessorOptions?.includePaths,
47
48
  tailwindConfiguration,
48
- publicPath: options.publicPath,
49
+ cacheOptions,
50
+ publicPath,
49
51
  }, loadCache);
50
52
  // Keep special CSS comments `/*! comment */` in place when `removeSpecialComments` is disabled.
51
53
  // These comments are special for a number of CSS tools such as Critters and PurgeCSS.
@@ -45,7 +45,7 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
45
45
  const hints = [];
46
46
  const { indexHtmlOptions, externalPackages, optimizationOptions, crossOrigin, subresourceIntegrity, baseHref, } = buildOptions;
47
47
  (0, node_assert_1.default)(indexHtmlOptions, 'indexHtmlOptions cannot be undefined.');
48
- if (!externalPackages) {
48
+ if (!externalPackages && indexHtmlOptions.preloadInitial) {
49
49
  for (const [key, value] of initialFiles) {
50
50
  if (value.entrypoint) {
51
51
  // Entry points are already referenced in the HTML
@@ -87,6 +87,7 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
87
87
  },
88
88
  crossOrigin: crossOrigin,
89
89
  deployUrl: buildOptions.publicPath,
90
+ postTransform: indexHtmlOptions.transformer,
90
91
  });
91
92
  indexHtmlGenerator.readAsset = readAsset;
92
93
  const transformResult = await indexHtmlGenerator.process({
@@ -110,6 +111,7 @@ async function generateIndexHtml(initialFiles, outputFiles, buildOptions, lang)
110
111
  const { InlineCriticalCssProcessor } = await Promise.resolve().then(() => __importStar(require('../../utils/index-file/inline-critical-css')));
111
112
  const inlineCriticalCssProcessor = new InlineCriticalCssProcessor({
112
113
  minify: false, // CSS has already been minified during the build.
114
+ deployUrl: buildOptions.publicPath,
113
115
  readAsset,
114
116
  });
115
117
  const { content, errors, warnings } = await inlineCriticalCssProcessor.process(contentWithoutCriticalCssInlined, {
@@ -6,12 +6,14 @@
6
6
  * found in the LICENSE file at https://angular.io/license
7
7
  */
8
8
  import type { BuildOptions } from 'esbuild';
9
+ import { NormalizedCachedOptions } from '../../../utils/normalize-cache';
9
10
  import { LoadResultCache } from '../load-result-cache';
10
11
  export interface BundleStylesheetOptions {
11
12
  workspaceRoot: string;
12
13
  optimization: boolean;
14
+ inlineFonts: boolean;
13
15
  preserveSymlinks?: boolean;
14
- sourcemap: boolean | 'external' | 'inline';
16
+ sourcemap: boolean | 'external' | 'inline' | 'linked';
15
17
  outputNames: {
16
18
  bundles: string;
17
19
  media: string;
@@ -24,6 +26,7 @@ export interface BundleStylesheetOptions {
24
26
  package: string;
25
27
  };
26
28
  publicPath?: string;
29
+ cacheOptions: NormalizedCachedOptions;
27
30
  }
28
31
  export declare function createStylesheetBundleOptions(options: BundleStylesheetOptions, cache?: LoadResultCache, inlineComponentData?: Record<string, string>): BuildOptions & {
29
32
  plugins: NonNullable<BuildOptions['plugins']>;
@@ -12,6 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
12
12
  Object.defineProperty(exports, "__esModule", { value: true });
13
13
  exports.createStylesheetBundleOptions = void 0;
14
14
  const node_path_1 = __importDefault(require("node:path"));
15
+ const css_inline_fonts_plugin_1 = require("./css-inline-fonts-plugin");
15
16
  const css_language_1 = require("./css-language");
16
17
  const css_resource_plugin_1 = require("./css-resource-plugin");
17
18
  const less_language_1 = require("./less-language");
@@ -26,6 +27,15 @@ function createStylesheetBundleOptions(options, cache, inlineComponentData) {
26
27
  inlineComponentData,
27
28
  tailwindConfiguration: options.tailwindConfiguration,
28
29
  }, cache);
30
+ const plugins = [
31
+ pluginFactory.create(sass_language_1.SassStylesheetLanguage),
32
+ pluginFactory.create(less_language_1.LessStylesheetLanguage),
33
+ pluginFactory.create(css_language_1.CssStylesheetLanguage),
34
+ (0, css_resource_plugin_1.createCssResourcePlugin)(cache),
35
+ ];
36
+ if (options.inlineFonts) {
37
+ plugins.push((0, css_inline_fonts_plugin_1.createCssInlineFontsPlugin)({ cache, cacheOptions: options.cacheOptions }));
38
+ }
29
39
  return {
30
40
  absWorkingDir: options.workspaceRoot,
31
41
  bundle: true,
@@ -44,12 +54,7 @@ function createStylesheetBundleOptions(options, cache, inlineComponentData) {
44
54
  publicPath: options.publicPath,
45
55
  conditions: ['style', 'sass', 'less'],
46
56
  mainFields: ['style', 'sass'],
47
- plugins: [
48
- pluginFactory.create(sass_language_1.SassStylesheetLanguage),
49
- pluginFactory.create(less_language_1.LessStylesheetLanguage),
50
- pluginFactory.create(css_language_1.CssStylesheetLanguage),
51
- (0, css_resource_plugin_1.createCssResourcePlugin)(cache),
52
- ],
57
+ plugins,
53
58
  };
54
59
  }
55
60
  exports.createStylesheetBundleOptions = createStylesheetBundleOptions;
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @license
3
+ * Copyright Google LLC 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 type { Plugin } from 'esbuild';
9
+ import { NormalizedCachedOptions } from '../../../utils/normalize-cache';
10
+ import { LoadResultCache } from '../load-result-cache';
11
+ /**
12
+ * Options for the createCssInlineFontsPlugin
13
+ * @see createCssInlineFontsPlugin
14
+ */
15
+ export interface CssInlineFontsPluginOptions {
16
+ /** Disk cache normalized options */
17
+ cacheOptions?: NormalizedCachedOptions;
18
+ /** Load results cache. */
19
+ cache?: LoadResultCache;
20
+ }
21
+ /**
22
+ * Creates an esbuild {@link Plugin} that inlines fonts imported via import-rule.
23
+ * within the build configuration.
24
+ */
25
+ export declare function createCssInlineFontsPlugin({ cache, cacheOptions, }: CssInlineFontsPluginOptions): Plugin;
@@ -0,0 +1,57 @@
1
+ "use strict";
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.createCssInlineFontsPlugin = void 0;
11
+ const inline_fonts_1 = require("../../../utils/index-file/inline-fonts");
12
+ const load_result_cache_1 = require("../load-result-cache");
13
+ /**
14
+ * Creates an esbuild {@link Plugin} that inlines fonts imported via import-rule.
15
+ * within the build configuration.
16
+ */
17
+ function createCssInlineFontsPlugin({ cache, cacheOptions, }) {
18
+ return {
19
+ name: 'angular-css-inline-fonts-plugin',
20
+ setup(build) {
21
+ const inlineFontsProcessor = new inline_fonts_1.InlineFontsProcessor({ cache: cacheOptions, minify: false });
22
+ build.onResolve({ filter: /fonts\.googleapis\.com|use\.typekit\.net/ }, (args) => {
23
+ // Only attempt to resolve import-rule tokens which only exist inside CSS.
24
+ if (args.kind !== 'import-rule') {
25
+ return null;
26
+ }
27
+ if (!inlineFontsProcessor.canInlineRequest(args.path)) {
28
+ return null;
29
+ }
30
+ return {
31
+ path: args.path,
32
+ namespace: 'css-inline-fonts',
33
+ };
34
+ });
35
+ build.onLoad({ filter: /./, namespace: 'css-inline-fonts' }, (0, load_result_cache_1.createCachedLoad)(cache, async (args) => {
36
+ try {
37
+ return {
38
+ contents: await inlineFontsProcessor.processURL(args.path),
39
+ loader: 'css',
40
+ };
41
+ }
42
+ catch (error) {
43
+ return {
44
+ loader: 'css',
45
+ errors: [
46
+ {
47
+ text: `Failed to inline external stylesheet '${args.path}'.`,
48
+ detail: error,
49
+ },
50
+ ],
51
+ };
52
+ }
53
+ }));
54
+ },
55
+ };
56
+ }
57
+ exports.createCssInlineFontsPlugin = createCssInlineFontsPlugin;
@@ -49,7 +49,15 @@ let postcss;
49
49
  *
50
50
  * Based on https://tailwindcss.com/docs/functions-and-directives
51
51
  */
52
- const TAILWIND_KEYWORDS = ['@tailwind', '@layer', '@apply', '@config', 'theme(', 'screen('];
52
+ const TAILWIND_KEYWORDS = [
53
+ '@tailwind',
54
+ '@layer',
55
+ '@apply',
56
+ '@config',
57
+ 'theme(',
58
+ 'screen(',
59
+ '@screen', // Undocumented in version 3, see: https://github.com/tailwindlabs/tailwindcss/discussions/7516.
60
+ ];
53
61
  /**
54
62
  * Cached postcss instances that can be re-used between various StylesheetPluginFactory instances.
55
63
  */
@@ -7,6 +7,7 @@
7
7
  */
8
8
  import { BuilderContext } from '@angular-devkit/architect';
9
9
  import { BuildOptions, Metafile, OutputFile, PartialMessage } from 'esbuild';
10
+ import { NormalizedOutputOptions } from '../../builders/application/options';
10
11
  import { BudgetCalculatorResult } from '../../utils/bundle-calculator';
11
12
  import { BuildOutputFile, BuildOutputFileType, InitialFileRecord } from './bundler-context';
12
13
  import { BuildOutputAsset } from './bundler-execution-result';
@@ -25,12 +26,11 @@ export declare function logMessages(context: BuilderContext, { errors, warnings
25
26
  * @returns An object that can be used with the esbuild build `supported` option.
26
27
  */
27
28
  export declare function getFeatureSupport(target: string[]): BuildOptions['supported'];
28
- export declare function writeResultFiles(outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[] | undefined, outputPath: string): Promise<void>;
29
+ export declare function writeResultFiles(outputFiles: BuildOutputFile[], assetFiles: BuildOutputAsset[] | undefined, { base, browser, media, server }: NormalizedOutputOptions): Promise<void>;
29
30
  export declare function emitFilesToDisk<T = BuildOutputAsset | BuildOutputFile>(files: T[], writeFileCallback: (file: T) => Promise<void>): Promise<void>;
30
31
  export declare function createOutputFileFromText(path: string, text: string, type: BuildOutputFileType): BuildOutputFile;
31
32
  export declare function createOutputFileFromData(path: string, data: Uint8Array, type: BuildOutputFileType): BuildOutputFile;
32
33
  export declare function convertOutputFile(file: OutputFile, type: BuildOutputFileType): BuildOutputFile;
33
- export declare function getFullOutputPath(file: BuildOutputFile): string;
34
34
  /**
35
35
  * Transform browserlists result to esbuild target.
36
36
  * @see https://esbuild.github.io/api/#target