Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(compiler): handle file rename in watch mode #5971

Merged
merged 3 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 2 additions & 4 deletions .github/workflows/test-wdio.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
# https://docs.github.com/en/actions/using-workflows/reusing-workflows

jobs:
run_wdio:
wdio_test:
name: Run WebdriverIO Component Tests (${{ matrix.browser }})
runs-on: ubuntu-22.04
strategy:
Expand All @@ -27,9 +27,6 @@ jobs:
node-version-file: './test/wdio/package.json'
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Download Build Archive
uses: ./.github/workflows/actions/download-archive
with:
Expand All @@ -39,6 +36,7 @@ jobs:

- name: Run WebdriverIO Component Tests
run: npm run test.wdio
shell: bash
env:
BROWSER: ${{ matrix.browser }}

Expand Down
20 changes: 20 additions & 0 deletions src/compiler/build/watch-build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,26 @@ export const createWatchBuild = async (
);
}

// Make sure all files in the module map are still in the fs
// Otherwise, we can run into build errors because the compiler can think
// there are two component files with the same tag name
Array.from(compilerCtx.moduleMap.keys()).forEach((key) => {
if (filesUpdated.has(key) || filesDeleted.has(key)) {
// Check if the file exists in the fs
const fileExists = compilerCtx.fs.accessSync(key);
if (!fileExists) {
compilerCtx.moduleMap.delete(key);
}
}
});

// Make sure all added/updated files are watched
// We need to check both added/updates since the TS watch program behaves kinda weird
// and doesn't always handle file renames the same way
new Set([...filesUpdated, ...filesAdded]).forEach((filePath) => {
compilerCtx.addWatchFile(filePath);
});

dirsAdded.clear();
dirsDeleted.clear();
filesAdded.clear();
Expand Down