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

Allow importmap overrides in shim mode with option #257

Merged
merged 9 commits into from
Feb 11, 2022

Conversation

lewisl9029
Copy link
Contributor

@lewisl9029 lewisl9029 commented Feb 10, 2022

As discussed in #254, this PR adds a override boolean option to allow overriding of existing import map entries in shim mode, defaulting to false to preserve current behavior. Overall increase in footprint is 7 bytes to 9167 according to the npm run footprint command.

A few hoops I had to jump through:

  • Depending on ./config.js in ./common.js introduced a circular dependency, which caused some weird issues in tests. So I ended up refactoring the noop function into its own module to untangle it. I also tried inlining the noop function everywhere, but it ended up making the bundle larger than using a separate module.

  • For testing, I ended up adding a separate module for this option because I couldn't figure out a way to make the test coexist in the same module without conflicting with the existing importmap overrides tests, which require this option to be off. Open to alternatives!

Total additional footprint is 7 bytes.
Used for footprint command, but was being loaded as transitive dependency previously.
Had to make a separate test suite, as I couldn't figure out a way to make this test coexist with the existing shim suite, since it required a different override option from the other tests.

Open to ideas!
Copy link
Owner

@guybedford guybedford left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks for your work on this!

README.md Outdated Show resolved Hide resolved
src/common.js Outdated Show resolved Hide resolved
@lewisl9029
Copy link
Contributor Author

With the latest changes we're only 2 bytes higher at 9162 now! I guess refactoring out the resolve functions must have saved enough bytes to make up for everything else, somehow.

@guybedford
Copy link
Owner

Thanks for the quick turnaround on this one - footprint is great!

Will release soon, just hoping to get #255 fix in as well.

@guybedford guybedford merged commit d36f1e0 into guybedford:main Feb 11, 2022
@lewisl9029 lewisl9029 deleted the allow-importmap-overrides branch February 11, 2022 01:37
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

Successfully merging this pull request may close these issues.

2 participants