I'm using Webpack and Babel to build an Angular1.4 project, written in ECMA6 syntax. I'd like to use ECMAScript 6 import
/export default
module syntax, but sometimes I have to use Webpack loaders, such as expose
to globally expose modules (e.g. jquery, required to be a global object by angular): require("expose?jquery!jquery")
.
Is there a way to write ECMAScript6 imports with Webpack loaders? Something like:
import "expose?jquery!jquery"
I can't mix require()
calls with import
calls, because imports
hoist to the top of the module and break the order of dependency loading. E.g.
require("expose?jquery!jquery);
import angular from "angular";
transpiles to:
var angular = require("angular");
require("expose?jquery!jquery);
which breaks the build, because window.jquery
is required by my Angular directives that expect angular.element
to be full jquery
, not angular's jqLite
.
And require
breaks with modules, exported with exports default
.