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

Ensure vendored loader does not cache missing modules. #1601

Merged
merged 1 commit into from
May 25, 2021

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented May 25, 2021

Prior to this change, calling requireModule('foo') would create a foo module (with no exports) due to eager caching in the list of "seen" modules.

This means that code like this:

let Ember;
try {
  Ember = requireModule('ember')['default'];
} catch {
  Ember = window.Ember;
}
return Ember;

Will properly fallback to window.Ember the first time, but all subsequent runs will end up finding a module and returning {}.

This addresses at least part of #1595 (cannot confirm if it is fully resolved, due to raciness and testing timing).

Prior to this change, calling `requireModule('foo')` would **create** a
`foo` module (with no exports) due to eager caching in the list of
"seen" modules.

This means that code like this:

```js
let Ember;
try {
  Ember = requireModule('ember')['default'];
} catch {
  Ember = window.Ember;
}
return Ember;
```

Will properly fallback to `window.Ember` the first time, but all
subsequent runs will end up finding a module and returning `{}`.
@rwjblue rwjblue added the bug label May 25, 2021
Copy link
Member

@RobbieTheWagner RobbieTheWagner left a comment

Choose a reason for hiding this comment

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

LGTM!

@RobbieTheWagner RobbieTheWagner merged commit 7f64b86 into master May 25, 2021
@delete-merged-branch delete-merged-branch bot deleted the fix-vendored-loader branch May 25, 2021 21:04
patricklx pushed a commit to patricklx/ember-inspector that referenced this pull request Sep 19, 2022
Prior to this change, calling `requireModule('foo')` would **create** a
`foo` module (with no exports) due to eager caching in the list of
"seen" modules.

This means that code like this:

```js
let Ember;
try {
  Ember = requireModule('ember')['default'];
} catch {
  Ember = window.Ember;
}
return Ember;
```

Will properly fallback to `window.Ember` the first time, but all
subsequent runs will end up finding a module and returning `{}`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants