Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pug extractor not working with type="module" in package.json #272

Open
davay42 opened this issue Jan 12, 2022 · 2 comments
Open

Pug extractor not working with type="module" in package.json #272

davay42 opened this issue Jan 12, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@davay42
Copy link

davay42 commented Jan 12, 2022

Describe the bug
I've been struggling with windicss not producing styles for my lang="pug" Vue SFCs in my components library. Manually adding the WindiCSS({ extract: [PugExtractor], }), didn't help. But then I looked through the extractor code and saw the dynamic require of pug. This lead me to try to remove "type="module" line in my package.json and all the styles got generated just fine.

Actual repo
https://github.com/DeFUCC/gun-vue/tree/master/components

Versions

  • vite-plugin-windicss: ^1.6.2
  • vite: ^2.7.10
  • framework(vue/react/svelte/etc): vue

Additonal Context

@davay42 davay42 added the bug Something isn't working label Jan 12, 2022
@theozhang32
Copy link

Seems like
#266 (comment)

@theozhang32
Copy link

I tried these

  1. use import { createRequire } from 'node:module'
  2. replace require.resolve('pug') to createRequire(import.meta.url).resolve('pug')
  3. replace require('pug') to createRequire(import.meta.url)('pug')
    const Pug = require('pug') as typeof import('pug')

Reference from https://stackoverflow.com/questions/59443525/require-not-working-in-module-type-nodejs-script

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants