@angular/build 18.0.2 → 18.0.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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@angular/build",
3
- "version": "18.0.2",
3
+ "version": "18.0.3",
4
4
  "description": "Official build system for Angular",
5
5
  "keywords": [
6
6
  "Angular CLI",
@@ -23,7 +23,7 @@
23
23
  "builders": "builders.json",
24
24
  "dependencies": {
25
25
  "@ampproject/remapping": "2.3.0",
26
- "@angular-devkit/architect": "0.1800.2",
26
+ "@angular-devkit/architect": "0.1800.3",
27
27
  "@babel/core": "7.24.5",
28
28
  "@babel/helper-annotate-as-pure": "7.22.5",
29
29
  "@babel/helper-split-export-declaration": "7.24.5",
@@ -53,9 +53,10 @@ function createCompilerPlugin(pluginOptions, styleOptions) {
53
53
  async setup(build) {
54
54
  let setupWarnings = [];
55
55
  const preserveSymlinks = build.initialOptions.preserveSymlinks;
56
- // Initialize a worker pool for JavaScript transformations
56
+ // Initialize a worker pool for JavaScript transformations.
57
+ // Webcontainers currently do not support this persistent cache store.
57
58
  let cacheStore;
58
- if (pluginOptions.sourceFileCache?.persistentCachePath) {
59
+ if (pluginOptions.sourceFileCache?.persistentCachePath && !process.versions.webcontainer) {
59
60
  const { LmbdCacheStore } = await Promise.resolve().then(() => __importStar(require('../lmdb-cache-store')));
60
61
  cacheStore = new LmbdCacheStore(path.join(pluginOptions.sourceFileCache.persistentCachePath, 'angular-compiler.db'));
61
62
  }
@@ -169,6 +169,10 @@ async function compileString(data, filePath, syntax, options, resolveUrl) {
169
169
  catch (error) {
170
170
  if (isSassException(error)) {
171
171
  const fileWithError = error.span.url ? (0, node_url_1.fileURLToPath)(error.span.url) : undefined;
172
+ const watchFiles = [filePath, ...extractFilesFromStack(error.sassStack)];
173
+ if (fileWithError) {
174
+ watchFiles.push(fileWithError);
175
+ }
172
176
  return {
173
177
  loader: 'css',
174
178
  errors: [
@@ -177,7 +181,7 @@ async function compileString(data, filePath, syntax, options, resolveUrl) {
177
181
  },
178
182
  ],
179
183
  warnings,
180
- watchFiles: fileWithError ? [filePath, fileWithError] : [filePath],
184
+ watchFiles,
181
185
  };
182
186
  }
183
187
  throw error;
@@ -190,3 +194,25 @@ function sourceMapToUrlComment(sourceMap, root) {
190
194
  const urlSourceMap = Buffer.from(JSON.stringify(sourceMap), 'utf-8').toString('base64');
191
195
  return `/*# sourceMappingURL=data:application/json;charset=utf-8;base64,${urlSourceMap} */`;
192
196
  }
197
+ function* extractFilesFromStack(stack) {
198
+ const lines = stack.split('\n');
199
+ const cwd = process.cwd();
200
+ // Stack line has format of "<file> <location> <identifier>"
201
+ for (const line of lines) {
202
+ const segments = line.split(' ');
203
+ if (segments.length < 3) {
204
+ break;
205
+ }
206
+ // Extract path from stack line.
207
+ // Paths may contain spaces. All segments before location are part of the file path.
208
+ let path = '';
209
+ let index = 0;
210
+ while (!segments[index].match(/\d+:\d+/)) {
211
+ path += segments[index++];
212
+ }
213
+ if (path) {
214
+ // Stack paths from dart-sass are relative to the current working directory (not input file or workspace root)
215
+ yield (0, node_path_1.join)(cwd, path);
216
+ }
217
+ }
218
+ }
@@ -45,9 +45,20 @@ function* findUrls(contents) {
45
45
  };
46
46
  // Based on https://www.w3.org/TR/css-syntax-3/#consume-ident-like-token
47
47
  while ((pos = contents.indexOf('url(', pos)) !== -1) {
48
+ width = 1;
49
+ // Ensure whitespace, comma, or colon before `url(`
50
+ if (pos > 0) {
51
+ pos -= 2;
52
+ next();
53
+ if (!isWhitespace(current) && current !== 0x0027 && current !== 0x003a) {
54
+ // Skip - not a url token
55
+ pos += 3;
56
+ continue;
57
+ }
58
+ pos += 1;
59
+ }
48
60
  // Set to position of the (
49
61
  pos += 3;
50
- width = 1;
51
62
  // Consume all leading whitespace
52
63
  while (isWhitespace(next())) {
53
64
  /* empty */
@@ -17,25 +17,6 @@ const node_path_1 = require("node:path");
17
17
  const node_url_1 = require("node:url");
18
18
  const error_1 = require("../../utils/error");
19
19
  const lexer_1 = require("./lexer");
20
- /**
21
- * Ensures that a bare specifier URL path that is intended to be treated as
22
- * a relative path has a leading `./` or `../` prefix.
23
- *
24
- * @param url A bare specifier URL path that should be considered relative.
25
- * @returns
26
- */
27
- function ensureRelative(url) {
28
- // Empty
29
- if (!url) {
30
- return url;
31
- }
32
- // Already relative
33
- if (url[0] === '.' && (url[1] === '/' || (url[1] === '.' && url[2] === '/'))) {
34
- return url;
35
- }
36
- // Needs prefix
37
- return './' + url;
38
- }
39
20
  /**
40
21
  * A Sass Importer base class that provides the load logic to rebase all `url()` functions
41
22
  * within a stylesheet. The rebasing will ensure that the URLs in the output of the Sass compiler
@@ -84,13 +65,13 @@ class UrlRebasingImporter {
84
65
  }
85
66
  // Sass variable usage either starts with a `$` or contains a namespace and a `.$`
86
67
  const valueNormalized = value[0] === '$' || /^\w+\.\$/.test(value) ? `#{${value}}` : value;
87
- const rebasedPath = (0, node_path_1.relative)(this.entryDirectory, stylesheetDirectory) + '||file:' + valueNormalized;
68
+ const rebasedPath = (0, node_path_1.relative)(this.entryDirectory, stylesheetDirectory);
88
69
  // Normalize path separators and escape characters
89
70
  // https://developer.mozilla.org/en-US/docs/Web/CSS/url#syntax
90
- const rebasedUrl = ensureRelative(rebasedPath.replace(/\\/g, '/').replace(/[()\s'"]/g, '\\$&'));
71
+ const rebasedUrl = rebasedPath.replace(/\\/g, '/').replace(/[()\s'"]/g, '\\$&');
91
72
  updatedContents ??= new magic_string_1.default(contents);
92
73
  // Always quote the URL to avoid potential downstream parsing problems
93
- updatedContents.update(start, end, `"${rebasedUrl}"`);
74
+ updatedContents.update(start, end, `"${rebasedUrl}||file:${valueNormalized}"`);
94
75
  }
95
76
  if (updatedContents) {
96
77
  contents = updatedContents.toString();
@@ -10,7 +10,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
10
10
  exports.normalizeCacheOptions = void 0;
11
11
  const node_path_1 = require("node:path");
12
12
  /** Version placeholder is replaced during the build process with actual package version */
13
- const VERSION = '18.0.2';
13
+ const VERSION = '18.0.3';
14
14
  function hasCacheMetadata(value) {
15
15
  return (!!value &&
16
16
  typeof value === 'object' &&