diff --git a/dist/AureliaDependenciesPlugin.js b/dist/AureliaDependenciesPlugin.js
index b1a0a87..2f63d66 100644
--- a/dist/AureliaDependenciesPlugin.js
+++ b/dist/AureliaDependenciesPlugin.js
@@ -65,13 +65,12 @@ class ParserPlugin {
// PLATFORM.moduleName('some-module')
return addDependency(param1.string, expr.range);
}
- let chunk;
let options;
let param2 = parser.evaluateExpression(arg2);
if (param2.isString()) {
// Async module dependency
// PLATFORM.moduleName('some-module', 'chunk name');
- chunk = param2.string;
+ options = { chunk: param2.string };
}
else if (arg2.type === "ObjectExpression") {
// Module dependency with extended options
@@ -84,7 +83,7 @@ class ParserPlugin {
switch (prop.key.name) {
case "chunk":
if (value.isString())
- chunk = value.string;
+ options.chunk = value.string;
break;
case "exports":
if (value.isArray() && value.items.every(v => v.isString()))
@@ -97,7 +96,7 @@ class ParserPlugin {
// Unknown PLATFORM.moduleName() signature
return;
}
- return addDependency(chunk ? `async?lazy&name=${chunk}!${param1.string}` : param1.string, expr.range, options);
+ return addDependency(param1.string, expr.range, options);
});
}
}
diff --git a/dist/AureliaPlugin.js b/dist/AureliaPlugin.js
index 09a12a4..8374236 100644
--- a/dist/AureliaPlugin.js
+++ b/dist/AureliaPlugin.js
@@ -6,22 +6,24 @@ const ConventionDependenciesPlugin_1 = require("./ConventionDependenciesPlugin")
const DistPlugin_1 = require("./DistPlugin");
const GlobDependenciesPlugin_1 = require("./GlobDependenciesPlugin");
const HtmlDependenciesPlugin_1 = require("./HtmlDependenciesPlugin");
+const InlineViewDependenciesPlugin_1 = require("./InlineViewDependenciesPlugin");
const ModuleDependenciesPlugin_1 = require("./ModuleDependenciesPlugin");
const PreserveExportsPlugin_1 = require("./PreserveExportsPlugin");
const PreserveModuleNamePlugin_1 = require("./PreserveModuleNamePlugin");
const SubFolderPlugin_1 = require("./SubFolderPlugin");
// See comments inside the module to understand why this is used
-const emptyEntryModule = "aurelia-webpack-plugin/dist/aurelia-entry";
+const emptyEntryModule = "aurelia-webpack-plugin/runtime/empty-entry";
class AureliaPlugin {
constructor(options = {}) {
this.options = Object.assign({
includeAll: false,
- aureliaApp: "main",
aureliaConfig: ["standard", "developmentLogging"],
dist: "native-modules",
features: {},
moduleMethods: [],
noHtmlLoader: false,
+ // Undocumented safety switch
+ noInlineView: false,
noModulePathResolve: false,
noWebpackLoader: false,
// Ideally we would like _not_ to process conventions in node_modules,
@@ -45,6 +47,8 @@ class AureliaPlugin {
const opts = this.options;
const features = opts.features;
let needsEmptyEntry = false;
+ let dllPlugin = compiler.options.plugins.some(p => p instanceof webpack_1.DllPlugin);
+ let dllRefPlugins = compiler.options.plugins.filter(p => p instanceof webpack_1.DllReferencePlugin);
// Make sure the loaders are easy to load at the root like `aurelia-webpack-plugin/html-resource-loader`
let resolveLoader = compiler.options.resolveLoader;
let alias = resolveLoader.alias || (resolveLoader.alias = {});
@@ -57,6 +61,11 @@ class AureliaPlugin {
resolveLoader.symlinks = false;
compiler.options.resolve.symlinks = false;
}
+ // If we aren't building a DLL, "main" is the default entry point
+ // Note that the 'in' check is because someone may explicitly set aureliaApp to undefined
+ if (!dllPlugin && !("aureliaApp" in opts)) {
+ opts.aureliaApp = "main";
+ }
// Uses DefinePlugin to cut out optional features
const defines = {
AURELIA_WEBPACK_2_0: "true"
@@ -107,8 +116,6 @@ class AureliaPlugin {
// When using includeAll, we assume it's already included
globalDependencies.push({ name: opts.aureliaApp, exports: ["configure"] });
}
- let dllPlugin = compiler.options.plugins.some(p => p instanceof webpack_1.DllPlugin);
- let dllRefPlugins = compiler.options.plugins.filter(p => p instanceof webpack_1.DllReferencePlugin);
if (!dllPlugin && dllRefPlugins.length > 0) {
// Creates delegated entries for all Aurelia modules in DLLs.
// This is required for aurelia-loader-webpack to find them.
@@ -122,10 +129,7 @@ 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;
- // 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"]);
+ this.addEntry(compiler.options, ["aurelia-webpack-plugin/runtime/pal-loader-entry"]);
}
if (!opts.noHtmlLoader) {
// Ensure that we trace HTML dependencies (always required because of 3rd party libs)
@@ -135,6 +139,9 @@ class AureliaPlugin {
// because it will process the file first, before any other loader.
rules.push({ test: /\.html?$/i, use: "aurelia-webpack-plugin/html-requires-loader" });
}
+ if (!opts.noInlineView) {
+ compiler.apply(new InlineViewDependenciesPlugin_1.InlineViewDependenciesPlugin());
+ }
if (globalDependencies.length > 0) {
dependencies[emptyEntryModule] = globalDependencies;
needsEmptyEntry = true;
@@ -186,6 +193,7 @@ function getPAL(target) {
switch (target) {
case "web": return "aurelia-pal-browser";
case "webworker": return "aurelia-pal-worker";
+ case "electron-renderer": return "aurelia-pal-browser";
default: return "aurelia-pal-nodejs";
}
}
diff --git a/dist/IncludeDependency.js b/dist/IncludeDependency.js
index 0403ffa..b7636a5 100644
--- a/dist/IncludeDependency.js
+++ b/dist/IncludeDependency.js
@@ -6,7 +6,8 @@ const ModuleDependency = require("webpack/lib/dependencies/ModuleDependency");
const NullDependency = require("webpack/lib/dependencies/NullDependency");
class IncludeDependency extends ModuleDependency {
constructor(request, options) {
- super(request);
+ let chunk = options && options.chunk;
+ super(chunk ? `async?lazy&name=${chunk}!${request}` : request);
this.options = options;
}
get type() {
diff --git a/dist/InlineViewDependenciesPlugin.js b/dist/InlineViewDependenciesPlugin.js
new file mode 100644
index 0000000..09548a5
--- /dev/null
+++ b/dist/InlineViewDependenciesPlugin.js
@@ -0,0 +1,52 @@
+"use strict";
+Object.defineProperty(exports, "__esModule", { value: true });
+// This plugins tries to detect @inlineView('...') and process its dependencies
+// like HtmlDependenciesPlugin does.
+const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
+const BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
+const htmlLoader = require("./html-requires-loader");
+class InlineViewDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
+ parser(compilation, parser, add) {
+ // The parser will only apply "call inlineView" on free variables.
+ // So we must first trick it into thinking inlineView is an unbound identifier
+ // in the various situations where it is not.
+ // This covers native ES module, for example:
+ // import { inlineView } from "aurelia-framework";
+ // inlineView("");
+ parser.plugin("evaluate Identifier imported var", (expr) => {
+ if (expr.name === "inlineView") {
+ return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
+ }
+ return undefined;
+ });
+ // This covers commonjs modules, for example:
+ // const _aurelia = require("aurelia-framework");
+ // _aurelia.inlineView("");
+ // Or (note: no renaming supported):
+ // const inlineView = require("aurelia-framework").inlineView;
+ // inlineView("");
+ parser.plugin("evaluate MemberExpression", (expr) => {
+ if (expr.property.name === "inlineView") {
+ return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
+ }
+ return undefined;
+ });
+ parser.plugin("call inlineView", (expr) => {
+ if (expr.arguments.length !== 1)
+ return;
+ let arg1 = expr.arguments[0];
+ let param1 = parser.evaluateExpression(arg1);
+ if (!param1.isString())
+ return;
+ let modules;
+ try {
+ modules = htmlLoader.modules(param1.string);
+ }
+ catch (e) {
+ return;
+ }
+ modules.forEach(add);
+ });
+ }
+}
+exports.InlineViewDependenciesPlugin = InlineViewDependenciesPlugin;
diff --git a/dist/PreserveModuleNamePlugin.js b/dist/PreserveModuleNamePlugin.js
index bd6a6bb..8194204 100644
--- a/dist/PreserveModuleNamePlugin.js
+++ b/dist/PreserveModuleNamePlugin.js
@@ -17,12 +17,21 @@ class PreserveModuleNamePlugin {
let { modules: roots, extensions, alias } = compilation.options.resolve;
roots = roots.map(x => path.resolve(x));
const normalizers = extensions.map(x => new RegExp(x.replace(/\./g, "\\.") + "$", "i"));
+ // ModuleConcatenationPlugin merges modules into new ConcatenatedModule
+ let modulesBeforeConcat = modules.slice();
+ for (let i = 0; i < modulesBeforeConcat.length; i++) {
+ let m = modulesBeforeConcat[i];
+ // We don't `import ConcatenatedModule` and then `m instanceof ConcatenatedModule`
+ // because it was introduced in Webpack 3.0 and we're still compatible with 2.x at the moment.
+ if (m.constructor.name === "ConcatenatedModule")
+ modulesBeforeConcat.splice(i--, 1, ...m["modules"]);
+ }
for (let module of getPreservedModules(modules)) {
let preserve = module[exports.preserveModuleName];
let id = typeof preserve === "string" ? preserve : null;
// No absolute request to preserve, we try to normalize the module resource
if (!id && module.resource)
- id = fixNodeModule(module, modules) ||
+ id = fixNodeModule(module, modulesBeforeConcat) ||
makeModuleRelative(roots, module.resource) ||
aliasRelative(alias, module.resource);
if (!id)
diff --git a/dist/html-requires-loader.js b/dist/html-requires-loader.js
index 6aa24c5..756c8b8 100644
--- a/dist/html-requires-loader.js
+++ b/dist/html-requires-loader.js
@@ -3,13 +3,7 @@ const parse = require("html-loader/lib/attributesParser");
const _htmlSymbol = Symbol("HTML dependencies");
function loader(content) {
this.cacheable && this.cacheable();
- this._module[_htmlSymbol] =
- parse(content, (tag, attr) => {
- const attrs = loader.attributes[tag];
- return attrs && attrs.includes(attr);
- })
- .filter(attr => !/(^|[^\\])\$\{/.test(attr.value))
- .map(attr => attr.value);
+ this._module[_htmlSymbol] = loader.modules(content);
return content;
}
(function (loader) {
@@ -17,6 +11,16 @@ function loader(content) {
loader.attributes = {
"require": ["from"],
"compose": ["view", "view-model"],
+ "router-view": ["layout-view", "layout-view-model"],
};
+ function modules(html) {
+ return parse(html, (tag, attr) => {
+ const attrs = loader.attributes[tag];
+ return attrs && attrs.includes(attr);
+ })
+ .filter(attr => !/(^|[^\\])\$\{/.test(attr.value))
+ .map(attr => attr.value);
+ }
+ loader.modules = modules;
})(loader || (loader = {}));
module.exports = loader;
diff --git a/dist/types/AureliaPlugin.d.ts b/dist/types/AureliaPlugin.d.ts
index c3b7b82..109ee64 100644
--- a/dist/types/AureliaPlugin.d.ts
+++ b/dist/types/AureliaPlugin.d.ts
@@ -14,6 +14,7 @@ export interface Options {
polyfills?: Polyfills;
};
noHtmlLoader: boolean;
+ noInlineView: boolean;
noModulePathResolve: boolean;
noWebpackLoader: boolean;
moduleMethods: string[];
diff --git a/dist/types/BaseIncludePlugin.d.ts b/dist/types/BaseIncludePlugin.d.ts
index 66ba25a..88ebb80 100644
--- a/dist/types/BaseIncludePlugin.d.ts
+++ b/dist/types/BaseIncludePlugin.d.ts
@@ -1,4 +1,4 @@
-export declare type AddDependency = (request: string, options?: DependencyOptions) => void;
+export declare type AddDependency = (request: string | DependencyOptionsEx) => void;
export declare class BaseIncludePlugin {
apply(compiler: Webpack.Compiler): void;
parser(compilation: Webpack.Compilation, parser: Webpack.Parser, add: AddDependency): void;
diff --git a/dist/types/IncludeDependency.d.ts b/dist/types/IncludeDependency.d.ts
index 00e93a0..ac0115a 100644
--- a/dist/types/IncludeDependency.d.ts
+++ b/dist/types/IncludeDependency.d.ts
@@ -1,7 +1,7 @@
import ModuleDependency = require("webpack/lib/dependencies/ModuleDependency");
import NullDependency = require("webpack/lib/dependencies/NullDependency");
export declare class IncludeDependency extends ModuleDependency {
- private options;
+ private options?;
constructor(request: string, options?: DependencyOptions);
readonly type: string;
getReference(): {
diff --git a/dist/types/InlineViewDependenciesPlugin.d.ts b/dist/types/InlineViewDependenciesPlugin.d.ts
new file mode 100644
index 0000000..fee57d7
--- /dev/null
+++ b/dist/types/InlineViewDependenciesPlugin.d.ts
@@ -0,0 +1,4 @@
+import { BaseIncludePlugin, AddDependency } from "./BaseIncludePlugin";
+export declare class InlineViewDependenciesPlugin extends BaseIncludePlugin {
+ parser(compilation: Webpack.Compilation, parser: Webpack.Parser, add: AddDependency): void;
+}
diff --git a/dist/types/html-requires-loader.d.ts b/dist/types/html-requires-loader.d.ts
index 8ac45c7..a377f15 100644
--- a/dist/types/html-requires-loader.d.ts
+++ b/dist/types/html-requires-loader.d.ts
@@ -4,6 +4,8 @@ declare namespace loader {
let attributes: {
"require": string[];
"compose": string[];
+ "router-view": string[];
};
+ function modules(html: string): string[];
}
export = loader;
diff --git a/doc/CHANGELOG.md b/doc/CHANGELOG.md
index 86dbe1a..5025461 100644
--- a/doc/CHANGELOG.md
+++ b/doc/CHANGELOG.md
@@ -1,3 +1,18 @@
+## 2.0.0-rc.3
+
+### Features
+
+* support Webpack 3 ModuleConcatenationPlugin
+* support resources inside @inlineView
+
+### Bug Fixes
+
+* recognize router-view attributes
+* better control over entry sequence
+* chunk not supported by ModuleDependenciesPlugin
+* no default entrypoint with DLLPlugin
+* use browser-pal for electron-renderer (#100)
+
## 2.0.0-rc.2
### Features
diff --git a/package.json b/package.json
index 7606625..81b992c 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "aurelia-webpack-plugin",
- "version": "2.0.0-rc.2",
+ "version": "2.0.0-rc.3",
"description": "A plugin for webpack that enables bundling Aurelia applications.",
"keywords": [
"aurelia",