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

[Feature Quest]: CommonJS build #33

Open
yuche opened this issue Oct 29, 2023 · 4 comments
Open

[Feature Quest]: CommonJS build #33

yuche opened this issue Oct 29, 2023 · 4 comments

Comments

@yuche
Copy link

yuche commented Oct 29, 2023

In some cases, vite is running in commonjs and developers are not authorised to change it. eg. Same CodeSandbox container. This can cause an error to be reported:

Error [ERR_REQUIRE_ESM]: require() of ES Module /project/sandbox/node_modules/unocss-preset-daisy/index.js from /project/sandbox/vite.config.ts not supported.

unocss-preset-daisy should provided a CommonJS build and specify the values of import and require in packages.json#exports like this.

@kidonng
Copy link
Owner

kidonng commented Oct 30, 2023

When this first got popular, I released a dual package version, but later went back to ESM only as I don't see why projects can't use ESM when they are new enough to deploy UnoCSS. It's like rejecting const foo = 'bar' while using Array.prototype.at.

As for your case, I doubt CodeSandbox, being a fairly popular service, doesn't support ESM. It's more like a config mistake. Could you provide a reproducible link?

@yuche
Copy link
Author

yuche commented Oct 30, 2023

When this first got popular, I released a dual package version, but later went back to ESM only as I don't see why projects can't use ESM when they are new enough to deploy UnoCSS. It's like rejecting const foo = 'bar' while using Array.prototype.at.

As for your case, I doubt CodeSandbox, being a fairly popular service, doesn't support ESM. It's more like a config mistake. Could you provide a reproducible link?

Repro:

Note that changing vite.config.js or vite.config.ts to vite.config.mjs seems to work, but in reality it will only work within CodeSandbox website itself, not if you use sandpack.

@lzdml
Copy link

lzdml commented Dec 15, 2023

you can use import 'daisyui/dist/full.css'; in main.ts

@yuche
Copy link
Author

yuche commented Dec 15, 2023

you can use import 'daisyui/dist/full.css'; in main.ts

Yes I can do that. But the reason for using this plugin is that I want the packaged files to be as small as possible, otherwise why would I use vite?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants