These are chat archives for systemjs/systemjs

25th
Nov 2015
Michael Prescott
@michaelprescott
Nov 25 2015 07:12
I have a minimal project setup using SystemJS with a "System.config({...})" > config.js. I'd like to use systemjs-builder to create bundles. Does it make sense to re-use the config.js or create a separate and similar config object for systemjs-builder?
Andrey Gubanov
@finom
Nov 25 2015 13:51
Guys, how can I use System with Babel 6 in browser?
Robert Herhold
@RobertHerhold
Nov 25 2015 13:57
Would anybody be able to answer this StackOverflow question?: http://stackoverflow.com/questions/33909001/import-handlebars-template-with-system-js
Andrey Gubanov
@finom
Nov 25 2015 13:59
Just little instruction please. I'm confused because this thing throws error:
<script src="//cdnjs.cloudflare.com/ajax/libs/babel-core/6.1.19/browser.js"></script>
Michael Prescott
@michaelprescott
Nov 25 2015 14:56
@finom The CDN version is 6.1.19 and the current npm installed version is 6.2.1. The npm version does not throw the same error, and instead throws one error when attempting to use browser.js by itself. Something to the effect of "could not find require" I believe that if use the latest version and load System.js first and then browser.js, browser.js should be able to find definition for 'require'
Michael Prescott
@michaelprescott
Nov 25 2015 15:10
<head>
  <meta charset="utf-8">
  <title>PAGE TITLE</title>
  <link rel="icon" href="data:;base64,iVBORw0KGgo=">
  <script src="node_modules/systemjs/dist/system.js"></script>
  <script>
    System.config({
      transpiler: "babel",
      babelOptions: {
        optional: [
          "runtime"
        ]
      },
      map: {
        'babel': 'babel-core/lib/api/browser.js'
      }
    });
  </script>

</head>
@finom I didn't test that further, but it no longer throws errors.
Michael Prescott
@michaelprescott
Nov 25 2015 16:13
I'm creating a bundle with systemjs-builder, and it appears that es2015 classes are transpiled to es5. The result is wrapped in the System.register; however, when running systemjs is attempting to load traceur-runtime. I must be misunderstanding something. If the source has been transpiled to ES5, why is the runtime needed?
Andrey Gubanov
@finom
Nov 25 2015 16:49
@michaelprescott thanks I'll try
Michael Prescott
@michaelprescott
Nov 25 2015 19:01
I'm thoroughly confused now. I'm using systemjs-builder to create ES5 bundles. Looking at the results, it seems fairly clear that they are ES5, wrapped in a call to System.register(); however, what I don't understand is why a runtime is still apparently needed if I'm including systemjs itself. Obviously i've got a gap in my understanding. Doesn't the runtime perform transpiling in the browser? Why is it needed if the bundles are already transpiled?
Peter Müller
@Munter
Nov 25 2015 19:14
Systemjs doors a whole lot more than transpiling. Transpiling is just a little sprinkle on top. It's a dynamic module loader and the module loading is still needed even with bundles, though they are already pre-cached in that case
Michael Prescott
@michaelprescott
Nov 25 2015 21:34
@Munter That's about how I understood it. I just thought the systems-builder was used to transpile to ES5 before production, and I could get by with just using SystemJS in production to load the previously transpiled bundles. With my current setup (likely misconfigured), I cannot get SystemJS to load the transpiled filed. Instead it's trying to use the traceur runtime even though it seems like it should not.
Peter Müller
@Munter
Nov 25 2015 21:36
ok, that part sounds a bit wierd. Maybe you have a misconfiguration somewhere
Jack Ma
@jack4it
Nov 25 2015 21:37
@Munter You probably missed the "bundle" config
Michael Prescott
@michaelprescott
Nov 25 2015 21:38
builder.bundle('one', {
      transpiler: 'babel',
      babelOptions: {
        "optional": [
          "runtime"
        ]
      },
      map: {
        'one': './src/es2015/one.js'
      }
    })
Jack Ma
@jack4it
Nov 25 2015 21:39
one is the bundle?
Michael Prescott
@michaelprescott
Nov 25 2015 21:40
yes
trying to distill it down to minimum
Jack Ma
@jack4it
Nov 25 2015 21:41
try this
    System.config({
        bundles: {
            "app/app-bundle.js": ['app/app.ts']
        }
    });
in the above config,
app.ts is the entry point for both dev time browser loading and build time systemjs-builder bundle
app-bundle.js is the bundle output
with this config, systemjs will be teached to load the bundle instead, when you System.import("app/app.ts")
sorry, in the message @ 13:37, i really meant @michaelprescott :smile:
Scott Smith
@scottadamsmith
Nov 25 2015 21:50
@jack4it You should never be sorry for a message sent @13:37
Michael Prescott
@michaelprescott
Nov 25 2015 22:07
@jack4it thanks, adding the bundles got it running. I'm pretty sure that I've still got some things misconfigured. The transpiled files include 'src/', like System.registerDynamic("src/es5/one.js" I imagine that can be removed with a proper config and maybe baseURL change.
@jack4it
```
<body>
  <script src="system.js"></script>
  <script>
    System.config({
      defaultJSExtensions: true,
      baseURL: '/',
      bundles: {
        'one': ['src/es5/one.js']
      }
    });
    System.import('src/es5/one');
  </script>
</body>
This is what finally worked for me
Jack Ma
@jack4it
Nov 25 2015 22:11
does it matter? i mean the paths in the "system" module
Michael Prescott
@michaelprescott
Nov 25 2015 22:18
@jack4it No, not really. If I understand it well, these are just module names. 'src/es5' could be 'xyz' throughout and it would still work.
Jack Ma
@jack4it
Nov 25 2015 22:19
i agree with you with my limitted systemjs knowledge :)
Michael Prescott
@michaelprescott
Nov 25 2015 22:20
That last part in the snippet above is not understood. It seems strange to me that I have to import 'src/es5/one' when bundles seems to say "here is the name, 'one'" Maybe that could be changed if I used a "map: { 'one': 'src/es5/one' }
Just trying to understand it all in this prototype so I'll know what is happening in a larger app.
Jack Ma
@jack4it
Nov 25 2015 22:22
i suppose you are right about the map config, give it a quick try and let us know
Michael Prescott
@michaelprescott
Nov 25 2015 22:29
@jack4it no, I was wrong about map usage. Oh well.
Tolis Christomanos
@chchrist
Nov 25 2015 22:31
Hello, is anyone using handlebars with templateCache?
Tolis Christomanos
@chchrist
Nov 25 2015 22:38
or there is not need when I precompile my handlebars templates?
Tolis Christomanos
@chchrist
Nov 25 2015 22:58
oops wrong channel