Skip to content

Lazy load chokidar dependency #863

@eklingen

Description

@eklingen

Is it possible to make dart-sass load chokidar only when actually watching files?

In trying to optimise my build chain, I've noticed dart-sass loads the chokidar dependency, even when the watch functionality isn't actually used. While the absolute timings are small (though depending on cpu, I/O, etc), chokidar is relatively heavy, since it accounts for ~75% of the time it takes to load dart-sass. At least, in my tests.

   55 ms        │   ├─ node_modules/sass/sass.dart.js (2x)
   43 ms        │   │   └─ node_modules/chokidar/index.js (10x)
    4 ms        │   │       ├─ node_modules/readdirp/index.js (2x)
    4 ms        │   │       │   └─ node_modules/picomatch/index.js
   18 ms        │   │       ├─ node_modules/chokidar/node_modules/braces/index.js (4x)
    4 ms        │   │       │   └─ node_modules/chokidar/node_modules/braces/lib/compile.js (2x)
    9 ms        │   │       └─ node_modules/chokidar/lib/fsevents-handler.js (2x)
    8 ms        │   │           └─ node_modules/fsevents/fsevents.js

I'm not that well versed in Dart. But i'm willing to take a crack at it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions