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

fix: avoid global declaration collisions in cjs #15608

Merged
merged 2 commits into from
Aug 26, 2022

Conversation

dsherret
Copy link
Member

Also adds the ability for us to have custom npm packages in the tests, which is what most of this PR is.

Closes #15604

"(function (exports, require, module, __filename, __dirname, globalThis) { (function (exports, require, module, __filename, __dirname, globalThis, Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout) {",
"\n}).call(this, exports, require, module, __filename, __dirname, globalThis, globalThis.Buffer, globalThis.clearImmediate, globalThis.clearInterval, globalThis.clearTimeout, globalThis.global, globalThis.process, globalThis.setImmediate, globalThis.setInterval, globalThis.setTimeout); })",
"(function (exports, require, module, __filename, __dirname, globalThis) { const { Buffer, clearImmediate, clearInterval, clearTimeout, global, process, setImmediate, setInterval, setTimeout} = globalThis; (function () {",
"\n}).call(this); })",
Copy link
Member Author

Choose a reason for hiding this comment

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

Fix is here.

@dsherret
Copy link
Member Author

dsherret commented Aug 25, 2022

The stack overflows on the Windows CI is because of swc parsing the _pico.mjs module in std/node. I'm not sure why it suddenly started happneing, but it happens locally for me too (and I locally increased the stack size to prevent it)... https://github.com/denoland/deno/runs/8027046381?check_suite_focus=true

Edit: I bumped it up to *2 instead of *1.5 the default size. Some people were asking to increase it anyway.

pub struct CustomNpmPackageCache(HashMap<String, CustomNpmPackage>);

impl CustomNpmPackageCache {
pub fn load() -> Result<Self, anyhow::Error> {
Copy link
Member Author

@dsherret dsherret Aug 25, 2022

Choose a reason for hiding this comment

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

In the future, this should probably be lazy so it's faster once we start having many packages. I just wrote this as a first pass.

…o much stack size. We should look into this more later though.
Copy link
Member

@bartlomieju bartlomieju left a comment

Choose a reason for hiding this comment

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

LGTM, nice fix!

Comment on lines +1 to +6
# npm test data

This folder contains test data for npm specifiers.

## Registry

Copy link
Member

Choose a reason for hiding this comment

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

This is great

@dsherret dsherret merged commit 376665d into denoland:main Aug 26, 2022
@dsherret dsherret deleted the fix_avoid_declaration_collisions_cjs branch August 26, 2022 00:24
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.

npm URL throws: Identifier 'process' has already been declared
2 participants