New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-esm-resolver

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-esm-resolver - npm Package Compare versions

Comparing version

to
2.3.2

83

lib/index.js

@@ -12,2 +12,3 @@ "use strict";

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const rSlashed = /[\\/]$/;
let moduleIsBuiltinCache = null;

@@ -216,9 +217,14 @@

function resolveExtension(base, extensions, expand = false) {
const stat = pathStat(base);
const paths = [''];
if (stat) {
if (stat.isDirectory()) {
paths.push('/index');
} else {
return '';
let paths;
if (rSlashed.test(base)) {
paths = ['index'];
} else {
paths = [''];
const stat = pathStat(base);
if (stat) {
if (stat.isDirectory()) {
paths.push('/index');
} else {
return '';
}
}

@@ -462,37 +468,34 @@ }

*/
// eslint-disable-next-line arrow-body-style, import/no-default-export
var _default = () => {
return {
visitor: {
/**
* Visitor callback for import declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ImportDeclaration(path, state) {
visitDeclaration(path, state);
},
/**
* Visitor callback for export all declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ExportAllDeclaration(path, state) {
visitDeclaration(path, state);
},
/**
* Visitor callback for export names declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ExportNamedDeclaration(path, state) {
visitDeclaration(path, state);
}
var _default = () => ({
visitor: {
/**
* Visitor callback for import declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ImportDeclaration(path, state) {
visitDeclaration(path, state);
},
/**
* Visitor callback for export all declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ExportAllDeclaration(path, state) {
visitDeclaration(path, state);
},
/**
* Visitor callback for export names declarations.
*
* @param {object} path AST node.
* @param {object} state AST state.
*/
ExportNamedDeclaration(path, state) {
visitDeclaration(path, state);
}
};
};
}
});
exports.default = _default;
//# sourceMappingURL=index.js.map
{
"name": "babel-plugin-esm-resolver",
"description": "A Babel plugin for resolving ESM import and export paths",
"version": "2.3.1",
"version": "2.3.2",
"keywords": [

@@ -26,5 +26,4 @@ "babel",

"test": "node ./lib/index.spec.js",
"all": "run-s clean build test lint formatted",
"watch": "nodemon --exec 'run-s all'",
"prepack": "run-s clean build"
"all": "npm run clean && npm run build && npm run test && npm run lint && npm run formatted",
"prepack": "npm run clean && npm run build"
},

@@ -44,4 +43,2 @@ "repository": "https://github.com/AlexanderOMara/babel-plugin-esm-resolver.git",

"eslint-plugin-jsdoc": "^46.4.6",
"nodemon": "^3.0.1",
"npm-run-all": "^4.1.5",
"prettier": "^3.0.1",

@@ -48,0 +45,0 @@ "rimraf": "^5.0.1"

@@ -15,3 +15,3 @@ # Babel Plugin: ESM Resolver

Resolves ESM import and export paths to other source modules with extensions, optionally replacing the extension with a different one (including imports with extensions, like native ESM and Deno-style TypeScript). This is useful because browsers cannot perform automatic file extension resolution, and other environments like Node may not have this enabled by default either.
Resolves ESM import and export paths to other source modules with extensions, optionally replacing the extension with a different one (including imports with extensions, like native ESM and Deno-style TypeScript). This is useful because most environments will not perform automatic file extension resolution.

@@ -22,3 +22,3 @@ Since it resolves the statements before the modules are transpiled, it can also be used to resolve the paths for other transpiled module loaders.

There are three classes of resolver that can be enabled (`source`, `module`, `submodule`) depending on the modules that need to be resloved. Module support for ESM has improved however so only `source` is likely to be needed.
There are three classes of resolver that can be enabled (`source`, `module`, `submodule`) depending on the modules that need to be resolved. Module support for ESM has improved so only `source` is likely to be needed.

@@ -29,5 +29,5 @@ # Usage

- [`source`](options/source.md) Source modules (`import foo from './bar'`).
- [`module`](options/module.md) Module main entry points (`import foo from 'bar'`).
- [`submodule`](options/submodule.md) Module submodules (`import foo from 'bar/foo'`).
- [`source`](options/source.md) Source modules: `import foo from './bar'`
- [`module`](options/module.md) Module main entry points: `import foo from 'bar'`
- [`submodule`](options/submodule.md) Module submodules: `import foo from 'bar/foo'`

@@ -34,0 +34,0 @@ NOTE: The `module` and `submodule` options are generally no longer needed now that conditional exports are available.

Sorry, the diff of this file is not supported yet