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

bug: watchIgnoredRegex is not respected during stencil build --watch #5709

Open
3 tasks done
rwaskiewicz opened this issue Apr 26, 2024 · 0 comments
Open
3 tasks done
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil

Comments

@rwaskiewicz
Copy link
Member

rwaskiewicz commented Apr 26, 2024

Prerequisites

Stencil Version

4.17.1

Current Behavior

Stencil has an undocumented config flag called watchIgnoredRegex (source). The JSDoc implies that we should be able to run the build task with --watch and "ignore" files that are matched by this regex. However, that doesn't seem to be the case in some of my testing.

When adding watchIgnoredRegex to my Stencil config (from a Component Starter):

diff --git a/stencil.config.ts b/stencil.config.ts
index 0137899..0994269 100644
--- a/stencil.config.ts
+++ b/stencil.config.ts
@@ -2,6 +2,7 @@ import { Config } from '@stencil/core';
 
 export const config: Config = {
   namespace: 'watch-ignore-test',
+  watchIgnoredRegex: [/.*\.stories\.ts$/],
   outputTargets: [
     {
       type: 'dist',

I would expect any files matching that regex to be ignored for something like /private/tmp/watch-ignore-test/src/components/my-component/my-component.stories.ts. The screenshot below is just a quick check on the regex itself, and shows the file name getting matched by the regex we use in the stencil config diff above:
Screenshot 2024-04-26 at 2 19 49 PM

However, if I create a file, src/components/my-component/my-component.stories.ts with any valid TypeScript in it, then start the build task with watchers enabled, changing that file results in a re-render

Expected Behavior

I would expect that file to be ignored, and a compilation to stop if that was the only file being changed/updated

System Info

$ npx stencil info

      System: node 20.10.0
    Platform: darwin (23.2.0)
   CPU Model: Apple M3 Max (14 cpus)
    Compiler: /private/tmp/watch-ignore-test/node_modules/@stencil/core/compiler/stencil.js
       Build: 1713902307
     Stencil: 4.17.1 🚒
  TypeScript: 5.4.5
      Rollup: 2.56.3
      Parse5: 7.1.2
      jQuery: 4.0.0-pre
      Terser: 5.30.3

Steps to Reproduce

  1. Create a new component starter with npm init stencil@latest component watch-test
  2. Enter that directory cd watch-test
  3. Install deps npm i
  4. Add the ignoreWatchedRegex to your Stencil config file (root level stencil.config.ts)
diff --git a/stencil.config.ts b/stencil.config.ts
index 0137899..0994269 100644
--- a/stencil.config.ts
+++ b/stencil.config.ts
@@ -2,6 +2,7 @@ import { Config } from '@stencil/core';
 
 export const config: Config = {
   namespace: 'watch-ignore-test',
+  watchIgnoredRegex: [/.*\.stories\.ts$/],
   outputTargets: [
     {
       type: 'dist',
  1. Create src/components/my-component/my-component.stories.ts with:
console.log('hello world')
  1. Run npm start, which runs the build task with --watch and --serve
  2. Change src/components/my-component/my-component.stories.ts in some way to be still valid TS. E.g.
- console.log('hello world')
+ console.log('hello world');
  1. See the recompilation occur

Code Reproduction URL

https://github.com/rwaskiewicz/stencil-5709-repro

Additional Information

I also tested this on v4.0.0, presumably it broke before then (although I didn't try every version between that and v4.17.1)

Discord thread that started this https://discord.com/channels/520266681499779082/1230541824750387271/1230541824750387271

@ionitron-bot ionitron-bot bot added the triage label Apr 26, 2024
@rwaskiewicz rwaskiewicz added Bug: Validated This PR or Issue is verified to be a bug within Stencil and removed triage labels Apr 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug: Validated This PR or Issue is verified to be a bug within Stencil
Projects
None yet
Development

No branches or pull requests

1 participant