extensionless imports with jspm

31 views
Skip to first unread message

Andrew Smith

unread,
Aug 14, 2016, 12:03:30 PM8/14/16
to jspm
Hi.

I'm using jspm 0.17.0-beta.25

I'm probably doing something stupid but I'm having all sorts of fun importing packages which are a part of my source tree with jspm.

If I have an import like 

import * as Component from './component'

then the default behaviour appears to be to try to load './component' as a file rather than './component/index.js

I've fixed this (although I've no idea if it's the correct approach) by declaring each of my own packages in the packages section of the jspm.config.js as follows

"/component": {
    "main": "index.js"
}

This fixes the issue for a development build but as soon as I try to create a bundle using jspm bundle I'll get an error like

err  Error on fetch for dist/component at file:///path/to/my/project/dist/component
  Loading dist/index.js
  Error: EISDIR: illegal operation on a directory, read
    at Error (native)

Which looks to me like the bundler is ignoring my package definitions but I'm probably just solving my problem the wrong way

importing my modules as './component/index.js' isn't an option, primarily because I'm compiling from typescript externally to jspm/systemjs. Built in transpilers always seem to come with their own set of fun to debug problems so I would much much rather work that way.


TIA

Andrew Smith

 

Guy Bedford

unread,
Aug 14, 2016, 3:14:21 PM8/14/16
to Andrew Smith, jspm
When you reference the package name as /component that is an absolute URL. On the file system (and therefore in the build) that means an absolute path, which is why the config isn't applying. Try leaving out the '/'.
--
You received this message because you are subscribed to the Google Groups "jspm" group.
To unsubscribe from this group and stop receiving emails from it, send an email to jspm-io+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Andrew Smith

unread,
Aug 14, 2016, 3:40:17 PM8/14/16
to Guy Bedford, jspm
Hi Guy. 

Thanks for getting back to me. 

Unfortunately that doesn't help, although it also doesn't hurt the dev build either.

Does bundle expect the jspm config file to be in a specific place relative to either the working directory or the file it is bundling? Is there a way to change that? I've tried the --config option but that is expecting a json file not a js file. I'm wondering if it straight up isn't finding my config.

Andy


Guy Bedford

unread,
Aug 14, 2016, 3:53:00 PM8/14/16
to Andrew Smith, jspm
Make sure your baseURL in the builder when running new Builder(baseURLPath) is set to the path that contains the 'component' folder. The builder requires that to be a shared reference point.

Guy Bedford

unread,
Aug 14, 2016, 3:53:47 PM8/14/16
to Andrew Smith, jspm
Or sorry if using jspm then via 'jspm init' ensure that the baseURL path and URLs between browser and server match in structure.

Andrew Smith

unread,
Aug 14, 2016, 4:45:51 PM8/14/16
to Guy Bedford, jspm
Sorry, I don't think I'm following. Do you mean the package.json or the base url in the jspm.config.js?

Andrew Smith

unread,
Aug 14, 2016, 4:46:29 PM8/14/16
to Guy Bedford, jspm
Sorry, typo. I mean the baseUrl in the package.json or the baseUrl in the jspm.config.js?

Andrew Smith

unread,
Aug 14, 2016, 4:58:40 PM8/14/16
to Guy Bedford, jspm
Actually I think I'm starting to make some progress. 

Thanks, you've set me on the right path.

Andy
Reply all
Reply to author
Forward
0 new messages