-
-
Notifications
You must be signed in to change notification settings - Fork 134
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
jspm support #198
Comments
Not at this time, no. Consider that jspm and system.js are two separate things. We will probably add support for system.js first and consider jspm at a later date. jspm is the most problematic of all build options due to its stability and issues within enterprises. If you want jspm now, the best way to go is use our skeletons or set up a custom solution. |
System.js +1 |
SystemJS supportI think the best way to start working on this is to first create a new aurelia-cli project (with requirejs) and modify that project to work with systemjs. You'll probably want to follow these instructions to be able to make changes to the CLI easily. As soon as the project is working with SystemJS, we can teach the project creation part of the CLI to create this exact setup. The CLI has both a bundler and a loader. For the bundling part we use amodro-trace which uses RequireJS internally to trace dependencies of an app. What is created by the bundler is a bundle that requirejs as well as systemjs should be able to load. So we don't need to modify the bundler part of the CLI, only the loader that is used. I would start by editing the aurelia.json file (require -> systemjs, empty plugins array as they are requirejs specific, remove text plugin dependency, remove this line). The way the current setup works is that the loader is in the vendor-bundle.js, which gets loaded through a script tag in index.html. So we need to make sure that the current bundler can bundle SystemJS, and if not what is preventing it from being bundled. The vendor-bundle is configured via aurelia.json to contain the loader configuration which can be found at the bottom of vendor-bundle.js: This config is requirejs specific, so the cli should create a similar systemjs config. This configuration is created here based on the type of loader. Here is the code that creates the RequireJS config, so that's what we need to do here but then for SystemJS cc @simonfox |
Cool thanks @JeroenVinke will take a look early next week!
… On 13/05/2017, at 08:35, Jeroen Vinke ***@***.***> wrote:
SystemJS support
I think the best way to start working on this is to first create a new aurelia-cli project (with requirejs) and modify that project to work with systemjs. You'll probably want to follow these instructions to be able to make changes to the CLI easily. As soon as the project is working with SystemJS, we can teach the project creation part of the CLI to create this exact setup.
The CLI has both a bundler and a loader. For the bundling part we use amodro-trace which uses RequireJS internally to trace dependencies of an app. What is created by the bundler is a bundle that requirejs as well as systemjs should be able to load. So we don't need to modify the bundler part of the CLI, only the loader that is used.
I would start by editing the aurelia.json file (require -> systemjs, empty plugins array as they are requirejs specific, remove text plugin dependency, remove this line).
The way the current setup works is that the loader is in the vendor-bundle.js, which gets loaded through a script tag in index.html. So we need to make sure that the current bundler can bundle SystemJS, and if not what is preventing it from being bundled. The vendor-bundle is configured via aurelia.json to contain the loader configuration which can be found at the bottom of vendor-bundle.js:
This config is requirejs specific, so the cli should create a similar systemjs config. This configuration is created here based on the type of loader. Here is the code that creates the RequireJS config, so that's what we need to do here but then for SystemJS
cc @simonfox
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
Right I've started to look at this @JeroenVinke and I've run into a couple of things and one problem I haven't been able to get to the bottom of...
Are you able to help at all? or @AStoker ? |
Great work @simonfox! I can look into this tomorrow |
Just taking a quick peek, I'm kinda loaded up at work right now. |
Ah sorry @AStoker ....in the latest commit that is not how it is configured (the mappings are at a consistent level)...I had been trying a bunch of variations of the mapping and published it inconsistent like that by mistake. Thanks for taking a look though, will keep this thread updated if I make any further progress. |
@JeroenVinke @AStoker to check the config, I installed Another option would be to modify CLI to use aurelia-bundler when the loader is SystemJS (if the translation from |
Do I need a modified version of the CLI to run https://github.com/simonfox/cli-systemjs-loader? Also, could you share the bundle you created with systemjs-builder? I'm curious to see what it tells the systemjs loader vs what we tell it |
Right I've found the issue....SystemJS needs the bundle define to contain full mapped path i.e. Do I need to look into amodro writeTransforms? |
@JeroenVinke OK ignore my last post....I feel dumb! If you replace the generated function _aureliaConfigureModuleLoader(){
window.define = SystemJS.amdDefine;
window.require = window.requirejs = SystemJS.amdRequire;
SystemJS.config({
"baseURL":"src"
});
} Because the require.js bundle uses normalized names for define there is no mapping required (at least for this simplist of cases)! The only issue I haven't solved now is how to load templates. |
Nice work @simonfox! I've been digging and think it's working now. The app-bundle should be loaded by SystemJS. So what I did was comment out the app-bundle script tag from index.html. Then I've used the following config in vendor-bundle:
Note that you need SystemJS's text loader: Could you confirm that this resolves the issue? If so, then you could proceed as follows (but feel free to take another path). First clone and link the CLI so that you can make changes to the CLI (see these instructions).
|
@JeroenVinke that works!...we can actually remove SystemJS.config({
map: {
"text": 'node_modules/systemjs-plugin-text/text.js',
"app-bundle": "scripts/app-bundle.js"
},
bundles: {
"app-bundle": ["app", "main", "environment", "resources/index"]
}
}); there is one other manual change I made in Do you know if I can easily change amodro output for plugin loaded modules? SystemJS has a |
@simonfox excellent! Could we maybe use https://github.com/aurelia/cli/blob/master/lib/build/loader-plugin.js#L39? |
@JeroenVinke perfect! I'll get onto the actual cli changes tomorrow. |
@JeroenVinke right I've got the guts of this done in https://github.com/simonfox/cli/tree/feature/systemjs-support I'll get onto the Let me know if you have any initial comments on what I have already done! |
@simonfox We really appreciate you working on this! Keep up the great work! |
@JeroenVinke I've made most of the Last thing is |
Echoing what the Eise' Man said, thanks so much for your help on this @simonfox! Really appreciate you working with him on this too @JeroenVinke. |
Nice work @simonfox. I wonder if the builder pattern may be a bit too much. While the SystemJS and RequireJS config are very similar, those two may be the only ones that could benefit from the builder pattern. What do you think? |
Yes, that sounds fine to me. I'm curious though, why can't systemjs be bundled? |
@JeroenVinke yes good point, I'm not familiar with Webpack but just had a quick look and the config is a bit different. The steps I've added are very granular leaving most of the template in place, maybe if the template had chunkier steps it might work. I will roll it back for now. Have just moved systemjs to the bundle and can confirm it does work (now we have the necessary config correct). Two other things to decide
Thoughts? |
@simonfox having a requirejs.index.html and systemjs.index.html should be fine. That would allow you to put |
Enables support for SystemJS as module loader including new project setup via `au new`. closes aurelia#198
Enables support for SystemJS as module loader including new project setup via au new. closes aurelia#198
Enables support for SystemJS as module loader including new project setup via au new. closes aurelia#198
Enables support for SystemJS as module loader including new project setup via au new. closes aurelia#198
Enables support for SystemJS as module loader including new project setup via au new. closes aurelia#198
Great job @simonfox and @JeroenVinke for getting this in!!! 👏 🎆 |
Is there any way to create a new project with the cli that uses jspm/systemjs as module loader?
The text was updated successfully, but these errors were encountered: