This is not a duplicate of below questions which is dealing with browser specific questions. I'm expecting an answer whether
import / export
will work in Client side or not.
- ECMA 6 Not working although experimental js is enabled
- how export variable in ES6 in Chrome/Firefox?
//lib.js
export const sqrt = Math.sqrt;
export function square(x) {
return x * x;
}
export function diag(x, y) {
return sqrt(square(x) + square(y));
}
//main.js
"use strict";
import { square, diag } from 'lib';
console.log(square(11)); // 121
console.log(diag(4, 3)); // 5
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Import Check</title>
</head>
<body>
<script type="text/javascript" src="main.js"></script>
</body>
</html>
Error that I'm getting in Chrome:
![]()
Tested Browser: Google Chrome Version 47.0.2526.106
- Is that possible to make the code working in any browser or not ?
- Lets say, we have chosen one transpiler (
BabelJS
) and code got transpiled. Will theimport
/export
file code snippet will work in the Client side or Server side (In node Server as require method)?