Closed json2d closed 7 years ago
It depends on the package configuration - for example, with lodash
you can import individual modules as well - https://github.com/activewidgets/getlibs/blob/master/examples/lodash/es6/hello/hello.js#L2
getlibs is based on systemjs, so you can add your own configuration as well (see #2).
Do you have in mind any particular npm package?
So in my example, getlibs
is trying to import/require cwise-compiler
, but when it encounters a local module within that module's source...
var createThunk = require("./lib/thunk.js")
...systemjs
trys to resolve it as if it were a module from npm:
system.src.js:80 Uncaught (in promise) Error: Fetch error: 404
Instantiating https://unpkg.com/lib/thunk.js
Loading https://unpkg.com/cwise-compiler
As you've said though, this seems more of an issue for systemjs
You can try adding a mapping with a full path to systemjs config -
System.config({
map: {
'cwise-compiler': 'https://unpkg.com/cwise-compiler/compiler.js'
}
});
It should fix relative imports.
Thanks that works!
Seems like I can only import packages from npm that bundle the entire main module into a single file. Is there a plan on the roadmap to support importing unbundled packages with many loose files?