Skip to content

Commit

Permalink
Merge pull request #98 from aurelia/v2.0-rc2
Browse files Browse the repository at this point in the history
V2.0 rc2
  • Loading branch information
EisenbergEffect authored Mar 31, 2017
2 parents 99f25cd + c86042f commit 1134c3b
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/AureliaDependenciesPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,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: Webpack.MemberExpression) => {
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;
Expand Down
13 changes: 9 additions & 4 deletions src/AureliaPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface Options {
dist: string;
entry?: string | string[];
features: {
ie?: boolean;
svg?: boolean;
unparser?: boolean;
polyfills?: Polyfills;
Expand Down Expand Up @@ -63,6 +64,7 @@ export class AureliaPlugin {
options);

this.options.features = Object.assign({
ie: true,
svg: true,
unparser: true,
polyfills: <"es2015">"es2015",
Expand Down Expand Up @@ -92,6 +94,7 @@ export class AureliaPlugin {
const defines: any = {
AURELIA_WEBPACK_2_0: "true"
};
if (!features.ie) defines.FEATURE_NO_IE = "true";
if (!features.svg) defines.FEATURE_NO_SVG = "true";
if (!features.unparser) defines.FEATURE_NO_UNPARSER = "true";
definePolyfills(defines, features.polyfills!);
Expand Down Expand Up @@ -157,13 +160,15 @@ export 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" });
Expand Down Expand Up @@ -200,9 +205,9 @@ export class AureliaPlugin {
);
}

addEntry(options: Webpack.Options, module: string) {
addEntry(options: Webpack.Options, modules: string|string[]) {
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
Expand Down
5 changes: 4 additions & 1 deletion src/SubFolderPlugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export 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]) { cb(); return; }
// 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; }
let [, module, rest] = match;
// Try resolve just the module name to locate its actual root
let rootRequest = Object.assign({}, request, { request: module });
Expand Down
1 change: 1 addition & 0 deletions src/webpack.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ declare namespace Webpack {
target: string;
module: {
rules?: { test?: RegExp; use: string | string[] }[];
loaders?: { test?: RegExp; use: string | string[] }[]; // same as rules, supported for backward compat with 1.x
};
resolve: {
alias: { [key: string]: string };
Expand Down

0 comments on commit 1134c3b

Please sign in to comment.