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

refactor: update webpack plugins to new plugin system #523

Merged
merged 1 commit into from May 15, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 4 additions & 6 deletions nativescript-target/index.js
Expand Up @@ -9,10 +9,8 @@ module.exports = function nativescriptTarget(compiler) {
const NodeSourcePlugin = require(webpackLib + "/node/NodeSourcePlugin");
const LoaderTargetPlugin = require(webpackLib + "/LoaderTargetPlugin");

compiler.apply(
new NsJsonpTemplatePlugin(options.output),
new FunctionModulePlugin(options.output),
new NodeSourcePlugin(options.node),
new LoaderTargetPlugin("web")
);
new NsJsonpTemplatePlugin(options.output).apply(compiler);
new FunctionModulePlugin(options.output).apply(compiler);
new NodeSourcePlugin(options.node).apply(compiler);
new LoaderTargetPlugin("web").apply(compiler);
}
2 changes: 1 addition & 1 deletion plugins/GenerateBundleStarterPlugin.js
Expand Up @@ -10,7 +10,7 @@ exports.GenerateBundleStarterPlugin = (function() {
GenerateBundleStarterPlugin.prototype.apply = function(compiler) {
this.webpackContext = compiler.options.context;

compiler.plugin("emit", (compilation, cb) => {
compiler.hooks.emit.tapAsync("GenerateBundleStarterPlugin", (compilation, cb) => {
this.addAsset(compilation, "package.json", this.generatePackageJson());
this.addAsset(compilation, "starter.js", this.generateStarterModule());
this.generateTnsJavaClasses(compilation);
Expand Down
2 changes: 1 addition & 1 deletion plugins/NativeScriptAngularCompilerPlugin.ts
Expand Up @@ -66,7 +66,7 @@ module.exports = (projectDir) => {
apply(compiler) {
super.apply(compiler);
if (this.options.platformOptions && this.options.platformOptions.platform && this.options.platformOptions.platforms) {
compiler.plugin('environment', () => {
compiler.hooks.environment.tap("NativeScriptAngularCompilerPlugin", () => {
compiler.inputFileSystem = mapFileSystem({
fs: compiler.inputFileSystem,
context: compiler.context,
Expand Down
2 changes: 1 addition & 1 deletion plugins/NativeScriptSnapshotPlugin/index.js
Expand Up @@ -104,7 +104,7 @@ exports.NativeScriptSnapshotPlugin = (function() {
NativeScriptSnapshotPlugin.prototype.apply = function (compiler) {
const options = this.options;

compiler.plugin("after-emit", function (compilation, callback) {
compiler.hooks.afterEmit.tapAsync("NativeScriptSnapshotPlugin", function (compilation, callback) {
const chunksToSnapshot = options.chunks
.map(name => ({ name, chunk: compilation.chunks.find(chunk => chunk.name === name) }));
const unexistingChunks = chunksToSnapshot.filter(pair => !pair.chunk);
Expand Down
4 changes: 2 additions & 2 deletions plugins/WatchStateLoggerPlugin.ts
Expand Up @@ -13,15 +13,15 @@ export class WatchStateLoggerPlugin {
isRunningWatching: boolean;
apply(compiler) {
const plugin = this;
compiler.plugin("watch-run", function (compiler, callback) {
compiler.hooks.watchRun.tapAsync("WatchStateLoggerPlugin", function (compiler, callback) {
plugin.isRunningWatching = true;
if (plugin.isRunningWatching) {
console.log(messages.changeDetected);
}
process.send && process.send(messages.changeDetected, error => null);
callback();
});
compiler.plugin("after-emit", function (compilation, callback) {
compiler.hooks.afterEmit.tapAsync("WatchStateLoggerPlugin", function (compilation, callback) {
callback();
if (plugin.isRunningWatching) {
console.log(messages.startWatching);
Expand Down