Skip to content

Commit 99fe0dc

Browse files
chore(all): prepare release 3.0.0-rc.1
1 parent 93f7aff commit 99fe0dc

17 files changed

Lines changed: 71 additions & 59 deletions

dist/AureliaDependenciesPlugin.js

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const IncludeDependency_1 = require("./IncludeDependency");
44
const BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
5+
const TAP_NAME = "Aurelia:Dependencies";
56
class AureliaDependency extends IncludeDependency_1.IncludeDependency {
67
constructor(request, range, options) {
78
super(request, options);
@@ -27,10 +28,11 @@ class ParserPlugin {
2728
// The parser will only apply "call PLATFORM.moduleName" on free variables.
2829
// So we must first trick it into thinking PLATFORM.moduleName is an unbound identifier
2930
// in the various situations where it is not.
31+
const hooks = parser.hooks;
3032
// This covers native ES module, for example:
3133
// import { PLATFORM } from "aurelia-pal";
3234
// PLATFORM.moduleName("id");
33-
parser.plugin("evaluate Identifier imported var.moduleName", (expr) => {
35+
hooks.evaluateIdentifier.tap("imported var.moduleName", TAP_NAME, (expr) => {
3436
if (expr.property.name === "moduleName" &&
3537
expr.object.name === "PLATFORM" &&
3638
expr.object.type === "Identifier") {
@@ -44,7 +46,7 @@ class ParserPlugin {
4446
// Or (note: no renaming supported):
4547
// const PLATFORM = require("aurelia-pal").PLATFORM;
4648
// PLATFORM.moduleName("id");
47-
parser.plugin("evaluate MemberExpression", (expr) => {
49+
hooks.evaluate.tap("MemberExpression", TAP_NAME, expr => {
4850
if (expr.property.name === "moduleName" &&
4951
(expr.object.type === "MemberExpression" && expr.object.property.name === "PLATFORM" ||
5052
expr.object.type === "Identifier" && expr.object.name === "PLATFORM")) {
@@ -53,7 +55,7 @@ class ParserPlugin {
5355
return undefined;
5456
});
5557
for (let method of this.methods) {
56-
parser.plugin("call " + method, (expr) => {
58+
hooks.call.tap(method, TAP_NAME, (expr) => {
5759
if (expr.arguments.length === 0 || expr.arguments.length > 2)
5860
return;
5961
let [arg1, arg2] = expr.arguments;
@@ -109,12 +111,12 @@ class AureliaDependenciesPlugin {
109111
this.parserPlugin = new ParserPlugin(methods);
110112
}
111113
apply(compiler) {
112-
compiler.plugin("compilation", (compilation, params) => {
114+
compiler.hooks.compilation.tap(TAP_NAME, (compilation, params) => {
113115
const normalModuleFactory = params.normalModuleFactory;
114116
compilation.dependencyFactories.set(AureliaDependency, normalModuleFactory);
115117
compilation.dependencyTemplates.set(AureliaDependency, new Template());
116-
normalModuleFactory.plugin("parser", parser => {
117-
parser.apply(this.parserPlugin);
118+
normalModuleFactory.hooks.parser.for("javascript/auto").tap(TAP_NAME, parser => {
119+
this.parserPlugin.apply(parser);
118120
});
119121
});
120122
}

dist/AureliaPlugin.js

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,11 +104,10 @@ class AureliaPlugin {
104104
}
105105
if (opts.includeAll) {
106106
// Grab everything approach
107-
compiler.apply(
108107
// This plugin ensures that everything in /src is included in the bundle.
109108
// This prevents splitting in several chunks but is super easy to use and setup,
110109
// no change in existing code or PLATFORM.nameModule() calls are required.
111-
new GlobDependenciesPlugin_1.GlobDependenciesPlugin({ [emptyEntryModule]: opts.includeAll + "/**" }));
110+
new GlobDependenciesPlugin_1.GlobDependenciesPlugin({ [emptyEntryModule]: opts.includeAll + "/**" }).apply(compiler);
112111
needsEmptyEntry = true;
113112
}
114113
else if (opts.aureliaApp) {
@@ -122,7 +121,7 @@ class AureliaPlugin {
122121
let aureliaModules = dllRefPlugins.map(plugin => {
123122
let content = plugin["options"].manifest.content;
124123
return Object.keys(content)
125-
.map(k => content[k].meta["aurelia-id"])
124+
.map(k => content[k].buildMeta["aurelia-id"])
126125
.filter(id => !!id);
127126
});
128127
globalDependencies = globalDependencies.concat(...aureliaModules);
@@ -140,7 +139,7 @@ class AureliaPlugin {
140139
rules.push({ test: /\.html?$/i, use: "aurelia-webpack-plugin/html-requires-loader" });
141140
}
142141
if (!opts.noInlineView) {
143-
compiler.apply(new InlineViewDependenciesPlugin_1.InlineViewDependenciesPlugin());
142+
new InlineViewDependenciesPlugin_1.InlineViewDependenciesPlugin().apply(compiler);
144143
}
145144
if (globalDependencies.length > 0) {
146145
dependencies[emptyEntryModule] = globalDependencies;
@@ -149,25 +148,24 @@ class AureliaPlugin {
149148
if (needsEmptyEntry) {
150149
this.addEntry(compiler.options, emptyEntryModule);
151150
}
152-
compiler.apply(
153151
// Aurelia libs contain a few global defines to cut out unused features
154-
new webpack_1.DefinePlugin(defines),
152+
new webpack_1.DefinePlugin(defines).apply(compiler);
155153
// Adds some dependencies that are not documented by `PLATFORM.moduleName`
156-
new ModuleDependenciesPlugin_1.ModuleDependenciesPlugin(dependencies),
154+
new ModuleDependenciesPlugin_1.ModuleDependenciesPlugin(dependencies).apply(compiler);
157155
// This plugin traces dependencies in code that are wrapped in PLATFORM.moduleName() calls
158-
new AureliaDependenciesPlugin_1.AureliaDependenciesPlugin(...opts.moduleMethods),
156+
new AureliaDependenciesPlugin_1.AureliaDependenciesPlugin(...opts.moduleMethods).apply(compiler);
159157
// This plugin adds dependencies traced by html-requires-loader
160158
// Note: the config extension point for this one is html-requires-loader.attributes.
161-
new HtmlDependenciesPlugin_1.HtmlDependenciesPlugin(),
159+
new HtmlDependenciesPlugin_1.HtmlDependenciesPlugin().apply(compiler);
162160
// This plugin looks for companion files by swapping extensions,
163161
// e.g. the view of a ViewModel. @useView and co. should use PLATFORM.moduleName().
164162
// We use it always even with `includeAll` because libs often don't `@useView` (they should).
165-
new ConventionDependenciesPlugin_1.ConventionDependenciesPlugin(opts.viewsFor, opts.viewsExtensions),
163+
new ConventionDependenciesPlugin_1.ConventionDependenciesPlugin(opts.viewsFor, opts.viewsExtensions).apply(compiler);
166164
// This plugin preserves module names for dynamic loading by aurelia-loader
167-
new PreserveModuleNamePlugin_1.PreserveModuleNamePlugin(dllPlugin),
165+
new PreserveModuleNamePlugin_1.PreserveModuleNamePlugin(dllPlugin).apply(compiler);
168166
// This plugin supports preserving specific exports names when dynamically loading modules
169167
// with aurelia-loader, while still enabling tree shaking all other exports.
170-
new PreserveExportsPlugin_1.PreserveExportsPlugin());
168+
new PreserveExportsPlugin_1.PreserveExportsPlugin().apply(compiler);
171169
}
172170
addEntry(options, modules) {
173171
let webpackEntry = options.entry;

dist/BaseIncludePlugin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,14 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const IncludeDependency_1 = require("./IncludeDependency");
44
const NullDependency = require("webpack/lib/dependencies/NullDependency");
5+
const TAP_NAME = "Aurelia:BaseInclude";
56
class BaseIncludePlugin {
67
apply(compiler) {
7-
compiler.plugin("compilation", (compilation, data) => {
8+
compiler.hooks.compilation.tap(TAP_NAME, (compilation, data) => {
89
const normalModuleFactory = data.normalModuleFactory;
910
compilation.dependencyFactories.set(IncludeDependency_1.IncludeDependency, normalModuleFactory);
1011
compilation.dependencyTemplates.set(IncludeDependency_1.IncludeDependency, new NullDependency.Template());
11-
normalModuleFactory.plugin("parser", parser => {
12+
normalModuleFactory.hooks.parser.for("javascript/auto").tap(TAP_NAME, parser => {
1213
function addDependency(request) {
1314
let options = typeof request === 'object' ? request : undefined;
1415
let name = options ? options.name : request;

dist/ConventionDependenciesPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ConventionDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin
1919
}
2020
parser(compilation, parser, addDependency) {
2121
const root = path.resolve();
22-
parser.plugin("program", () => {
22+
parser.hooks.program.tap("Aurelia:ConventionDependencies", () => {
2323
const { resource: file, rawRequest } = parser.state.current;
2424
if (!file)
2525
return;

dist/DistPlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
"use strict";
12
// This plugin tries to convert a request containing `/dist/xxx/` to the configured distribution if it exists.
23
// For example new DistPlugin('native-modules') will turn
34
// ./dist/commonjs/aurelia-framework.js
@@ -9,7 +10,6 @@
910
// if the alternate distribution does not exist.
1011
// The alias configuration above will fail the build if a third party lib also uses ./dist/commonjs
1112
// but does not include a ./dist/native-modules
12-
"use strict";
1313
Object.defineProperty(exports, "__esModule", { value: true });
1414
class DistPlugin {
1515
constructor(dist) {
@@ -18,12 +18,13 @@ class DistPlugin {
1818
apply(resolver) {
1919
if (!this.dist)
2020
return;
21-
resolver.plugin("before-described-resolve", (request, cb) => {
21+
resolver.getHook("before-described-resolve")
22+
.tapAsync("Aurelia:Dist", (request, resolveContext, cb) => {
2223
// If the request contains /dist/xxx/, try /dist/{dist}/ first
2324
let rewritten = request.request.replace(/\/dist\/[^/]+\//i, this.dist);
2425
if (rewritten !== request.request) {
2526
let newRequest = Object.assign({}, request, { request: rewritten });
26-
resolver.doResolve("described-resolve", newRequest, "try alternate " + this.dist, cb);
27+
resolver.doResolve(resolver.getHook("described-resolve"), newRequest, "try alternate " + this.dist, {}, cb);
2728
}
2829
else
2930
cb(); // Path does not contain /dist/xxx/, continue normally

dist/GlobDependenciesPlugin.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
44
const minimatch_1 = require("minimatch");
55
const path = require("path");
6+
const TAP_NAME = "Aurelia:GlobDependencies";
67
function* findFiles(root, glob, fs) {
78
// An easiest, naive approach consist of listing all files and then pass them through minimatch.
89
// This is a bad idea as `root` typically includes node_modules, which can contain *lots* of files.
@@ -47,19 +48,17 @@ class GlobDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
4748
const hashKeys = Object.getOwnPropertyNames(this.hash);
4849
if (hashKeys.length === 0)
4950
return;
50-
compiler.plugin("before-compile", (params, cb) => {
51+
compiler.hooks.beforeCompile.tapPromise(TAP_NAME, () => {
5152
// Map the modules passed in ctor to actual resources (files) so that we can
5253
// recognize them no matter what the rawRequest was (loaders, relative paths, etc.)
5354
this.modules = {};
54-
const resolve = compiler.resolvers.normal.resolve.bind(compiler.resolvers.normal, null, this.root);
55-
let countdown = hashKeys.length;
56-
for (let module of hashKeys) {
57-
resolve(module, (err, resource) => {
55+
const resolver = compiler.resolverFactory.get("normal", {});
56+
return Promise.all(hashKeys.map(module => new Promise(resolve => {
57+
resolver.resolve(null, this.root, module, {}, (err, resource) => {
5858
this.modules[resource] = this.hash[module];
59-
if (--countdown === 0)
60-
cb();
59+
resolve();
6160
});
62-
}
61+
})));
6362
});
6463
super.apply(compiler);
6564
}
@@ -70,7 +69,7 @@ class GlobDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
7069
const normalizers = resolveFolders.map(x => path.relative(this.root, x))
7170
.filter(x => !x.startsWith(".."))
7271
.map(x => new RegExp("^" + x + "/", "ig"));
73-
parser.plugin("program", () => {
72+
parser.hooks.program.tap(TAP_NAME, () => {
7473
const globs = this.modules[parser.state.module.resource];
7574
if (!globs)
7675
return;

dist/HtmlDependenciesPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
44
const html_requires_loader_1 = require("./html-requires-loader");
55
class HtmlDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
66
parser(compilation, parser, addDependency) {
7-
parser.plugin("program", () => {
7+
parser.hooks.program.tap("Aurelia:HtmlDependencies", () => {
88
const deps = parser.state.current[html_requires_loader_1.htmlSymbol];
99
if (!deps)
1010
return;

dist/InlineViewDependenciesPlugin.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
55
const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
66
const BasicEvaluatedExpression = require("webpack/lib/BasicEvaluatedExpression");
77
const htmlLoader = require("./html-requires-loader");
8+
const TAP_NAME = "Aurelia:InlineViewDependencies";
89
class InlineViewDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
910
parser(compilation, parser, add) {
1011
// The parser will only apply "call inlineView" on free variables.
@@ -13,7 +14,7 @@ class InlineViewDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin
1314
// This covers native ES module, for example:
1415
// import { inlineView } from "aurelia-framework";
1516
// inlineView("<template>");
16-
parser.plugin("evaluate Identifier imported var", (expr) => {
17+
parser.hooks.evaluateIdentifier.tap("imported var", TAP_NAME, (expr) => {
1718
if (expr.name === "inlineView") {
1819
return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
1920
}
@@ -25,13 +26,13 @@ class InlineViewDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin
2526
// Or (note: no renaming supported):
2627
// const inlineView = require("aurelia-framework").inlineView;
2728
// inlineView("<template>");
28-
parser.plugin("evaluate MemberExpression", (expr) => {
29+
parser.hooks.evaluate.tap("MemberExpression", TAP_NAME, expr => {
2930
if (expr.property.name === "inlineView") {
3031
return new BasicEvaluatedExpression().setIdentifier("inlineView").setRange(expr.range);
3132
}
3233
return undefined;
3334
});
34-
parser.plugin("call inlineView", (expr) => {
35+
parser.hooks.call.tap("inlineView", TAP_NAME, expr => {
3536
if (expr.arguments.length !== 1)
3637
return;
3738
let arg1 = expr.arguments[0];

dist/ModuleDependenciesPlugin.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Object.defineProperty(exports, "__esModule", { value: true });
33
const BaseIncludePlugin_1 = require("./BaseIncludePlugin");
44
const path = require("path");
5+
const TAP_NAME = "Aurelia:ModuleDependencies";
56
;
67
class ModuleDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
78
/**
@@ -29,24 +30,22 @@ class ModuleDependenciesPlugin extends BaseIncludePlugin_1.BaseIncludePlugin {
2930
const hashKeys = Object.getOwnPropertyNames(this.hash);
3031
if (hashKeys.length === 0)
3132
return;
32-
compiler.plugin("before-compile", (params, cb) => {
33+
compiler.hooks.beforeCompile.tapPromise(TAP_NAME, () => {
3334
// Map the modules passed in ctor to actual resources (files) so that we can
3435
// recognize them no matter what the rawRequest was (loaders, relative paths, etc.)
3536
this.modules = {};
36-
const resolve = compiler.resolvers.normal.resolve.bind(compiler.resolvers.normal, null, this.root);
37-
let countdown = hashKeys.length;
38-
for (let module of hashKeys) {
39-
resolve(module, (err, resource) => {
37+
const resolver = compiler.resolverFactory.get("normal", {});
38+
return Promise.all(hashKeys.map(module => new Promise(resolve => {
39+
resolver.resolve(null, this.root, module, {}, (err, resource) => {
4040
this.modules[resource] = this.hash[module];
41-
if (--countdown === 0)
42-
cb();
41+
resolve();
4342
});
44-
}
43+
})));
4544
});
4645
super.apply(compiler);
4746
}
4847
parser(compilation, parser, addDependency) {
49-
parser.plugin("program", () => {
48+
parser.hooks.program.tap(TAP_NAME, () => {
5049
// We try to match the resource, or the initial module request.
5150
const deps = this.modules[parser.state.module.resource];
5251
if (deps)

dist/PreserveExportsPlugin.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
33
exports.dependencyImports = Symbol();
44
const moduleExports = Symbol();
55
const nativeIsUsed = Symbol();
6+
const TAP_NAME = "Aurelia:PreserveExports";
67
function getModuleExports(module) {
78
let set = module[moduleExports];
89
if (!set) {
@@ -18,8 +19,8 @@ function getModuleExports(module) {
1819
}
1920
class PreserveExportsPlugin {
2021
apply(compiler) {
21-
compiler.plugin("compilation", compilation => {
22-
compilation.plugin("finish-modules", modules => {
22+
compiler.hooks.compilation.tap(TAP_NAME, compilation => {
23+
compilation.hooks.finishModules.tap(TAP_NAME, modules => {
2324
for (let module of modules) {
2425
for (let reason of module.reasons) {
2526
let dep = reason.dependency;

0 commit comments

Comments
 (0)