Skip to content

Commit 71a393e

Browse files
authored
fix: make sure angular project configs can resolve correctly on windows (#32971)
1 parent a267d31 commit 71a393e

File tree

3 files changed

+7
-4
lines changed

3 files changed

+7
-4
lines changed

.circleci/src/pipeline/@pipeline.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ commands:
121121
name: Set environment variable to determine whether or not to persist artifacts
122122
command: |
123123
echo "Setting SHOULD_PERSIST_ARTIFACTS variable"
124-
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "feat/support_next_16" ]]; then
124+
echo 'if ! [[ "$CIRCLE_BRANCH" != "develop" && "$CIRCLE_BRANCH" != "release/"* && "$CIRCLE_BRANCH" != "fix/angular_dep_resolution_windows" ]]; then
125125
export SHOULD_PERSIST_ARTIFACTS=true
126126
fi' >> "$BASH_ENV"
127127
# You must run `setup_should_persist_artifacts` command and be using bash before running this command

.circleci/src/pipeline/workflows/@main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ linux-x64:
44
- equal: [ develop, << pipeline.git.branch >> ]
55
# use the following branch as well to ensure that v8 snapshot cache updates are fully tested
66
- equal: [ 'update-v8-snapshot-cache-on-develop', << pipeline.git.branch >> ]
7-
- equal: [ 'feat/support_next_16', << pipeline.git.branch >> ]
7+
- equal: [ 'fix/angular_dep_resolution_windows', << pipeline.git.branch >> ]
88
- matches:
99
pattern: /^release\/\d+\.\d+\.\d+$/
1010
value: << pipeline.git.branch >>

npm/webpack-dev-server/src/helpers/angularHandler.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import * as fs from 'fs-extra'
2-
import { tmpdir } from 'os'
2+
import { tmpdir, platform } from 'os'
33
import * as path from 'path'
44
import type { Configuration, RuleSetRule } from 'webpack'
55
import type { PresetHandlerResult, WebpackDevServerConfig } from '../devServer'
@@ -183,12 +183,15 @@ export async function getAngularCliModules (projectRoot: string) {
183183
{ logging },
184184
] = await Promise.all(angularCLiModules.map(async (dep) => {
185185
try {
186-
const depPath = require.resolve(dep, { paths: [projectRoot] })
186+
let depPath = require.resolve(dep, { paths: [projectRoot] })
187187
// NOTE: @cypress/webpack-dev-server is a CJS package, but we need to import some ESM files and absolute imports.
188188
// since import statements in TypeScript will get transpiled down to CommonJS require statements, we want to use tsx to leverage
189189
// an ESM style import here, which supports CommonJS and ESM.
190190
const { tsImport } = require('tsx/esm/api')
191191

192+
// NOTE: on Windows, fully qualified paths (ex: C:\Users\username\project\blah) need to be prefixed with `file://` to be properly resolved.
193+
depPath = platform() === 'win32' ? `file://${toPosix(depPath)}` : depPath
194+
192195
const module = await tsImport(depPath, __filename)
193196

194197
return module

0 commit comments

Comments
 (0)