Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

111
Views
¿Esbuild con ReactJS.NET?

TL; DR ¿Cómo puedo usar esbuild conReactJS.NET ?


Versión larga

ReactJS.NET espera lo siguiente de un "paquete":

 React.Exceptions.ReactNotInitialisedException: 'React has not been loaded correctly: missing (React, ReactDOM, ReactDOMServer). Please expose your version of React as global variables named 'React', 'ReactDOM', and 'ReactDOMServer'

Lo que realmente hace Webpack nunca está muy claro para mí, pero mirando el tutorial de ReactJS.NET Webpackaquí , esta es la configuración:

 import React from 'react'; import ReactDOM from 'react-dom'; import ReactDOMServer from 'react-dom/server'; import RootComponent from './home.jsx'; global.React = React; global.ReactDOM = ReactDOM; global.ReactDOMServer = ReactDOMServer; global.Components = { RootComponent };

Además, en el ejemplo de webpack-config aquí , hay esta configuración de salida:

 { [...] globalObject: 'this', }

Duplicar esto en esbuild sería usar iife y esbuild.globalName = 'this' , pero arroja un error:

 > (global name):1:0: error: Expected identifier but found "this" 1 │ this

Esbuild es bastante severo en cuanto a que es un paquete (no un transpilador y concatenador), entonces, ¿cómo modificaría Esbuild para que el paquete mute el objeto global a lo que espera React.NET? - ¿Y es posible?

Gracias, Fleming

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Encontré una solución.

 import { build } from 'esbuild' const globalName = 'whatever' build({ [...] format: 'iife', globalName, footer: { // Important! Assigns the raw export of the bundle to whatever `this` is in the given context js: `Object.assign(this, ${globalName})`, }, })
about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!