This repository contains an application (jspm-empty-demo-app) and two packages
(jspm-empty-dependency and jspm-empty-other-dependency) that together demonstrate a bug in
jspm when setting a dependency to map to @empty.
jspm-empty-demo-app-- an application usingjspmto manage dependencies and build a bundled javascript file meant to be loaded by the browserjspm-empty-dependency-- annpmpackage that exports a function which displays a console.log. This package is depended on byjspm-empty-demo-app.jspm-empty-other-dependency-- an locally-defined package inside thejspm-dempty-demo-appwhich is declared as apeerDependencyinjspm-empty-dependency. The peer is imported and executed byjspm-empty-dependency. However, this package is not published tonpm. It instead exists completely insidejspm-empty-demo-appand usesjspmconfig's path mapping to correctly route the dependency and load the file
- Clone this repository
- Change directory to
jspm-empty-demo-appand runnpm install - Bundle the application by running
npm run bundle
jspm successfully bundles the application. It ignores the jspm-empty-other-dependency peer
dependency from jspm-empty-dependency and instead successfully uses the map set in the app's
config.js.
jspm fails to bundle the application with the following error:
> @joe-sh/[email protected] prepublish /.../jspm-empty-demo/jspm-empty-demo-app
> jspm bundle src/index.js ${npm_package_main}
Building the bundle tree for src/index.js...
err Error on fetch for @empty/index.js at file:///.../jspm-empty-demo/jspm-empty-demo-app/public/@empty/index.js
Loading npm:@joe-sh/[email protected]/index.js
Loading src/index.js
Error: ENOENT: no such file or directory, open '/.../jspm-empty-demo/jspm-empty-demo-app/public/@empty/index.js'
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @joe-sh/[email protected] prepublish: `jspm bundle src/index.js ${npm_package_main}`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @joe-sh/[email protected] prepublish script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /.../.npm/_logs/2018-02-23T20_10_41_989Z-debug.logAdditionally, if you open up jspm-empty-demo-app/public/jspm_packages/npm/@joe-sh/[email protected]/index.js
you'll notice that it's renamed import otherDependency from '@joe-sh/jspm-empty-other-dependency/index.js' to
import otherDependency from '@empty/index.js'
It seems there's a bug with the mapping of jspm-empty-other-dependency in the package.json of
jspm-empty-dependency. Instead of correctly mapping the dependency to the location in the
filesystem, it's actually renaming the @joe-sh/jspm-empty-other-dependency to @empty, which then
produces an ENOENT error since it cannot load @empty/index.js.