Socket
Socket
Sign inDemoInstall

@istanbuljs/esm-loader-hook

Package Overview
Dependencies
84
Maintainers
4
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1 to 0.1.2

7

CHANGELOG.md

@@ -5,2 +5,9 @@ # Changelog

### [0.1.2](https://github.com/istanbuljs/esm-loader-hook/compare/v0.1.1...v0.1.2) (2020-05-31)
### Bug Fixes
* Prepare for ESM loader hooks moving to worker threads. ([#3](https://github.com/istanbuljs/esm-loader-hook/issues/3)) ([8105a8f](https://github.com/istanbuljs/esm-loader-hook/commit/8105a8f110321e5d2c76e01e59c36a13b7f14162))
### 0.1.1 (2020-05-20)

@@ -7,0 +14,0 @@

20

index.js

@@ -18,5 +18,5 @@ import {fileURLToPath} from 'url';

export async function transformSource(source, context) {
if (loader.isLoading()) {
return {source};
export async function transformSource(source, context, defaultTransformSource) {
if (context.format !== 'module' || loader.isLoading()) {
return defaultTransformSource(source, context, defaultTransformSource);
}

@@ -45,14 +45,12 @@

if (Buffer.isBuffer(source)) {
source = source.toString();
} else if (typeof source !== 'string') {
return {source};
}
const filename = fileURLToPath(context.url);
/* babel-plugin-istanbul does this but the early check optimizes */
if (!testExclude.shouldInstrument(filename)) {
return {source};
return defaultTransformSource(source, context, defaultTransformSource);
}
if (typeof source !== 'string') {
source = new TextDecoder().decode(source);
}
/* Can/should this handle inputSourceMap? */

@@ -76,3 +74,3 @@ const {code} = await babel.transformAsync(source, {

return {source: code};
return defaultTransformSource(code, context, defaultTransformSource);
}
{
"name": "@istanbuljs/esm-loader-hook",
"version": "0.1.1",
"version": "0.1.2",
"description": "Loader hook for ESM instrumentation (experimental!!)",

@@ -5,0 +5,0 @@ "type": "module",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc