Skip to content

Commit

Permalink
remove custom handling for various node v12 versions of experimental …
Browse files Browse the repository at this point in the history
…loaders
  • Loading branch information
bjornstar committed Dec 30, 2022
1 parent 93cfca0 commit bd73bbc
Show file tree
Hide file tree
Showing 5 changed files with 4 additions and 32 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jobs:
script: npm run lint
language: node_js
node_js:
- 18
- 16
- 14
- 12
sudo: false
16 changes: 2 additions & 14 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,23 +96,11 @@ module.exports = function (

args.push(`--require=${resolveMain(localPath('wrap'))}`);

if (semver.satisfies(process.version, '<12.17.0')) {
args.push('--experimental-modules');
}

const loaderName = semver.satisfies(process.version, '>=16.12.0')
? 'load'
: semver.satisfies(process.version, '>=12.11.1')
? 'get-format'
: 'resolve';
const loaderName = semver.satisfies(process.version, '>=16.12.0') ? 'load' : 'get-format';

const loaderURL = pathToFileURL(resolveMain(localPath(join('loaders', `${loaderName}.mjs`))));

const experimentalPrefix = semver.satisfies(process.version, '>=12.11.1')
? 'experimental-'
: '';

args.push(`--${experimentalPrefix}loader=${loaderURL.href}`);
args.push(`--experimental-loader=${loaderURL.href}`);

child = fork(script, scriptArgs, {
cwd: process.cwd(),
Expand Down
12 changes: 0 additions & 12 deletions lib/loaders/resolve.mjs

This file was deleted.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
},
"main": "./lib",
"engines": {
"node": ">=12"
"node": ">=14"
},
"scripts": {
"lint": "eslint lib test bin/node-dev",
Expand Down
4 changes: 0 additions & 4 deletions test/spawn/esmodule.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
const semver = require('semver');
const tap = require('tap');

const { spawn, touchFile } = require('../utils');

tap.test('Supports ECMAScript modules with experimental-specifier-resolution', t => {
if (semver.satisfies(process.version, '<12.17'))
return t.skip('experimental-specifier-resolution requires node >= 12.17');

spawn('--experimental-specifier-resolution=node resolution.mjs', out => {
if (out.match(/touch message.js/)) {
touchFile('message.js');
Expand Down

0 comments on commit bd73bbc

Please sign in to comment.