Skip to content

'use strict' breaks importing #75

@techniq

Description

@techniq

I'm just getting into ES6 modules, but I ran into an issue that surprised me. If I import a module using strict mode ('use strict';), the entire application fails.

index.js

var System = require('systemjs');

System.import('main').then(function(m) {
    console.log('loaded');
})

main.js

console.log('before import');

import { name } from './lib';
console.log('name: ' + name);

lib.js

'use strict'; // <-- Breaks app
export var name = 'Foo';

Running node index.js will silently finish without logging anything to stdout, but if I remove 'use strict'; from lib.js, I'll get the expected output:

before import
name: Foo
loaded

Something else surprising is even if 'use strict;` is commented, the app still fails silently.

lib.js

// 'use strict';
export var name = 'Foo';

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions