Ho eseguito correttamente ReactJS.Net, incluso l'utilizzo della sintassi ES6.ReactJS.net - Come utilizzare i moduli ES6
Sto utilizzando la pipeline di trasformazione Jsx predefinita, che utilizza Babel. Guardando la sorgente nel browser posso vedere che il codice ES6 è stato convertito in ES5 da ReactJS.Net
Non sono riuscito a far funzionare i moduli.
Il browser mi dà 2 errori:
Uncaught ReferenceError: exports is not defined
Uncaught ReferenceError: require is not defined
Come si usa moduli ES6?
esempio più semplice:
Lib.js
export function square(x) {
return x * x;
}
UserOfLib.js
import { square } from 'Lib';
console.log(square(11));
si trasforma a questo (guardando alla fonte del browser):
Lib:
// @hash v3-AD133907ABEC5D32B3768A3AF2301FC9
// Automatically generated by ReactJS.NET. Do not edit, your changes will be overridden.
// Version: 2.0.1 (build 5e9476a)
// Generated at: 08-Nov-15 6:40:26 AM
///////////////////////////////////////////////////////////////////////////////
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.square = square;
function square(x) {
return x * x;
}
UserOfLib:
// @hash v3-812C209AFED25C2B4507E5769B0D899B
// Automatically generated by ReactJS.NET. Do not edit, your changes will be overridden.
// Version: 2.0.1 (build 5e9476a)
// Generated at: 08-Nov-15 6:40:26 AM
///////////////////////////////////////////////////////////////////////////////
var _Lib = require('Lib');
console.log((0, _Lib.square)(11)); // 121
Questi due possono essere utilizzati in combinazione con l'elaborazione JSX? –