Open gnestor opened 7 years ago
This is the result of how babel
transpiles import
statements. E.g.:
var uuid = require('uuid');
uuid.v4();
import v4 from 'uuid';
v4();
transpiles into:
'use strict';
var _uuid = require('uuid');
var _uuid2 = _interopRequireDefault(_uuid);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var uuid = require('uuid');
uuid.v4();
(0, _uuid2.default)();
I don't know how easy it'd be to override these transpilation rules.
@n-riesco I don't really understand the difference here between compiled require
and compiled import
... import
doesn't involve a _interopRequireDefault
?
@gnestor More on this issue: if understand correctly, babel
transpiles import
statements like this to allow a new magic feature in ES6 called import binding (see an interesting discussion about import binding here).
The immediate consequence (to jp-babel
) is that execution cells must include all the import statements used by the code in the execution cell.
the biggest difference is the __default
property being utilized. @gnestor
If imported modules are referenced outside of the cells where they're imported, they're
undefined
: