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

Transform Error when using unocss.config.ts as configuration file #1017

Closed
JSFTI opened this issue May 29, 2022 · 8 comments
Closed

Transform Error when using unocss.config.ts as configuration file #1017

JSFTI opened this issue May 29, 2022 · 8 comments

Comments

@JSFTI
Copy link

JSFTI commented May 29, 2022

When using unocss.config.ts as configuration file, npm run dev returns error.
2022_05_29_0pi_Kleki
Dependencies
image
vite.config.ts
image
unocss.config.ts
image

However, if unocss.config.ts is removed, npm run dev runs successfully. Am I missing something?

@antfu
Copy link
Member

antfu commented May 29, 2022

Can you share a minimal reproduction? Thanks.

@Sfinx
Copy link

Sfinx commented May 29, 2022

Same here (quasar2 + vite). Error appears from unocss v0.35.0. Reverting back to v0.34.1 eliminates the error

<path to app>/node_modules/@unocss/transformer-directives/dist/index.mjs:2
var _cssTree = require("css-tree");
               ^

Error: TRANSFORM_ERROR: Export namespace should be first transformed by `@babel/plugin-proposal-export-namespace-from`.
 
 <path to app>/node_modules/css-tree/lib/index.js:0:0
    at <path to app>/node_modules/@unocss/transformer-directives/dist/index.mjs:2:16
    at jiti (<path to app>/node_modules/jiti/dist/jiti.js:1:196506)
    at <path to app>/node_modules/unocss/dist/index.mjs:10:53
    at jiti (<path to app>/node_modules/jiti/dist/jiti.js:1:196506)
    at <path to app>/uno.config.js:1:177
    at jiti (<path to app>/node_modules/jiti/dist/jiti.js:1:196506)
    at loadConfigFile (<path to app>/node_modules/unconfig/dist/index.cjs:149:11)
    at async Object.load (<path to app>/node_modules/unconfig/dist/index.cjs:82:24)
    at async Object.loadConfig (<path to app>/node_modules/@unocss/config/dist/index.cjs:50:18)
    at async reloadConfig (<path to app>/node_modules/@unocss/vite/dist/index.cjs:67:20)

P.S. deps:

"dependencies": {
    "@quasar/extras": "^1.14.0",
    "pbkdf2": "^3.1.2",
    "plotly.js": "^2.12.1",
    "quasar": "^2.7.1",
    "tiny-emitter": "^2.1.0",
    "tweetnacl": "^1.0.3",
    "tweetnacl-util": "^0.15.1",
    "uuid": "^8.3.2",
    "vue": "^3.2.36",
    "vue-resize-directive": "^1.2.0",
    "vue-router": "^4.0.15"
  },
 "devDependencies": {
    "@quasar/app-vite": "^1.0.1",
    "autoprefixer": "^10.4.7",
    "postcss": "^8.4.14",
    "rollup": "^2.75.1",
    "unocss": "^0.35.1",
    "vite": "^2.9.9"
  },

@JSFTI
Copy link
Author

JSFTI commented May 29, 2022

Gladly,
First, I create a new Vite project by pnpm create vite, and choose react as the framework and react-ts as variant
image
Changed active directory to vite-project and run pnpm i
image
Installs unocss with pnpm i unocss
image
Import and add Unocss() to vite.config.ts plugin array.
image
Create unocss.config.ts file
image
This is the current directory structure
image
Run npm run dev to start development server
image
Error occurs.

However, if unocss.config.ts is removed, no error occurs and unocss will work as intended.

@JSFTI
Copy link
Author

JSFTI commented May 29, 2022

Forgot to mention that uno.css is imported in main.tsx

@QiroNT
Copy link
Member

QiroNT commented May 29, 2022

This was already fixed by #1016, just it's not released yet.
Seems like there is no way to link a closed pull request.

@JSFTI
Copy link
Author

JSFTI commented May 29, 2022

I see, I guess the best course of action is to revert to 0.34.1 as mention by Sfinx. Thank you for your help.

@JSFTI JSFTI closed this as completed May 29, 2022
@antfu
Copy link
Member

antfu commented May 29, 2022

Published v0.35.2

@Sfinx
Copy link

Sfinx commented May 29, 2022

Thanks, works !

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

4 participants