These are chat archives for systemjs/systemjs

21st
Aug 2018
Juha Järvi
@jjrv
Aug 21 2018 20:00
How does StealJS relate to SystemJS these days?
I made a SystemJS resolve hook that does lots of things:
import Map from 'fbjs/lib/Map'
is going to look automatically for node_modules/fbjs/lib/Map.js and node_modules/fbjs/lib/Map/index.js and https://unpkg.com/fbjs@0.8.17/lib/Map.js and https://unpkg.com/fbjs@0.8.17/lib/Map/index.js
It's pretty much always going to find the import, because all of npm is on unpkg
Juha Järvi
@jjrv
Aug 21 2018 20:07
If I'm doing in TypeScript:
import { App } from './App'
then under src it's going to look for ./App.ts and ./App.tsx and transpiles the one it finds. Under dist it would instead look for ./App.js (I'm using vscode which transpiles on save with the right extension)
It doesn't just find the files, but generates SystemJS config so next time SystemJS native resolver will immediately find the file it ended up loading
Juha Järvi
@jjrv
Aug 21 2018 20:22
I can pretty much just write ES6 or even TSX and import whatever, without configuring or installing anything. I can code right on GitHub on the gh-pages branch and it just works. See for yourself: https://github.com/jjrv/loader-playground and https://jjrv.github.io/loader-playground/
The autogenerated config is printed in the browser's console.
Feed it to SystemJS, and my loader is no longer necessary because vanilla SystemJS can then load the project.
Juha Järvi
@jjrv
Aug 21 2018 20:33
I can also create a Web Worker with its entry point written in TypeScript, and all imports work just the same. It communicates with the UI thread over a message channel to keep the config up to date, in case something is imported in the worker that the main thread didn't know how to load yet.
I used to use a project called cbuild to autogenerate SystemJS config while running the builder, but hooking and autoconfiguring the loader straight in the browser is so much better. I don't even need any NodeJS -based toolchain any more, except to bundle the final product for production.