-
-
Notifications
You must be signed in to change notification settings - Fork 272
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
mapping workflow, first attempt #140
Conversation
Would that allow overriding any mapping including |
What type of custom mappings do you mean? Like the If it is the endpoint mappings, is this configuration project-specific? Currently endpoint mappings are global jspm configuration. |
I'm talking about both endpoint mappings ( To give a more concrete example, we have a Play app that has the following structure:
with {
"jspm": {
"directories": {
"jspmPackages": "public/jspm_packages"
},
"configFile": "public/config.js",
"dependencies": { ... }
} This results in the default System.config({
"paths": {
"*": "*.js",
"npm:*": "public/jspm_packages/npm/*.js",
"github:*": "public/jspm_packages/github/*.js"
}
}); However, our own modules are actually within <script src="@routes.Assets.at("config.js")"></script>
<script>
System.config({
baseURL: "/assets",
paths: {
"*": "js/*.js",
"npm:*": "jspm_packages/npm/*.js",
"github:*": "jspm_packages/github/*.js"
}
});
System.import("app");
</script> So it feels there are at least three things happening here:
Have we missed some clever tricks to make this configuration possible within the jspm setup (which would make bundling easier etc)? It'd be great if jspm didn't have to enforce any particular directory structure and it could be configured to match whatever people used. Thanks! |
For setting the server base path, perhaps we need a new directories entry for this so that all paths in the config file are relative to this. How about |
I found the doc for Running If I understand you correctly, the "server base path" would be the |
Ahh, there might have been some changes in this - Then what I mean by {
"jspm": {
"directories": {
"jspmPackages": "public/jspm_packages",
"public": "public",
"lib": "public/js"
},
"configFile": "public/config.js",
"dependencies": { ... }
} Then the config.js paths should look like: System.config({
paths: {
'*': 'js/*.js',
'npm:*': 'jspm_packages/npm/*.js', ...
}
}); Let me know if that sounds sensible? |
Maybe the paths should even have a leading |
I think the requirements are to have a path that is referred to on the filesystem by JSPM and one that is referred to on the web by SystemJS.
Which then gives you:
This would also require JSPM to not look at the baseURL when bundling but use In short How's that sound? |
Note that the |
The So in theory we could remove the need for
which let SystemJS resolve paths to So @jamesgorrie's solution relies on there being a different base path for jspm ( Unless we're still missing something? |
I wonder if the known working use case for jspm and SystemJS so far is one where both base paths (local and remote) were coincidentally identical? |
Right ok I get you, that makes sense. So the |
It's not really the difference between development and production, but more between the local paths and the paths served by the web server. To reuse the same example, the following local directory structure on the filesystem:
results in all the files in public being served under a
jspm works at the level of the local filesystem to install, bundle, etc so as far as it's concerned, the stuff is in SystemJS works at the level of files served on the web, so the stuff is in In terms of providing the Does that make sense? |
Ok I see. Thanks for explaining. So var System = require('systemjs').System;
require('config');
System.import('x'); And expect that to work, which would be good to maintain. Perhaps if you set |
Alright, fair enough on also allowing SystemJS to resolve paths locally. Setting So maybe let me try to recap what we've arrived to. First we add {
"jspm": {
"directories": {
"jspmPackages": "public/jspm_packages",
"public": "public",
"lib": "public/js"
},
"configFile": "public/config.js",
"dependencies": { ... }
} jspm would then produce the following System.config({
baseURL: 'public' // <- directories.public
paths: {
'*': 'js/*.js', // <- directories.lib relative to directories.public (see question below)
'npm:*': 'jspm_packages/npm/*.js', ... // <- directories.jspmPackages relative to directories.public
}
}); which should give the correct local paths to jspm (bundle, etc) and SystemJS when used locally, e.g.
In order to get SystemJS to use the correct paths on the web though, we'd need to override the
We don't need to override the A few questions:
I think we're getting close! |
I wouldn't actually set the I like keeping the I'm open to names other than |
Posted a new issue to track at #151, would be better to keep discussion going there, and discussion here for custom map workflows. |
I guess that's fine too!
|
This has been included in the latest beta ( |
This is a rough draft of a mapping workflow.
The idea is that when I am writing a package, say
thispackage
, I may want to have custom maps set up within that package that will transfer when it is published.The way we can handle this is with the
package.json
map property, which is supported by jspm:This PR propogates the above map configuration into the configuration file, supporting syncing between the package.json and config file values.