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

Re-exported const enums break emit in watch mode #376

Closed
smphhh opened this issue Nov 15, 2016 · 4 comments
Closed

Re-exported const enums break emit in watch mode #376

smphhh opened this issue Nov 15, 2016 · 4 comments

Comments

@smphhh
Copy link
Contributor

smphhh commented Nov 15, 2016

Given

bar.ts:

export const enum BarEnum {
    Bar = 1
};

foo.ts:

export { BarEnum } from './bar';

app.ts:

import { BarEnum } from './foo';
console.log(BarEnum.Bar);

the emit for app.ts in the initial build looks like the following:

"use strict";
console.log(1 /* Bar */);

After changing bar.ts to

export const enum BarEnum {
    Bar = 2
};

no modules will be rebuild. The expected output after the change would be

"use strict";
console.log(2 /* Bar */);

This is because ts-loader currently only adds the direct dependencies of modules as dependencies to webpack. Because bar.ts is not a direct dependency of app.ts, app.ts will not be rebuild when bar.ts changes.

For semantic errors the deeper dependencies are handled in the after-compile hook, but this doesn't help in cases like const enums where the actual emit can depend on deeper dependencies.

I believe awesome-typescript-loader does add all actual dependencies of a module as webpack dependencies recursively, which I think is the only way to handle these (relatively rare) cases correctly.

I'll post a pull-request with a test showcasing this error.

@johnnyreilly
Copy link
Member

Thanks for the issue and the PR illustrating the issue. I think you're right - it's a problem. If you get the time to take a look at this that'd be awesome. I'm not sure when I'd get time to look myself.

@smphhh
Copy link
Contributor Author

smphhh commented Nov 15, 2016

I can probably at least play around with this.

@johnnyreilly
Copy link
Member

Awesome - every little helps 😉

johnnyreilly added a commit that referenced this issue Nov 18, 2016
Add test for handling re-exported const enums (issue #376)
@johnnyreilly
Copy link
Member

Fixed with #377 - thanks @smphhh!

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