add support for functional `build.transpile` with vite builder
See original GitHub issueEnvironment
https://codesandbox.io/s/amazing-minsky-nwzxcr?file=/nuxt.config.js
Reproduction
In the “nuxt.config.js” define the build transpile like:
import { defineNuxtConfig } from “nuxt”;
export default defineNuxtConfig({ build: { transpile: [({ isDev }) => isDev && “lodash”] } });
Then execute “npm run build”
Describe the bug
The nuxt build is returns the error in logs section. And lodash is not transpiled.
Additional context
The functionality work properly when the nuxt.config is done in typescript (“nuxt.config.ts”).
Config from nuxt documentation. https://nuxtjs.org/docs/configuration-glossary/configuration-build/#transpile
Logs
WARN [SSR] Error transforming /sandbox/node_modules/nuxt/dist/app/entry: filename.split is not a function
at normalizePath (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:11471:21)
at getMatcherString (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:11476:16)
at Object.test (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:11495:33)
at result (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:11511:25)
at node_modules/vite/dist/node/chunks/dep-0fc8e132.js:38123:38
at node_modules/vite/dist/node/chunks/dep-0fc8e132.js:38139:41
at shouldExternalizeForSSR (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:38066:12)
at TransformContext.transform (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:40368:34)
at async Object.transform (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:35579:30)
at async loadAndTransform (node_modules/vite/dist/node/chunks/dep-0fc8e132.js:39888:29)
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Build Options - Vite
Another special value is 'esnext' - which assumes native dynamic imports support and will transpile as little as possible: If the build.minify option...
Read more >Build and Deploy a Single Page App with React, Vite, and ...
This guide will cover in detail the steps to create a working example bookstore single page application using the latest React 18 and...
Read more >Adding Vite to Your Existing Web App | CSS-Tricks
You'll grow tired of hearing me say this, but Vite supports this out of ... If that's the case, you'll need to transpile...
Read more >Documentation - Integrating with Build Tools - TypeScript
Vite supports importing .ts files out-of-the-box. It only performs transpilation and not type checking. It also requires that some compilerOptions have certain ...
Read more >rollup.js
js. Rollup allows you to write your code using the new module system, and will then compile it back down to existing supported...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Yes, we added it to Nuxt 2 for webpack too (main usecase was a transpile for nuxt/http module only on server) makes sense to support function entries for transpile accepting env for vite too (universally) 👍🏼
build.transpile
only supports RegExp + strings in Vite. (The function is used forwebpack
builder only.)Do you think it’s worth adding support for it to vite builder too @pi0? I think it could be useful as someone might want to transpile in server/client context only.