Typescript statement results in require for browser #19437
-
I've got a index.ts source file with the following line:
With the following content:
I am using a .babelrc file as well:
(Yep, I'm aware that the target environment is quite outdated) And this is my vite.config.ts file:
The built index.js file looks like this:
As you can see, it uses import as well as require-statements; while import may work for most browsers, require does not. I'd expect the file to be ES5 compatible (which the -legacy file appears to be). Is my expectation wrong? If not, what am I missing? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I guess babel is converting |
Beta Was this translation helpful? Give feedback.
I guess babel is converting
import
s intorequire
s unnecessarily. Vite does not supportrequire
outside of node_modules, so that's probably the reason whyrequire
is output as-is.