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

Option to transpile module inside node_modules #5025

Closed
4 tasks done
flip-it opened this issue Sep 22, 2021 · 4 comments
Closed
4 tasks done

Option to transpile module inside node_modules #5025

flip-it opened this issue Sep 22, 2021 · 4 comments

Comments

@flip-it
Copy link

flip-it commented Sep 22, 2021

Clear and concise description of the problem

I need to use a NPM package that isn't transpiled. Seems like babel/webpack can be configured, and Next.js added an option for it. Is it something Vite also can support?

Suggested solution

Possibly by adding something like this in the config:

export default defineConfig({
  addModulePathsToTranspile: ['package-name', '@other/package'],
});

Alternative

No response

Additional context

No response

Validations

@jasondibenedetto
Copy link

Just wanted to bump this one to see if there was any updates on how to achieve this.

@Devric
Copy link

Devric commented Dec 19, 2021

is your purpose of transpile mostly required for hot reloading? if so i just found this hotreload library, which does it by settings the watch on all files from root. works perfect with my monorepo setup and SSR, havent test changes with on page states yet, might not work with that.


import liveReload from "vite-plugin-live-reload"
 plugins: [
                liveReload('**/*'),
                ....  
]

@bluwy
Copy link
Member

bluwy commented Mar 20, 2022

As long as the NPM package is written in ESM, you can do so today with optimizeDeps.exclude: ["that-dep"]. And it'll go through Vite's process. If that-dep has transitive deps that are not ESM, you can add optimizeDeps.include: ["that-dep > cjs-dep"]. vite-plugin-svelte has been doing these automatically for raw Svelte libraries. Another option is to have Vite plugins apply #6801, but it's still at experimental stage.

Does the optimizeDeps flow work for you @flip-it? If so we could close this issue.

@sodatea
Copy link
Member

sodatea commented May 6, 2022

Closing due to lack of response.

@sodatea sodatea closed this as completed May 6, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 21, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants