Skip to content

Commit f31bf30

Browse files
clydindgp1130
authored andcommitted
fix(@angular-devkit/build-angular): avoid undefined module path for Sass imports in esbuild
When using Sass with the experimental esbuild-based browser application builder, bare imports without a path segment that were available via included paths but also happen to be a node module could cause an exception. An example of such an import would be `@import "globals";`. The deep import node module logic would previously attempt to join an undefined path segment to the resolved path for the `globals` package which would raise a argument type exception. This case has now been fixed by only joining if there is actually a path segment present such as `@import "globals/x"`. With this fix in place, the node module case can then continue and if no stylesheet is found, the include paths will then be searched. (cherry picked from commit d19f260)
1 parent de15ec5 commit f31bf30

File tree

1 file changed

+5
-1
lines changed
  • packages/angular_devkit/build_angular/src/builders/browser-esbuild

1 file changed

+5
-1
lines changed

packages/angular_devkit/build_angular/src/builders/browser-esbuild/sass-plugin.ts

+5-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,11 @@ async function compileString(
124124

125125
if (packageResult.path) {
126126
return pathToFileURL(
127-
join(dirname(packageResult.path), !hasScope ? nameOrFirstPath : '', ...pathPart),
127+
join(
128+
dirname(packageResult.path),
129+
!hasScope && nameOrFirstPath ? nameOrFirstPath : '',
130+
...pathPart,
131+
),
128132
);
129133
}
130134
}

0 commit comments

Comments
 (0)