question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

add support for functional `build.transpile` with vite builder

See original GitHub issue

Environment

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:open
  • Created a year ago
  • Reactions:1
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
pi0commented, Aug 30, 2022

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) 👍🏼

1reaction
danielroecommented, Aug 30, 2022

build.transpile only supports RegExp + strings in Vite. (The function is used for webpack 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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found