Open AleksandrHovhannisyan opened 2 years ago
I am hitting exactly this, if I had access to the inject: property from esbuild I would be totally set.
am I reading the esbuild docs correctly, in the transform api you can't inject?
I think this could be resolved fairly easily if the internals of the library used build instead of transform. Is anyone even actively maintaining this library anymore?
I don't think you'd want to use build actually, as jest transforms it in memory and executes it, which I think would be faster than emitting actual files. I got around this issue in a bit of a weird way, in my setup files script for jest I set react to a global variable, so
global.react = require('react');
the rest of my issues are things specific to esbuild and mocks.
There's a write option on the build function that keeps everything in memory and doesn't write to file.
ah, then that does sound good.
esbuild supports options that allow you to automatically import React for JSX files so that you don't have to do
import React from 'react'
in every file. Is there currently a way to do that with this plugin, or will I need to manually import React?