Skip to content
This repository was archived by the owner on Aug 7, 2021. It is now read-only.

Commit 87741a1

Browse files
authored
fix: add typescript@~2.0.10 to ng projects (#48)
Required for the StyleUrlResolvePlugin
1 parent be12c23 commit 87741a1

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

Diff for: index.js

+14-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,26 @@ var sources = require("webpack-sources");
22
var fs = require("fs");
33
var path = require("path");
44

5-
exports.StyleUrlResolvePlugin = require('./resource-resolver-plugins/StyleUrlResolvePlugin');
5+
var projectDir = path.dirname(path.dirname(__dirname));
6+
var packageJsonPath = path.join(projectDir, "package.json");
7+
var packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf8"));
8+
9+
var isAngular = Object.keys(packageJson.dependencies).filter(function (dependency) {
10+
return /^@angular\b/.test(dependency);
11+
}).length > 0;
12+
13+
14+
if (isAngular) {
15+
exports.StyleUrlResolvePlugin = require("./resource-resolver-plugins/StyleUrlResolvePlugin");
16+
}
617

718
//HACK: changes the JSONP chunk eval function to `global["nativescriptJsonp"]`
819
// applied to tns-java-classes.js only
920
exports.NativeScriptJsonpPlugin = function(options) {
1021
};
1122

1223
exports.NativeScriptJsonpPlugin.prototype.apply = function (compiler) {
13-
compiler.plugin('compilation', function (compilation, params) {
24+
compiler.plugin("compilation", function (compilation, params) {
1425
compilation.plugin("optimize-chunk-assets", function (chunks, callback) {
1526
chunks.forEach(function (chunk) {
1627
chunk.files.forEach(function (file) {
@@ -38,7 +49,7 @@ exports.GenerateBundleStarterPlugin.prototype = {
3849
var plugin = this;
3950
plugin.webpackContext = compiler.options.context;
4051

41-
compiler.plugin('emit', function (compilation, cb) {
52+
compiler.plugin("emit", function (compilation, cb) {
4253
console.log(" GenerateBundleStarterPlugin: " + plugin.webpackContext);
4354

4455
compilation.assets["package.json"] = plugin.generatePackageJson();

Diff for: postinstall.js

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ configureDevDependencies(packageJson, function (add) {
5555
if (isAngular) {
5656
add("@angular/compiler-cli", "2.3.1");
5757
add("@ngtools/webpack", "1.2.1");
58+
add("typescript", "~2.0.10");
5859
} else {
5960
add("awesome-typescript-loader", "~3.0.0-beta.9");
6061
}

0 commit comments

Comments
 (0)