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

Missing file extension for named modules from "-m system --outFile foo.js" #6774

Closed
danieleds opened this issue Jan 31, 2016 · 4 comments
Closed
Labels
Duplicate An existing issue was already created

Comments

@danieleds
Copy link

When bundling multiple files with -m system, the module names should include the file extension. Otherwise, they are loaded but not executed by systemjs.

Before:

    System.register("app/boot", [...], ...

After:

    System.register("app/boot.js", [...], ...

See here: systemjs/systemjs#1065

@danieleds danieleds changed the title Missing file extension for System named modules Missing file extension for named modules from "-m system --outFile foo.js" Jan 31, 2016
@mhegazy
Copy link
Contributor

mhegazy commented Feb 1, 2016

looks like a duplicate of #4595.

@mhegazy mhegazy closed this as completed Feb 1, 2016
@mhegazy mhegazy added the Duplicate An existing issue was already created label Feb 1, 2016
@geoff-mci
Copy link

geoff-mci commented Nov 9, 2016

@mhegazy I'm not sure this is really a duplicate. #4595 fixes an import issue for TypeScript, but the comments in https://github.com/systemjs/systemjs/issues/1065 indicate that, for systemjs to work with typescript outFile bundles, the .js extension must be present in the System.register call.
...Of course I could be missing something.

My use case:
I'm trying to have the simplest dev setup I can for Angular2 development. I use webpack in production because it's the one I've managed to grok enough to make work (why is module loading over complicated!) but have found it too slow for development. I'd like to be able to generate a bundle from typescript and then execute the bootstrap module from within that...but this issue blocks that workflow (except I'll probably write a gulp task to add the extensions myself).

Cheers.

@tuukkapuranen
Copy link

@geoff-mci I agree, this may not be a duplicate of #4595. I just ran into same issue as you and @danieleds with #1065 at SystemJS. The outFile bundle is generated without .js extension for SystemJS, and this results in the main script not executing. Other calls to register seem to work without the extension.

The good news is, I was able to trick tsc into generating the extension to the script defined by outFile. It turns out that the code is generated by the system module, which in turn calls tryGetModuleNameFromFile, and this function reads the <amd-module name="name"> comment to determine if there is a custom name present.

I added /// <amd-module name="boot.js" /> to the .ts file with the same name (which is also the name of the outFile target), and the result does now get the extension to the name: System.register("boot.js", ... However, I am not sure how stable this approach is. Can someone more knowledgeable shed some light on this?

@aluanhaddad
Copy link
Contributor

aluanhaddad commented Jan 7, 2017

@tuukkapuranen I do not recommend using <amd-module> as a workaround it is not something you want to commit to using. The bundle shouldn't need to use any extensions in the named register output, the names just need to match up. I just tried it and it generates an extensionless bundle that loads just fine provided that you are configuring the loader in the standard way.

I created an example repository. No file extensions required. It is very minimal but it works. https://github.com/aluanhaddad/typescript-systemjs-bundled-extensionless

@microsoft microsoft locked and limited conversation to collaborators Jun 19, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Duplicate An existing issue was already created
Projects
None yet
Development

No branches or pull requests

5 participants