Skip to content

Commit

Permalink
fix(compiler): handle file rename in watch mode (#5971)
Browse files Browse the repository at this point in the history
* fix(compiler): handle file rename in watch mode

Fixes: #3443

STENCIL-1104

* fix(ci): update pipeline name

* parity w/ other test workflows

---------

Co-authored-by: Christian Bromann <[email protected]>
  • Loading branch information
tanner-reits and christian-bromann authored Sep 6, 2024
1 parent 8ad326c commit 8f0a882
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
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

0 comments on commit 8f0a882

Please sign in to comment.