Code Monkey home page Code Monkey logo

Comments (16)

csr632 avatar csr632 commented on May 24, 2024 1

I will upgrade it in a week. @yunsii

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

@yunsii The latest version supports Vite3. You can try it!

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

Thanks. I also plan to upgrade mdx dependencies to its 2.x version. I will take a look into into vite-plugin-mdx today (maybe create an issue in that repo to discuess with the author).

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

Thanks, how about vite-plugin-mdx?

I will send a PR to vite-plugin-mdx, once I find out a way to support nodejs esm without breaking change and test it out.

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

I just published an alpha version that support esm: [email protected]
You can try it out! @yunsii
I will publish it as public version after writing some tests.

Here is an example for ES Module setup:
https://stackblitz.com/edit/vitejs-vite-plugin-react-pages-bhmjv8?file=vite.config.ts&terminal=dev

// vite.config.ts
import { defineConfig } from 'vite'
import * as path from 'path'
import react from '@vitejs/plugin-react'
import pages from 'vite-plugin-react-pages'

// vite-plugin-mdx currently have interop issue in node esm.
// This is a workaround.
// I will send a PR to fix it so users won't need this workaround.
import _mdx from 'vite-plugin-mdx'
const mdx = ((_mdx as any).default || _mdx) as typeof _mdx

export default defineConfig({
  plugins: [
    react(),
    mdx(),
    pages({
      pagesDir: path.join(__dirname, 'pages'),
    }),
  ],
})

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

Maybe waiting for vite support vitejs/vite#6623 or downgrade @mdx-js/mdx to v1?

@yunsii You need to downgrade @mdx-js/mdx to v1 (because vite-plugin-mdx don't support mdx v2 currently). And use the alpha version vite-plugin-react-pages, like the above example.

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024 1

#68 is merged and published as [email protected]. It supports Node.js esm.
Here is an example for Node.js esm setup:
https://stackblitz.com/edit/vitejs-vite-plugin-react-pages-bhmjv8?file=vite.config.ts&terminal=dev

I have created another issue to track mdx migration: #69
So that we don't make this issue to be too complicated.

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

Hi, I'm using vite v3 currently, and want to use storybook-like tool for now. So any progress? or anything I can help?

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024
"@vitejs/plugin-react": "^2.0.1",
"vite": "^3.0.7",
"vite-plugin-react-pages": "^3.2.1",
"vite-pages-theme-doc": "^3.3.0",

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

Great, I will try it later.

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

@csr632 I encounter the same issue like vitejs/vite#5694 So the bundle result should update?

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024

@yunsii Are you using nodejs's native ESModule (type: module in package.json)? I will take a look in this case today.

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

Yes, I use type: module in package.json, and vite-plugin-mdx has the same error, this repo LOOKING FOR A NEW MAINTAINER, maybe you can do it? Out of curiosity, I alse have a plan to maintain the repo 🤔

from vite-plugin-react-pages.

csr632 avatar csr632 commented on May 24, 2024

For users using nodejs's native ESModule (type: module in package.json), you can workaround vite plugins that not support ESModule currently like this:

import _mdx from 'vite-plugin-mdx'
import _pages from 'vite-plugin-react-pages'

const mdx = (_mdx as any).default as typeof _mdx
const pages = (_pages as any).default as typeof _pages

// mdx and pages will be the actual default export

I will fix vite-plugin-react-pages soon.

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

Thanks, how about vite-plugin-mdx?

from vite-plugin-react-pages.

yunsii avatar yunsii commented on May 24, 2024

Still has error:
image

Maybe waiting for vite support vite.config.mts or downgrade @mdx-js/mdx to v1?

from vite-plugin-react-pages.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.