Skip to content

Commit

Permalink
chore(all): prepare release 2.0.0-rc.3
Browse files Browse the repository at this point in the history
  • Loading branch information
EisenbergEffect committed Jul 26, 2017
1 parent 457ee6f commit 37a05b5
Show file tree
Hide file tree
Showing 13 changed files with 119 additions and 24 deletions.
7 changes: 3 additions & 4 deletions dist/AureliaDependenciesPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()))
Expand All @@ -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);
});
}
}
Expand Down
24 changes: 16 additions & 8 deletions dist/AureliaPlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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 = {});
Expand All @@ -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"
Expand Down Expand Up @@ -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.
Expand All @@ -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)
Expand All @@ -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;
Expand Down Expand Up @@ -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";
}
}
Expand Down
3 changes: 2 additions & 1 deletion dist/IncludeDependency.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
52 changes: 52 additions & 0 deletions dist/InlineViewDependenciesPlugin.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// This plugins tries to detect @inlineView('<template>...</template>') 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("<template>");
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("<template>");
// Or (note: no renaming supported):
// const inlineView = require("aurelia-framework").inlineView;
// inlineView("<template>");
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;
11 changes: 10 additions & 1 deletion dist/PreserveModuleNamePlugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
18 changes: 11 additions & 7 deletions dist/html-requires-loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ 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) {
loader.htmlSymbol = _htmlSymbol;
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;
1 change: 1 addition & 0 deletions dist/types/AureliaPlugin.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export interface Options {
polyfills?: Polyfills;
};
noHtmlLoader: boolean;
noInlineView: boolean;
noModulePathResolve: boolean;
noWebpackLoader: boolean;
moduleMethods: string[];
Expand Down
2 changes: 1 addition & 1 deletion dist/types/BaseIncludePlugin.d.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion dist/types/IncludeDependency.d.ts
Original file line number Diff line number Diff line change
@@ -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(): {
Expand Down
4 changes: 4 additions & 0 deletions dist/types/InlineViewDependenciesPlugin.d.ts
Original file line number Diff line number Diff line change
@@ -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;
}
2 changes: 2 additions & 0 deletions dist/types/html-requires-loader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ declare namespace loader {
let attributes: {
"require": string[];
"compose": string[];
"router-view": string[];
};
function modules(html: string): string[];
}
export = loader;
15 changes: 15 additions & 0 deletions doc/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down

0 comments on commit 37a05b5

Please sign in to comment.