canyon-project / canyon

👋 Canyon is a JavaScript code coverage solution
https://docs.canyoncov.com/getting-started/first-coverage
MIT License
133 stars 9 forks source link

是否支持 nextjs swc 呢 #18

Open gt-daifan opened 2 weeks ago

zhangtao25 commented 2 weeks ago

是支持的,可以使用 https://github.com/kwonoj/swc-plugin-coverage-instrument ,插桩成功后可以进行后续的测试用例+覆盖率上报,不过 swc-plugin-coverage-instrument 这个插件目前处于实验阶段

zhangtao25 commented 2 weeks ago

可以参考 https://github.com/canyon-project/canyon/blob/e32dd4f97983e3fc3b22eb88160262badf04ad88/examples/vite-react-swc/vite.config.ts#L12-L11

gt-daifan commented 2 weeks ago

可以参考 https://github.com/canyon-project/canyon/blob/e32dd4f97983e3fc3b22eb88160262badf04ad88/examples/vite-react-swc/vite.config.ts#L12-L11

我看 example 里面是和 vite 一起跑的?

zhangtao25 commented 2 weeks ago

可以参考 https://github.com/canyon-project/canyon/blob/e32dd4f97983e3fc3b22eb88160262badf04ad88/examples/vite-react-swc/vite.config.ts#L12-L11

我看 example 里面是和 vite 一起跑的?

https://github.com/canyon-project/canyon/blob/main/examples/next-swc/next.config.mjs 新加了next swc的配置

gt-daifan commented 2 weeks ago

可以参考 https://github.com/canyon-project/canyon/blob/e32dd4f97983e3fc3b22eb88160262badf04ad88/examples/vite-react-swc/vite.config.ts#L12-L11

我看 example 里面是和 vite 一起跑的?

https://github.com/canyon-project/canyon/blob/main/examples/next-swc/next.config.mjs 新加了next swc的配置

我用的是 nextjs 13.4 似乎不行

zhangtao25 commented 2 weeks ago

https://nextjs.org/docs/pages/building-your-application/configuring/babel

zhangtao25 commented 2 weeks ago

得先确认你的next使用的是babel还是swc

gt-daifan commented 2 weeks ago

得先确认你的next使用的是babel还是swc

是 swc ,在 experimental 里面加 swcPlugins,但是会报一个 cache 的错误。Error: Filesystem cache is not enabled, cannot read plugin from phsyical path 不知道该怎么弄。😭

zhangtao25 commented 2 weeks ago

得先确认你的next使用的是babel还是swc

是 swc ,在 experimental 里面加 swcPlugins,但是会报一个 cache 的错误。Error: Filesystem cache is not enabled, cannot read plugin from phsyical path 不知道该怎么弄。😭

是不是需要先安装一下 npm install swc-plugin-coverage-instrument -D

zhangtao25 commented 2 weeks ago

得先确认你的next使用的是babel还是swc

是 swc ,在 experimental 里面加 swcPlugins,但是会报一个 cache 的错误。Error: Filesystem cache is not enabled, cannot read plugin from phsyical path 不知道该怎么弄。😭

或者看一下这个issue,貌似需要用 nextjs 13.4.3 ,我试过最新的14以上的可以 https://github.com/blitz-js/next-superjson-plugin/issues/84

gt-daifan commented 2 weeks ago

确实13.4.4 才有这个问题