Skip to content

Collapse duplicated module requires #118

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

Closed
evmar opened this issue Apr 2, 2016 · 4 comments
Closed

Collapse duplicated module requires #118

evmar opened this issue Apr 2, 2016 · 4 comments
Assignees

Comments

@evmar
Copy link
Contributor

evmar commented Apr 2, 2016

import {A} from './foo';
import {B} from './foo';

A, B;

becomes

var foo_1 = require('./foo');
var foo_2 = require('./foo');
foo_1.A, foo_2.B;

We need to collapse those multiple requires into

var foo_1 = require('./foo');
var foo_2 = foo_1;

(This is not just a thing that can be handled by the user by just avoiding double imports, because if you'll get the duplicate identifiers also if you import and export from the same module.)

@evmar
Copy link
Contributor Author

evmar commented Apr 2, 2016

Part of issue #111.

@alexeagle
Copy link
Contributor

note, everything I've tried here is very slow (like >5m to compile angular2)
so I'm not sending a PR from https://github.com/angular/sickle/tree/ajd

It seems like even with hash-based map lookup, it is too expensive to check every import statement against the previously seen ones. If the imports were known to be ordered by clang-format, then we would be able to do this in O(1). Do you have any ideas?

@evmar
Copy link
Contributor Author

evmar commented Apr 4, 2016

It can't be that expensive, are you sure it's your code? Perhaps your code is just enabling compilation to make more progress and something after it is making this slow? A given file has at most ~50 imports, and even using an array it's only 50^2 = 2500 steps which should be a fraction of a second.

@alexeagle
Copy link
Contributor

I'm pretty sure this change causes it. In a clean client I can build
angular2 and deps in under 2m, but it's over 5m in the client with the
sickle change.

On Mon, Apr 4, 2016 at 3:15 PM Evan Martin [email protected] wrote:

It can't be that expensive, are you sure it's your code? Perhaps your code
is just enabling compilation to make more progress and something after it
is making this slow? A given file has at most ~50 imports, and even using
an array it's only 50^2 = 2500 steps which should be a fraction of a second.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#118 (comment)

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