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

Mapping overrides default extension #524

Closed
thomaux opened this issue Jun 16, 2015 · 5 comments
Closed

Mapping overrides default extension #524

thomaux opened this issue Jun 16, 2015 · 5 comments

Comments

@thomaux
Copy link

thomaux commented Jun 16, 2015

I'm trying to get System.js to play along with Angular2 and the new typescript transpiler option (introduced in 0.17). However I can't seem to get the mapping correctly.

I have angular2 installed under my node_modules, while I have my sources under src. This is my System.js configuration:

System.config({
    transpiler: 'typescript',
    packages: {
        '/src': {
            main: 'app',
            defaultExtension: 'ts'
        },
        '/node_modules/angular2': {
            main: 'angular2',
            defaultExtension: 'js',
            map: {
                'rx': './node_modules/rx/index.js'
            }
        }
    },
    map: {
        // Added a path for ng2 because internal they require modules as 'angular2/src/...'
        angular2: '/node_modules/angular2/',
        typescript: '/lib/typescript@v1.5-beta2/bin/typescript.js'
    }
});

As you can see I'm trying to make use of the new packgaes configuration to set the default extension per package. This works great, except for one issue: somewhere in the code the rx is required by Angular2. Without the mapping configuration, System.js tries to resolve the Rx package on the path

localhost/rx

Which is obviously wrong. With the mapping in place, the package is correctly located, but requires are no longer automatically postfixed with my default extension. So I get a bunch of 404s regarding the requires in the Rx package.

Am I doing anything wrong here? You can find the code on this Github repository of mine

@guybedford
Copy link
Member

You'll need to separately add the defaultExtension option to the rx package here.

@thomaux
Copy link
Author

thomaux commented Jun 16, 2015

Thanks for your fast reply. I tried this, by updating my config to:

System.config({
    transpiler: 'typescript',
    packages: {
        '/src': {
            main: 'app',
            defaultExtension: 'ts'
        },
        '/node_modules/angular2/node_modules/rx': {
            main: 'index',
            defaultExtension: 'js'
        },
        '/node_modules/angular2': {
            main: 'angular2',
            defaultExtension: 'js',
            map: {
                'rx': './node_modules/rx'
            }
        }
    },
    map: {
        // Added a path for ng2 because internal they require modules as 'angular2/src/...'
        angular2: '/node_modules/angular2/',
        typescript: '/lib/typescript@v1.5-beta2/bin/typescript.js'
    }
});

I can correctly target the Rx package now (thank you for that!). However, all requires from there on are still not resolved with the default extension.

If I update the default extension to foo I correctly get a 404 for

localhost/node_modules/angular2/node_modules/rx/index.foo

@guybedford
Copy link
Member

Can you share a test case here?

@thomaux
Copy link
Author

thomaux commented Jun 16, 2015

Working on it!

If you have time, you could already verify the issue by cloning my repo, running npm install and then just open up the index file. I don't have a lot of time left today, so might be postponed to tomorrow. Thanks for the quick assistance.

@guybedford
Copy link
Member

Let me know if you need any further assistance here.

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

2 participants