diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js index a8151d1..b1a0a87 100644 --- a/dist/AureliaDependenciesPlugin.js +++ b/dist/AureliaDependenciesPlugin.js @@ -41,10 +41,13 @@ class ParserPlugin { // This covers commonjs modules, for example: // const _aureliaPal = require("aurelia-pal"); // _aureliaPal.PLATFORM.moduleName("id"); + // Or (note: no renaming supported): + // const PLATFORM = require("aurelia-pal").PLATFORM; + // PLATFORM.moduleName("id"); parser.plugin("evaluate MemberExpression", (expr) => { if (expr.property.name === "moduleName" && - expr.object.type === "MemberExpression" && - expr.object.property.name === "PLATFORM") { + (expr.object.type === "MemberExpression" && expr.object.property.name === "PLATFORM" || + expr.object.type === "Identifier" && expr.object.name === "PLATFORM")) { return new BasicEvaluatedExpression().setIdentifier("PLATFORM.moduleName").setRange(expr.range); } return undefined; diff --git a/dist/AureliaPlugin.js b/dist/AureliaPlugin.js index 7e1dd52..09a12a4 100644 --- a/dist/AureliaPlugin.js +++ b/dist/AureliaPlugin.js @@ -35,6 +35,7 @@ class AureliaPlugin { viewsExtensions: ".html", }, options); this.options.features = Object.assign({ + ie: true, svg: true, unparser: true, polyfills: "es2015", @@ -60,6 +61,8 @@ class AureliaPlugin { const defines = { AURELIA_WEBPACK_2_0: "true" }; + if (!features.ie) + defines.FEATURE_NO_IE = "true"; if (!features.svg) defines.FEATURE_NO_SVG = "true"; if (!features.unparser) @@ -120,12 +123,14 @@ class AureliaPlugin { if (!dllPlugin && !opts.noWebpackLoader) { // Setup aurelia-loader-webpack as the module loader // Note that code inside aurelia-loader-webpack performs PLATFORM.Loader = WebpackLoader; - this.addEntry(compiler.options, "aurelia-loader-webpack"); + // Since this runs very early, before any other Aurelia code, we need "aurelia-polyfills" + // for older platforms (e.g. `Map` is undefined in IE 10-). + this.addEntry(compiler.options, ["aurelia-polyfills", "aurelia-loader-webpack"]); } if (!opts.noHtmlLoader) { // Ensure that we trace HTML dependencies (always required because of 3rd party libs) let module = compiler.options.module; - let rules = module.rules || (module.rules = []); + let rules = module.rules || module.loaders || (module.rules = []); // Note that this loader will be in last place, which is important // because it will process the file first, before any other loader. rules.push({ test: /\.html?$/i, use: "aurelia-webpack-plugin/html-requires-loader" }); @@ -157,9 +162,9 @@ class AureliaPlugin { // with aurelia-loader, while still enabling tree shaking all other exports. new PreserveExportsPlugin_1.PreserveExportsPlugin()); } - addEntry(options, module) { + addEntry(options, modules) { let webpackEntry = options.entry; - let entries = [module]; + let entries = Array.isArray(modules) ? modules : [modules]; if (typeof webpackEntry == "object" && !Array.isArray(webpackEntry)) { // There are multiple entries defined in the config // Unless there was a particular configuration, we modify the first one diff --git a/dist/SubFolderPlugin.js b/dist/SubFolderPlugin.js index aafc250..7db337b 100644 --- a/dist/SubFolderPlugin.js +++ b/dist/SubFolderPlugin.js @@ -13,7 +13,10 @@ class SubFolderPlugin { // Only look for request not starting with a dot (module names) // and followed by a path (slash). Support @scoped/modules. let match = /^(?!\.)((?:@[^/]+\/)?[^/]+)(\/.*)$/i.exec(request.request); - if (!match || request.context[subFolderTrial]) { + // Fix: it seems that under some error conditions `request.context` might end up being null. + // this is bad but to help users find relevant errors on the web, we don't want to crash + // so instead we just skip the request. + if (!match || !request.context || request.context[subFolderTrial]) { cb(); return; } diff --git a/dist/types/AureliaPlugin.d.ts b/dist/types/AureliaPlugin.d.ts index 3eb38dc..c3b7b82 100644 --- a/dist/types/AureliaPlugin.d.ts +++ b/dist/types/AureliaPlugin.d.ts @@ -8,6 +8,7 @@ export interface Options { dist: string; entry?: string | string[]; features: { + ie?: boolean; svg?: boolean; unparser?: boolean; polyfills?: Polyfills; @@ -23,5 +24,5 @@ export declare class AureliaPlugin { options: Options; constructor(options?: Partial); apply(compiler: Webpack.Compiler): void; - addEntry(options: Webpack.Options, module: string): void; + addEntry(options: Webpack.Options, modules: string | string[]): void; } diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md index 031e209..86dbe1a 100644 --- a/doc/CHANGELOG.md +++ b/doc/CHANGELOG.md @@ -1,3 +1,16 @@ +## 2.0.0-rc.2 + +### Features + +* flag to opt-out of IE support +* support module.loaders + +### Bug Fixes + +* errors might crash SubFolderPlugin +* compat with IE < 11 +* support more CommonJS import styles + ## 2.0.0-rc.1 Complete re-writer for Webpack 2.2. diff --git a/package.json b/package.json index 8b7eef4..6737687 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "aurelia-webpack-plugin", - "version": "2.0.0-rc.1", + "version": "2.0.0-rc.2", "description": "A plugin for webpack that enables bundling Aurelia applications.", "keywords": [ "aurelia", @@ -45,7 +45,7 @@ "devDependencies": { "@types/minimatch": "^2.0.29", "@types/node": "^7.0.1", - "typescript": "^2.2.1" + "typescript": "^2.2.1" }, "aurelia": { "documentation": {