Hey!
I've been playing around with SystemJS; specifically, I've been trying to figure out if I can make SystemJS use the famous require resolution algorithm (https://nodejs.org/docs/v0.4.8/api/all.html#all_Together...) in both node and the browser.
Just to tell you where I'm coming from, I think the biggest barrier preventing me from adopting SystemJS is its implicit reliance on jspm; it's my understanding that you can't really use SystemJS with npm without a lot of hand-configuration (https://github.com/systemjs/systemjs/issues/767). Besides reasons of familiarity (I know all the npm gotchas, I know how to deploy systems built on npm), I'd like to avoid using jspm because I like that I can npm install something and see the essential change to the codebase (an update to package.json), whereas I find it much harder to keep track of all the changes in files updated by jspm.
I suspect there are reasons why it might be difficult to do the node resolve algorithm in the browser, but I've also had some success using competing tools like browserify and webpack to get node resolves working in frontend systems. I was looking into the loader extension spec and I hypothesized that I could create a loader/plugin which overrides the locate hook in node environments, and uses some combination of locate and fetch in the browser to reproduce the node resolution algorithm.
I've been trying to get it working on my own without asking anyone for help (https://github.com/brainkim/systemjs-npm) but there are so many unknowns, and I've run into a couple snags that may be my own fault. For instance, I can't seem to call the original SystemJS hooks in node inside my own plugin's hooks without blowing the stack/going into an async loop.
So I thought I should just ask 馃寶 if what I'm trying is even feasible. I'm guessing I can redo the node implementation and rely just on es6-module-loader, but it would be a shame not to leverage all the great code in SystemJS, especially all of your downstream apis like systemjs/builder.
Thanks!
Brian
+1 Looking at aiming to fix exactly this issue
If you only need your code to run in NodeJS and not the browser at all you can use import '@node/package-name in SystemJS.
If you need to install from npm or Node and have it behave identically, this is what jspm can provide.
Not supporting the NodeJS resolution any deeper than the above is a fundamental design decision in the project (perhaps THE fundamental design decision).
Yeah I'm getting that sense. I'd love to understand why!
Most helpful comment
Yeah I'm getting that sense. I'd love to understand why!