-
Notifications
You must be signed in to change notification settings - Fork 47
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
Rollup optimization support #97
Comments
Note the above will only support SystemJS Builder 0.15 though. |
I'm seeing an issue when I try this - when type-checking the plugin sets
When I set the output to es6 these declaration files are no longer getting fed to the plugin and so it cannot type-check the files property. The issue also happens using the plugin-typescript -> plugin-babel -> es6 pipeline. |
@frankwallis |
It is possible but I want to put them in deps so that they will get reloaded by the hot-reloader when they change |
@frankwallis |
TBH it's a lot easier to let systemjs manage loading the files as it can take care of only loading them once and reloading them (when watching/hot-reloading). It also means The plugin translates these injected declaration files into empty files so they do not end up in the bundle, however I think perhaps the plugin should strip them out of the bundle in the Is there a technical reason that |
@frankwallis even if they are empty files, that means their module names are still built into the bundle though surely? That doesn't sound like a good build technique to me unfortunately, although I understand the convenience. Stripping these modules from the bundle process is not an option as bundles are designed to retain dynamic linking semantics and only act as a transport multiplexing. These sorts of optimizations would break that. The main reason for not allowing metadata deps for es modules is that it is not clear if this will even be possible in the loader spec. While the current spec would allow it via source code transformation ( This may well be an unnecessary assumption though, and depending how things go we could allow it in future, but the goal is to try and err on the side of conservatism to ensure the best chances of minimal pain going into a real loader. Returning to your scenario, I would really suggest loading typings with a |
For the hot-reloading scenario are you saying that changing a typing file should change the related ts file, even if that file itself did not change? Is this not something that can be integrated into the |
Thanks for the clarification, it is helpful for me to understand the bigger picture. I think the issue was that previously I was using The plugin just wants to receive any updates to typings files which wasn't happening when using I am going to give this a try now. |
@guybedford this seems to be working nicely, I have released 2.5.10 which uses |
Great to hear that. Is this definitely working with build support? Note that |
Yes it seems to work in all the scenarios, I'm just using the global https://github.com/frankwallis/plugin-typescript/blob/master/src/plugin.ts#L66 |
A scoped Does it work for builds though? |
Yes, it seems to work for builds somehow. |
@frankwallis have you definitely tested it in the latest builder? It shouldn't work. Is there not supposed to be a handler on the promises in https://github.com/frankwallis/plugin-typescript/blob/master/src/plugin.ts#L66? |
I am pretty certain it is working, but I will double-check later. We are not interested in the result of the System.import, but I suppose there ought to be a catch handler to trap errors. |
I can confirm that
I have added the promise handler and the rollup support (the original issue) and it is released in plugin-typescript@3.0.0 |
@frankwallis thanks I tried this out by adding a |
You need to add it to |
Also there is an issue using the rollup support - TypeScript cannot currently compile to es6 module format while outputting the code as es5. See microsoft/TypeScript#6319 which is tracking this. This means that rollup support is only available when using plugin-babel in the pipeline. I think I need to revert the change which switches from system -> es6 in build mode until the above issue is resolved. |
Thanks @frankwallis I checked again and this is exactly right. Because you are writing the plugin as ES6 / System.register it is getting the right instance. This would not necessarily be true for a CommonJS or AMD plugin where we do not provide a scoped System, and the plugin should use It does sound like we're waiting on TypeScript for the Rollup support then. Will keep an eye on that issue as well. |
@guybedford I'm seeing some issues using
will cause Would really appreciate your input here, thanks |
One way I have found to get around (1) is to provide an empty |
@frankwallis |
I would rather not do that into the actual files, but I could perhaps inject another file which just imports the files that I want, maybe using would something like this work?:
|
@frankwallis another thing you can do is to push dependencies into the metadata within the translate hook - |
I was setting |
Right, thanks yes I remember now. This is entirely about being unsure if the spec will allow us to do it (it currently doesn't). If the spec doesn't allow this, then adding deps would basically be handled in SystemJS itself as just injecting Note that it would still be completely equivalent to doing that sort of injection of |
Thanks, I have implemented as you suggested - |
Excellent, it sounds like the Rollup support should be working correctly then now? If so we can close this. |
Unfortunately Rollup support is still waiting on microsoft/TypeScript#6319 |
Looks like this is supported in microsoft/TypeScript#6319 now! |
All that should be needed here with the latest Typescript is something along the lines of: if (this.builder) {
typescriptOptions.module = "es2015";
load.metadata.format = 'esm';
}
else {
typescriptOptions.module = "system";
load.metadata.format = 'register';
} |
Rollup optimisation is available in plugin-typescript@5.0.6 |
👍 |
For this plugin to support rollup optimizations, it should output ES modules directly instead of System.register modules when running in a build (
var loader = this; if (this.builder == true && options.modules == 'system') options.modules = 'es6';
).The text was updated successfully, but these errors were encountered: