@istanbuljs/esm-loader-hook
Advanced tools
Comparing version 0.1.2 to 0.2.0
@@ -5,2 +5,13 @@ # Changelog | ||
## [0.2.0](https://github.com/istanbuljs/esm-loader-hook/compare/v0.1.2...v0.2.0) (2022-07-15) | ||
### ⚠ BREAKING CHANGES | ||
* Node.js 16.12.0 is required | ||
### Bug Fixes | ||
* Work with Node.js >=16.12.0 ([4ea4529](https://github.com/istanbuljs/esm-loader-hook/commit/4ea45295141690af27e0497afc1495b710453ed0)), closes [#6](https://github.com/istanbuljs/esm-loader-hook/issues/6) | ||
### [0.1.2](https://github.com/istanbuljs/esm-loader-hook/compare/v0.1.1...v0.1.2) (2020-05-31) | ||
@@ -7,0 +18,0 @@ |
17
index.js
@@ -18,5 +18,5 @@ import {fileURLToPath} from 'url'; | ||
export async function transformSource(source, context, defaultTransformSource) { | ||
export async function load(url, context, nextLoad) { | ||
if (context.format !== 'module' || loader.isLoading()) { | ||
return defaultTransformSource(source, context, defaultTransformSource); | ||
return nextLoad(url, context); | ||
} | ||
@@ -45,8 +45,10 @@ | ||
const filename = fileURLToPath(context.url); | ||
const filename = fileURLToPath(url); | ||
/* babel-plugin-istanbul does this but the early check optimizes */ | ||
if (!testExclude.shouldInstrument(filename)) { | ||
return defaultTransformSource(source, context, defaultTransformSource); | ||
return nextLoad(url, context); | ||
} | ||
const fromNext = await nextLoad(url, context); | ||
let {source} = fromNext; | ||
if (typeof source !== 'string') { | ||
@@ -61,3 +63,3 @@ source = new TextDecoder().decode(source); | ||
filename, | ||
/* Revisit this if transformSource adds support for returning sourceMap object */ | ||
/* Revisit this if the load hook adds support for returning sourceMap object */ | ||
sourceMaps: babelConfig.produceSourceMap ? 'inline' : false, | ||
@@ -75,3 +77,6 @@ compact: babelConfig.compact, | ||
return defaultTransformSource(code, context, defaultTransformSource); | ||
return { | ||
format: fromNext.format, | ||
source: code | ||
}; | ||
} |
{ | ||
"name": "@istanbuljs/esm-loader-hook", | ||
"version": "0.1.2", | ||
"version": "0.2.0", | ||
"description": "Loader hook for ESM instrumentation (experimental!!)", | ||
@@ -17,3 +17,3 @@ "type": "module", | ||
"engines": { | ||
"node": ">=13.7.0" | ||
"node": ">=16.12.0" | ||
}, | ||
@@ -32,3 +32,3 @@ "license": "ISC", | ||
"@istanbuljs/load-nyc-config": "^1.1.0", | ||
"@istanbuljs/schema": "^0.1.2", | ||
"@istanbuljs/schema": "^0.1.3", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
@@ -38,9 +38,9 @@ "test-exclude": "^6.0.0" | ||
"devDependencies": { | ||
"@cfware/lint": "^1.4.0", | ||
"c8": "^7.1.0", | ||
"cross-env": "^7.0.2", | ||
"libtap": "^0.3.0", | ||
"standard-version": "^7.1.0", | ||
"@cfware/lint": "^2.0.6", | ||
"c8": "^7.11.3", | ||
"cross-env": "^7.0.3", | ||
"libtap": "^1.4.0", | ||
"standard-version": "^9.5.0", | ||
"tap-yaml-summary": "^0.1.0" | ||
} | ||
} |
7169
69
+ Addedbrowserslist@4.23.0(transitive)
+ Addedcaniuse-lite@1.0.30001629(transitive)
+ Addedelectron-to-chromium@1.4.790(transitive)
- Removedbrowserslist@4.23.1(transitive)
- Removedcaniuse-lite@1.0.30001632(transitive)
- Removedelectron-to-chromium@1.4.798(transitive)
Updated@istanbuljs/schema@^0.1.3