`resolveId` doesn’t seem to work in webpack
See original GitHub issueI use resolveId
and load
to implement the plugin logic:
export default createUnplugin(() => ({
name: 'unplugin-starter',
resolveId(id) {
return id === 'my-unplugin-virtual-id' ? id : null
},
load(id) {
if (id === 'my-unplugin-virtual-id')
return 'export default \'hello my-unplugin\''
},
}))
When I used this plugin in webpack, it reported an error. But it’s ok in vite.
import str from 'my-unplugin-virtual-id'
Module not found: Error: Can't resolve 'my-unplugin-virtual-id' in 'D:\Projects\my-unplugin\playground\webpack\src'
This is my minimal demo that can reproduce the problem:https://github.com/Codpoe/unplugin-minimal-demo. And I had this problem on Windows, I haven’t tested it on Mac…
Issue Analytics
- State:
- Created 2 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Webpack Externals doesn't seem to work for React
I'm creating a React Library, already published it to npm somehow. But, I faced several issues/questions during the development flow.
Read more >rollup.js
js and webpack, you can use Rollup to compile to UMD or CommonJS format, and then point to that compiled version with the...
Read more >Hooking into import with Webpack & Rollup - AnDrew
resolveId is called for every module being imported, this is run recursively through all files until no further imports are found. The function ......
Read more >unplugin - npm
Hook, Rollup, Vite, Webpack 4, Webpack 5, esbuild ... It doesn't pass any arguments. ... Other hooks like load or resolveId work fine....
Read more >Writing build plugins - YouTube
It's common to use a build tool as part of development, ... In this session, we develop the same plugin for both Rollup...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I’m getting this as well. In case it’s helpful, here are three reproductions:
I tried to do what you said, but it still didn’t work