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("