Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

require.cache() does not work as expected #124

Closed
kitsonk opened this issue Apr 15, 2017 · 0 comments
Closed

require.cache() does not work as expected #124

kitsonk opened this issue Apr 15, 2017 · 0 comments
Assignees
Labels
Milestone

Comments

@kitsonk
Copy link
Member

kitsonk commented Apr 15, 2017

Bug

When passing modules via the require.cache() API, it does not work as expected.

Code

require.cache({
    'some/module/mid': () => { define('some/module/mid', [ 'dependency' ], (dependency) => { /* module */ }
});

require([ 'some/module/mid' ], (someModule) => { /* stuff */ };

Expected behavior:

This should run without issue.

Actual behavior:

The loader will report it cannot load some/module/mid. In order to make it available, you have to
do something like this:

require.cache({
    'some/module/mid': () => { define('some/module/mid', [ 'dependency' ], (dependency) => { /* module */ }
});
require.cache({});

require([ 'some/module/mid' ], (someModule) => { /* stuff */ };

Which will cause the loader to actually consume the provided cached modules.

I suspect this is mainly because there are not tests around the .cache() API that this is why this is undetected.

@kitsonk kitsonk added the bug label Apr 15, 2017
@dylans dylans added this to the 2017.04 milestone Apr 18, 2017
rorticus added a commit to rorticus/loader that referenced this issue Apr 28, 2017
@dylans dylans modified the milestones: 2017.05, 2017.04 Apr 29, 2017
rorticus added a commit to rorticus/loader that referenced this issue May 5, 2017
rorticus added a commit that referenced this issue May 5, 2017
#129)

* Adding to cache as soon as require.cache is called instead of pending it for later, issue #124

* Removing unused code
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants