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

153
Views
Acceda a __webpack_exports__ desde un paquete webpack usando "nueva función (código)"

Estoy buscando una forma de acceder a las clases dentro de un paquete web compilado después de usar new Function() para ejecutar el paquete.

por ejemplo, tengo

 export class TestClass { constructor() { console.log('Success'); } }

Qué webpack compila para:

 /******/ (() => { // webpackBootstrap /******/ "use strict"; var __webpack_exports__ = {}; // This entry need to be wrapped in an IIFE because it uses a non-standard name for the exports (exports). (() => { var exports = __webpack_exports__; /*!*********************!*\ !*** ./src/test.ts ***! \*********************/ Object.defineProperty(exports, "__esModule", ({ value: true })); exports.TestClass = void 0; class TestClass { constructor() { console.log('Success'); } } exports.TestClass = TestClass; })(); /******/ })() ; //# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsIm1hcHBpbmdzIjoiOzs7Ozs7Ozs7Ozs7QUFBQSxNQUFhLFNBQVM7SUFDbkI7UUFDRyxPQUFPLENBQUMsR0FBRyxDQUFDLFNBQVMsQ0FBQyxDQUFDO0lBQzFCLENBQUM7Q0FDSDtBQUpELDhCQUlDIiwic291cmNlcyI6WyJ3ZWJwYWNrOi8vc3RyYXRlZ3kvc3JjL1VzZXJzL2FkbWluL2NvZGUvYm90bWFpbi9zdHJhdGVneS9zcmMvdGVzdC50cyJdLCJzb3VyY2VzQ29udGVudCI6WyJleHBvcnQgY2xhc3MgVGVzdENsYXNzIHtcbiAgIGNvbnN0cnVjdG9yKCkge1xuICAgICAgY29uc29sZS5sb2coJ1N1Y2Nlc3MnKTtcbiAgIH1cbn0iXSwibmFtZXMiOltdLCJzb3VyY2VSb290IjoiIn0=

Si cargo este paquete desde el sistema de archivos y lo ejecuto usando new Function() , ¿cómo puedo acceder a TestClass ?

Me gustaría hacer algo como:

 const code = await fs.readFile(path, 'utf8') const rawModule = new Function(code)(); const instance = new rawModule.TestClass();

Básicamente necesito acceder a __webpack_exports__ . ¿Hay algún cargador de paquetes web u otra forma en que pueda hacer esto?

about 4 years ago · Juan Pablo Isaza
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!