From vite@2.0.0-beta.22, vite uses native esm imports in vite.config.js when "type": "module" is set in package.json of the project.
This PR adds exports field to every package.
Adding this to rollup-plugin-purge-icons and vite-plugin-purge-icons fixed the error in the situation above.
failed to load config from /documents/GitHub/portfolio/vite.config.ts
error when starting dev server:
TypeError: PurgeIcons is not a function
at file:///D:/documents/GitHub/portfolio/vite.config.ts.js?t=1611041039388:34:5
at ModuleJob.run (internal/modules/esm/module_job.js:152:23)
at async Loader.import (internal/modules/esm/loader.js:166:24)
at async loadConfigFromFile (D:\documents\GitHub\portfolio\node_modules\vite\dist\node\chunks\dep-b51e3b62.js:46921:31)
at async resolveConfig (D:\documents\GitHub\portfolio\node_modules\vite\dist\node\chunks\dep-b51e3b62.js:46710:28)
at async createServer$2 (D:\documents\GitHub\portfolio\node_modules\vite\dist\node\chunks\dep-b51e3b62.js:70324:20)
at async CAC.<anonymous> (D:\documents\GitHub\portfolio\node_modules\vite\dist\node\cli.js:683:24)
(I have not tested other packages but I think it would work.)
From vite@2.0.0-beta.22, vite uses native esm imports in
vite.config.js
when"type": "module"
is set in package.json of the project.This PR adds
exports
field to every package.Adding this to
rollup-plugin-purge-icons
andvite-plugin-purge-icons
fixed the error in the situation above.(I have not tested other packages but I think it would work.)
Another way to fix this is to change the transpile somehow. The reason of this error is that
export default
's are been transpiled toexport.default =
instead ofmodule.exports =
. https://github.com/egoist/tsup/blob/f0a833976b99bdd2df0d704b636f370963751eb7/src/index.ts#L204 https://sucrase.io/#selectedTransforms=imports&compareWithTypeScript=true&code=const%20App%20%3D%20%7B%7D%0A%0Aexport%20default%20App%3B%0A%0A