Concepts of module in JavaScript
First: require / exports.module
Second: import / export
Why does Babel.js convert the second module Concept (import / export) to the first module Concept (require / module.exports)?
I‘m using babel.js to be able to use the es6 feature but when i use the (import / export) it will be converted to (require / exports.module) so i have to use a another plugin in babel.js although browsers support (import /export).
Example:
in src/Validator.js i have
export class Validator {}
in src/update.js i have
import Validator from 'Validator';
what babel.js does:
In public/ Validator
exports.Validator=Validator;
in public/update.js
require("Validator")
so of course it wouldn't work because i need plugin like commonJs.
Babel.js should help me to use the es6 feautres, that not support in the browsers but like i said browsers support (import /export).
What i have understood that babel.js is responsible for Browsers and not for Node.js.
No responses yet.