ES6 Module Transpiler NPM Resolver

raw JSON →
0.3.0 verified Fri May 01 auth: no javascript deprecated

A resolver extension for es6-module-transpiler (v0.10+) that enables importing ES6 modules from npm packages using the jsnext:main flag. This package bridges npm resolution with ES6 module transpilation, allowing developers to import modules by package name (e.g., 'import foo from "foo"') instead of brittle relative paths into node_modules. Active development ceased; the last release v0.3.0 dates from 2016 and the ecosystem has moved to native ES modules or newer transpilers (Babel, TypeScript). Key differentiator: it was the first solution to integrate npm package resolution into the es6-module-transpiler pipeline via a custom resolver class, relying on the jsnext:main convention popularized by libraries like Rollup. Requires es6-module-transpiler as a peer dependency.

error Error: Cannot find module 'es6-module-transpiler'
cause Missing peer dependency es6-module-transpiler.
fix
npm install es6-module-transpiler@^0.10.0
error TypeError: NPMFileResolver is not a constructor
cause Using wrong import style; e.g., require() without .default or wrong destructuring.
fix
Use const NPMFileResolver = require('es6-module-transpiler-npm-resolver');
error Error: Module 'foo' not found
cause The npm package 'foo' does not have a 'jsnext:main' field in its package.json.
fix
Add 'jsnext:main': 'path/to/es6-module.js' to the package's package.json, or ensure the resolver's search paths are correct.
deprecated Package is no longer maintained; no updates since 2016.
fix Migrate to modern module bundlers like Rollup or Webpack which support jsnext:main natively.
gotcha The resolver only works with packages that have a jsnext:main field in package.json; otherwise it throws a lookup error.
fix Ensure the npm package you are importing has 'jsnext:main' defined. If not, use a different resolver or bundle the module manually.
gotcha This resolver does NOT provide interoperability between ES6 modules and CommonJS modules. It only resolves ES6 source files within npm packages.
fix Do not expect to import CommonJS modules using this resolver; use a different toolchain (e.g., Babel) for transpilation.
breaking v0.3.0 requires es6-module-transpiler >=0.10.0. Using an older version of the transpiler will cause resolution failures.
fix Update es6-module-transpiler to ^0.10.0.
npm install es6-module-transpiler-npm-resolver
yarn add es6-module-transpiler-npm-resolver
pnpm add es6-module-transpiler-npm-resolver

Shows how to create a transpiler Container with both file resolver and NPM resolver, then compile a module and write output.

const transpiler = require('es6-module-transpiler');
const Container = transpiler.Container;
const FileResolver = transpiler.FileResolver;
const NPMFileResolver = require('es6-module-transpiler-npm-resolver');
const formatters = require('es6-module-transpiler/lib/formatters');
const Formatter = formatters[formatters.DEFAULT];

const container = new Container({
  resolvers: [
    new FileResolver(['lib/']),
    new NPMFileResolver([process.cwd()])
  ],
  formatter: new Formatter()
});

container.getModule('index');
container.write('out/mylib.js');
console.log('Build complete.');