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

Vite CJS build warning caused by import of unoCSSConfig from @tutorialkit/astro #244

Closed
AriPerkkio opened this issue Aug 14, 2024 · 2 comments · Fixed by #270
Closed

Vite CJS build warning caused by import of unoCSSConfig from @tutorialkit/astro #244

AriPerkkio opened this issue Aug 14, 2024 · 2 comments · Fixed by #270
Labels
nice-to-have Not breaking anything but nice to have

Comments

@AriPerkkio
Copy link
Member

AriPerkkio commented Aug 14, 2024

Describe the bug

When TutorialKit is started in development or build mode, Vite's CJS build entrypoint error is shown:

$ pnpm dev
...
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

Steps to reproduce

$ pnpm create tutorial

$ pnpm dev
...
The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
$ code uno.config.ts

- import { unoCSSConfig } from '@tutorialkit/astro';

export default defineConfig({
-  ...unoCSSConfig,
$ pnpm dev

# No warnings

Expected behavior

No warning should be shown

Platform

  • TutorialKit version: 0.1.4
@AriPerkkio AriPerkkio added the nice-to-have Not breaking anything but nice to have label Aug 14, 2024
@henrikvilhelmberglund
Copy link
Contributor

Not sure why but seems to be caused by spreading ...unoCSSConfig instead of using the variables from import { rules, shortcuts, theme } from "@tutorialkit/theme";

The UnoCSS config could also be made into a preset if that's easier:

presetTutorialKit.ts

import { definePreset } from "unocss"
import { rules, shortcuts, theme } from "@tutorialkit/theme";

export default definePreset(() => {
  return {
    name: 'presetTutorialKit',
    rules,
    shortcuts,
    theme
  }
})

uno.config.ts (removing ...unoCSSConfig)

  presets: [
    presetUno({
      dark: {
        dark: '[data-theme="dark"]',
      },
    }),
    presetTutorialKit(),
    ```

@AriPerkkio
Copy link
Member Author

I think this is happening when unocss imports the uno.config.ts, and that file imports '@tutorialkit/astro' that has imports for Astro stuff. Not sure why unocss decides to use CJS here.

We are planning to move most, if not all (?) uno.config.ts inside @tutorialkit/* packages so that end-users wouldn't have to maintain that file. Ideally tutorials wouldn't even have to create uno.config.ts unless they explicitly wanted to extend that. There's some discussion on #144.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
nice-to-have Not breaking anything but nice to have
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants