Skip to content

Commit

Permalink
Test asset import in bundle with resolutions map
Browse files Browse the repository at this point in the history
  • Loading branch information
kasperisager committed Oct 9, 2024
1 parent a509921 commit bd42259
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2813,6 +2813,24 @@ test('load .bundle with asset import, asset method', (t) => {
t.is(Module.load(new URL(root + '/app.bundle'), bundle, { protocol }).exports, isWindows ? 'c:\\bar.txt' : '/bar.txt')
})

test('load .bundle with asset import, resolutions map', (t) => {
t.teardown(onteardown)

const bundle = new Module.Bundle()
.write('/foo.js', 'module.exports = require.asset(\'./bar.txt\')', { main: true })
.write('/baz.txt', 'hello world', { asset: true })

bundle.resolutions = {
'/foo.js': {
'./bar.txt': {
asset: '/baz.txt'
}
}
}

t.is(Module.load(new URL(root + '/app.bundle'), bundle.toBuffer()).exports, isWindows ? 'c:\\app.bundle\\baz.txt' : '/app.bundle/baz.txt')
})

function onteardown () {
// TODO Provide a public API for clearing the cache.
Module._cache = Object.create(null)
Expand Down

0 comments on commit bd42259

Please sign in to comment.