modernweb-dev / web

Guides, tools and libraries for modern web development.
https://modern-web.dev
MIT License
2.2k stars 280 forks source link

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

Open mdownes opened 2 years ago

mdownes commented 2 years ago

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

enessoylu commented 1 year ago

Any updates on this?