web
web copied to clipboard
HTML test importmaps doesn't work with esbuild + typescript?
Trying to mock es modules in a test by using a HTML-test with importmaps.
<script type="importmap">
{
"imports": {
"../../../src/player/index.ts": "./player.mock.ts"
}
}
</script>
<script type="module" src="player.test.ts"></script>
It fails to include the mock, and includes the original file instead. However, when logging import.meta.url in the original file I see that ?wds-import-map=0 has been appended to the import. I suppose this tells the dev-server to include the mock but for some unknown reason it fails to do so?
Active plugins:
plugins: [
commonjs({
transformMixedEsModules: true,
include: [
'node_modules/shaka-player/dist/shaka-player.compiled.js'
],
}),
esbuildPlugin({ ts: true }),
importMapsPlugin()
]
I see same problem. If I add ?wds-import-map=0 to the import map url manually, it works. Like:
plugins: [
litCss({
include: ['src/components/**/*.css'],
}),
esbuildPlugin({ ts: true, target: 'esnext' }),
importMapsPlugin({
inject: {
importMap: {
imports: {
'/src/components/icon/bl-icon.ts?wds-import-map=0': '/src/utilities/bl-icon.mock.ts',
},
},
},
}),
],
But I think we should not add this parameter manually.