gulpjs / gulp-cli

Command Line Interface for gulp.
MIT License
400 stars 106 forks source link

Tests for extension lookups #215

Open phated opened 4 years ago

phated commented 4 years ago

While thinking about https://github.com/gulpjs/gulp-cli/pull/214#issuecomment-637921048

I realized I also needed to add the .mjs extension to the 1.x and 2.x release streams of interpret, but all the tests were passing for gulp-cli.

I think this is due to us using --gulpfile for all our tests. @sttk do you know a way to test for the extensions?

sttk commented 4 years ago

@phated Extension tests are executed in a Liftoff's test. That is test/lib/register_loader.js. The explanation of the test is as follows:

  1. Creates loader mock for each extension. It returns a loading message with a loaded file name and the loader name.
  2. Sets a loader:success event handler to a sample Liftoff app, and verifies the loading message in the event handler.
  3. Executes registerLoader with extensions option which has only a pair of target extension and the loader mock.
phated commented 4 years ago

@sttk with the completion of #214, a file with .mjs extension does not use the loaders as handled by liftoff because is uses import(gulpfilePath). That's why I think we need to include tests for loading by extension in this project.

sttk commented 4 years ago

@phated Sorry. I didn't look detail of #214, and I assumed that the dynamic import function was used like require with being associated with .mjs. But the merged way is better according to interpret#68, indeed.

phated commented 4 years ago

@sttk I'm thinking about our APIs for the next major version and maybe rechoir can become an abstraction over require/import() like was added in #214 - it might even be able to handle "loader extensions" that the node.js team is working on for import