windicss / vite-plugin-windicss

🍃 Windi CSS for Vite ⚡️
MIT License
852 stars 65 forks source link

pug support broken since moving to esm #318

Closed tjk closed 1 year ago

tjk commented 1 year ago
__require("pug");

causes the following:

[0] Error: Dynamic require of "pug" is not supported
[0]     at file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:10:9
[0]     at getDefaultExtractors (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:358:5)
[0]     at resolveOptions (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:482:40)
[0]     at async _init (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:970:15)

and

__require.resolve("pug");

which was introduced in https://github.com/windicss/vite-plugin-windicss/commit/b40865f15edc147e1664486767018ba39dad703a, causes the following:

[0] TypeError: __require.resolve is not a function
[0]     at getDefaultExtractors (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:358:15)
[0]     at resolveOptions (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:482:40)
[0]     at async _init (file:///_____/node_modules/.pnpm/@windicss+plugin-utils@1.8.10_uo55fazybmpes3n54qosx65kau/node_modules/@windicss/plugin-utils/dist/index.mjs:970:15)

In both cases, vite-plugin-windicss catches the error quietly and what ends up happening is that the class extraction breaks and none of the css generation is good.

Versions

Additonal Context Went to "type": "module"