Click here to Skip to main content
15,905,508 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I'm trying to implement a demo application where I want to use some code written in ES6
Module syntax format in a CommonJS style module format.

I have configured the babel-loader and presets, but can't seem to get it working.

//ES6 code
export default function(a) {
	console.log("The value passed is " + a);
	
};


//CommonJs style module.
var mod = require('./es6_lib'); 
module.exports = function SomeFunction(a,b){
	document.write(mod('hello'));
	//alert('iftikhares6libinstance' + req("Hello"));
         return;
};


I'm able to compile the whole thing using webpack with babel-loader for ES6. However, in the browser, I get the error req is not a function.

What I have tried:

Specified Babel loader configuration in webpack.config.j
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900