Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ava/typescript

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ava/typescript - npm Package Compare versions

Comparing version 2.0.0 to 3.0.0

LICENSE

66

index.js

@@ -1,7 +0,8 @@

'use strict';
const path = require('path');
const escapeStringRegexp = require('escape-string-regexp');
const execa = require('execa');
const pkg = require('./package.json');
import fs from 'node:fs';
import path from 'node:path';
import {pathToFileURL} from 'node:url';
import escapeStringRegexp from 'escape-string-regexp';
import execa from 'execa';
const pkg = fs.readFileSync(new URL('package.json', import.meta.url));
const help = `See https://github.com/avajs/typescript/blob/v${pkg.version}/README.md`;

@@ -47,3 +48,3 @@

return compile === false || compile === 'tsc';
}
},
},

@@ -57,6 +58,4 @@ rewritePaths: {

return Object.entries(rewritePaths).every(([from, to]) => {
return from.endsWith('/') && typeof to === 'string' && to.endsWith('/');
});
}
return Object.entries(rewritePaths).every(([from, to]) => from.endsWith('/') && typeof to === 'string' && to.endsWith('/'));
},
},

@@ -66,11 +65,11 @@ extensions: {

isValid(extensions) {
return Array.isArray(extensions) &&
extensions.length > 0 &&
extensions.every(ext => typeof ext === 'string' && ext !== '') &&
new Set(extensions).size === extensions.length;
}
}
return Array.isArray(extensions)
&& extensions.length > 0
&& extensions.every(ext => typeof ext === 'string' && ext !== '')
&& new Set(extensions).size === extensions.length;
},
},
};
module.exports = ({negotiateProtocol}) => {
export default function typescriptProvider({negotiateProtocol}) {
const protocol = negotiateProtocol(['ava-3.2'], {version: pkg.version});

@@ -92,3 +91,3 @@ if (protocol === null) {

rewritePaths: relativeRewritePaths,
compile
compile,
} = config;

@@ -98,3 +97,3 @@

path.join(protocol.projectDir, from),
path.join(protocol.projectDir, to)
path.join(protocol.projectDir, to),
]);

@@ -110,4 +109,4 @@ const testFileExtension = new RegExp(`\\.(${extensions.map(ext => escapeStringRegexp(ext)).join('|')})$`);

return {
extensions: extensions.slice(),
rewritePaths: rewritePaths.slice()
extensions: [...extensions],
rewritePaths: [...rewritePaths],
};

@@ -117,3 +116,3 @@ },

get extensions() {
return extensions.slice();
return [...extensions];
},

@@ -149,10 +148,10 @@

'!**/*.d.ts',
...Object.values(relativeRewritePaths).map(to => `!${to}**`)
...Object.values(relativeRewritePaths).map(to => `!${to}**`),
],
ignoredByWatcherPatterns: [
...ignoredByWatcherPatterns,
...Object.values(relativeRewritePaths).map(to => `${to}**/*.js.map`)
]
...Object.values(relativeRewritePaths).map(to => `${to}**/*.js.map`),
],
};
}
},
};

@@ -162,2 +161,3 @@ },

worker({extensionsToLoadAsModules, state: {extensions, rewritePaths}}) {
const useImport = extensionsToLoadAsModules.includes('js');
const testFileExtension = new RegExp(`\\.(${extensions.map(ext => escapeStringRegexp(ext)).join('|')})$`);

@@ -171,16 +171,10 @@

async load(ref, {requireFn}) {
for (const extension of extensionsToLoadAsModules) {
if (ref.endsWith(`.${extension}`)) {
throw new Error('@ava/typescript cannot yet load ESM files');
}
}
const [from, to] = rewritePaths.find(([from]) => ref.startsWith(from));
// TODO: Support JSX preserve mode — https://www.typescriptlang.org/docs/handbook/jsx.html
const rewritten = `${to}${ref.slice(from.length)}`.replace(testFileExtension, '.js');
return requireFn(rewritten);
}
return useImport ? import(pathToFileURL(rewritten)) : requireFn(rewritten); // eslint-disable-line node/no-unsupported-features/es-syntax
},
};
}
},
};
};
}
{
"name": "@ava/typescript",
"version": "2.0.0",
"version": "3.0.0",
"description": "TypeScript provider for AVA",
"engines": {
"node": ">=12.22 <13 || >=14.16 <15 || >=15"
"node": ">=12.22 <13 || >=14.17 <15 || >=16.4 <17 || >=17"
},

@@ -11,2 +11,6 @@ "files": [

],
"exports": {
".": "./index.js"
},
"type": "module",
"author": "Mark Wubben (https://novemberborn.net)",

@@ -23,11 +27,11 @@ "repository": "avajs/typescript",

"dependencies": {
"escape-string-regexp": "^4.0.0",
"execa": "^5.0.0"
"escape-string-regexp": "^5.0.0",
"execa": "^5.1.1"
},
"devDependencies": {
"ava": "^3.15.0",
"c8": "^7.7.1",
"ava": "4.0.0-rc.1",
"c8": "^7.10.0",
"del": "^6.0.0",
"typescript": "^4.2.4",
"xo": "^0.38.2"
"typescript": "^4.4.4",
"xo": "^0.46.3"
},

@@ -45,2 +49,6 @@ "c8": {

],
"ignoredByWatcher": [
"test/fixtures/**",
"test/broken-fixtures/**"
],
"timeout": "60s"

@@ -51,7 +59,4 @@ },

"test/broken-fixtures"
],
"rules": {
"import/order": "off"
}
]
}
}

@@ -42,2 +42,6 @@ # @ava/typescript

## ES Modules
When used with AVA 4, if your `package.json` has configured `"type": "module"`, or you've configured AVA to treat the `js` extension as `module`, then `@ava/typescript` will import the output file as an ES module. Note that this is based on the *output file*, not the `ts` extension.
## Add additional extensions

@@ -44,0 +48,0 @@

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc