These are chat archives for systemjs/systemjs

22nd
Mar 2016
Matt McDaniel
@matt-mcdaniel
Mar 22 2016 00:33

Has anyone else received the following error when trying to use System.import() to async fetch a commonjs module when System.transpiler = false?

Unable to dynamically transpile ES module as SystemJS.transpiler set to false

Netanel Basal
@NetanelBasal
Mar 22 2016 07:36
This message was deleted
Guy Bedford
@guybedford
Mar 22 2016 15:19
@davismj paths configuration forms the namespacing - eg System.config({ paths: { jquery: './main.js' } }) will build main.js as jquery. If you want this for a folder, use wildcard paths.
@matt-mcdaniel try setting the format to cjs with metadata rather - System.config({ meta: 'path/to/folder/*.js': { format: 'cjs' } }) or with package config
Vojtech Polivka
@vojtapol
Mar 22 2016 18:08
@guybedford I am trying to use map in the SystemJS config, it works, but it does not append .js to the resulting path, thus the file can't be found on the server
System.config({
    defaultExtension: 'js',
    map: {
        '@owner': 'node_modules/@owner'
    },
    packages: {
        "build": {
            format: 'register'
        }
    }
});
And I am importing it using this syntax:import {MyClass} from '@owner/path/to/file/MyClass';
so the mapping works correctly except the file extension.
Vojtech Polivka
@vojtapol
Mar 22 2016 18:17
defaultJSExtensions: true works
Vojtech Polivka
@vojtapol
Mar 22 2016 18:23
but that breaks angular2 :D
Dominic Watson
@intellix
Mar 22 2016 18:24
I think you can do .js!
import {MyClass} from '@owner/path/to/file/MyClass.js!';
thought I saw on a talk that if you append ! then it checks the file extension
Vojtech Polivka
@vojtapol
Mar 22 2016 18:25
@intellix yeah, but that import statement is in TypeScript, and it can't have the .js :(
Dominic Watson
@intellix
Mar 22 2016 18:26
I guess you're not using the angular bundles then if adding defaultExtension kills it?
Manuel Pacheco
@ShadowManu
Mar 22 2016 18:26
@intellix @vojtapol but that changes your syntax in your TS files (which you should minimize as possible: source code shouldn't care about build code).
Vojtech Polivka
@vojtapol
Mar 22 2016 18:26
@intellix I am using the bundles, I dont understand why does the defaultExtension affect it
@ShadowManu yeah I would rather leave the sources as they are because they work
Manuel Pacheco
@ShadowManu
Mar 22 2016 18:28
I don't remember exactly how but I remember you can set extensions per package, let me see if I find an example of that
Vojtech Polivka
@vojtapol
Mar 22 2016 18:30
yeah I tried something like that.. didnt seem to work.. I would rather like to understand what is the difference between
defaultJSExtensions: true and defaultExtension: 'js'
is there a way to check what modules are registered during runtime? something like System.get('moduleName') ?
System.defined seems to have that info
Manuel Pacheco
@ShadowManu
Mar 22 2016 18:37
you could also bruteforce your way with the dev tools network panel ;)
Vojtech Polivka
@vojtapol
Mar 22 2016 18:38
@ShadowManu yeah SystemJS is really teaching me the powers of devtools lol
ok I shuffled the config around and now it works.. no idea why though.. the configuration API could be sure improved.. it is super confusing currently
Manuel Pacheco
@ShadowManu
Mar 22 2016 18:43
a fast look at their config API says that defaultJSExtensions is a top level config property and defaultExtension is a package-level config property. No hints for them being on other locations.