gulp-cli icon indicating copy to clipboard operation
gulp-cli copied to clipboard

Tests for extension lookups

Open phated opened this issue 4 years ago • 4 comments

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?

phated avatar Jun 03 '20 03:06 phated

@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.

sttk avatar Jun 03 '20 13:06 sttk

@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.

phated avatar Jun 03 '20 22:06 phated

@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.

sttk avatar Jun 04 '20 12:06 sttk

@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

phated avatar Jun 10 '20 18:06 phated