web icon indicating copy to clipboard operation
web copied to clipboard

dev-server-import-maps not working if i dont add mapid querystring

Open mdownes opened this issue 2 years ago • 0 comments

I am trying to mock a service and I have the following configuration:

importMapsPlugin({
            inject: {
                importMap: {
                    imports: {
                        // mock a module in your own code
                        '/src/services/hello-world-service.ts': '/src/services/hello-world-service.mock.ts',
                    },
                },
            },
        }),

However, it only works if i add ?wds-import-map=0 to the identifier like so:

importMapsPlugin({
            inject: {
                importMap: {
                    imports: {
                        // mock a module in your own code
                        '/src/services/hello-world-service.ts?wds-import-map=0': '/src/services/hello-world-service.mock.ts',
                    },
                },
            },
        }),

It seems the transformImport() function in importMapsPlugin.js adds the identifier to all modules in the source code so the import map then does not match if i don't add the querystring.

Am i doing something wrong or is this somehow by design?

I have tried version 0.0.4, 0.0.5, 0.0.6

mdownes avatar Jul 28 '22 09:07 mdownes