Skip to content

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

@kitsonk

Description

@kitsonk

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.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions