路径通配符不适用于 system.js

Path wildcards not working with system.js

根据system.js documentation, it should be possible to configure paths for system.js with wildcards. However, I have been unable to get this to work. I have a specRunner with jasmine unit tests, and I followed the angular2 testing tutorial 插入脚本部分,以便规格显示。然而,当我想导入 *.spec.js 时,这需要我手动导入 each 和 every spec测试。这是我的 SpecRunner.html 显示哪些代码有效,哪些无效。

<script>
    // Configure systemjs to use the .js extension for imports from the src/js folder
    System.config({
        packages: {
            'src/js': {defaultExtension: 'js'}
        }
    });

    // Import spec files: Does NOT work
    System.paths['specs'] = 'src/js/*.spec';
    Promise.all([
        System.import('specs')
    ])

    // Import spec files: Does work
    System.paths['specs'] = 'src/js/greeter.spec';
    Promise.all([
        System.import('specs'),
    ])

    // Import spec files: Does work
    Promise.all([
        System.import('src/js/greeter.spec')
    ])
</script>

谁能告诉我是否可以使用 通配符 为 system.js 配置路径?

路径应在键和值中包含通配符。 SystemJS 需要知道你在映射什么。

...
// Should work like this
System.paths['specs/*'] = 'src/js/*.spec';
Promise.all([
    System.import('specs/greeter')
])

//Here, you're essentially aliasing
System.paths['specs'] = 'src/js/greeter.spec';
Promise.all([
    System.import('specs');
    // above is equivalent to:
    System.import('src/js/greeter.spec'),
])