Skip to content
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

Systemjs builder output not working as expected #205

Open
leepowelldev opened this issue Apr 27, 2017 · 2 comments
Open

Systemjs builder output not working as expected #205

leepowelldev opened this issue Apr 27, 2017 · 2 comments

Comments

@leepowelldev
Copy link

When using the plugin along with systemjs-builder and bundling into a single file, I'm getting some odd output when mixing in a regular .js file.

I've created a simple, file with the following:

vendor/test.js

const foo = 'bar'
export default foo

app/index.ts

import foo from 'vendor/test'
console.log(foo) // undefined in bundle, works fine when compiled in browser

When looking at the created bundle I'm getting the following output for the .js module:

System.register("vendor/test.js", [], function (_export, _context) {
    "use strict";

    return {
        setters: [],
        execute: function () {
            System.register([], function (exports_1, context_1) {
                "use strict";

                var __moduleName = context_1 && context_1.id;
                var foo;
                return {
                    setters: [],
                    execute: function () {
                        foo = 'bar';
                        exports_1("default", foo);
                    }
                };
            });
        }
    };

});

The nested System.register call seems odd to me ... when I manually amend to this it works:

System.register("vendor/test.js", [], function (exports_1, context_1) {
    "use strict";

     var __moduleName = context_1 && context_1.id;
     var foo;
     return {
         setters: [],
         execute: function () {
             foo = 'bar';
             exports_1("default", foo);
         }
     };
 });

This is my System.config file:

System.config({
  baseURL: '/',

  transpiler: 'plugin-typescript',

  typescriptOptions: {
    'module': 'System',
    'target': 'ES5',
    'noImplicitAny': true
  },

  paths: {
    'npm:': './node_modules/'
  },

  map: {
    'plugin-typescript': 'npm:plugin-typescript',
    'typescript': 'npm:typescript'
  },

  packages: {
    'plugin-typescript': {
      'main': 'lib/plugin.js'
    },
    'typescript': {
      'main': 'lib/typescript.js',
      'meta': {
        'lib/typescript.js': {
          'exports': 'ts'
        }
      }
    },
    'app': {
      'defaultExtension': 'ts',
      'main': 'index.ts'
    },
    'vendor': {
      'defaultExtension': 'js'
    }
  }
})
@aluanhaddad
Copy link
Contributor

Try with

    'app': {
      'format': 'esm',
      'defaultExtension': 'ts',
      'main': 'index.ts'
    },

@jooleeunc
Copy link

I get the same behavior when using the text plugin.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants