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

Commit 8ec3b8e

Browse files
authored
refactor: update webpack plugins to new plugin system (#523)
1 parent b48db75 commit 8ec3b8e

File tree

5 files changed

+9
-11
lines changed

5 files changed

+9
-11
lines changed

nativescript-target/index.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,8 @@ module.exports = function nativescriptTarget(compiler) {
99
const NodeSourcePlugin = require(webpackLib + "/node/NodeSourcePlugin");
1010
const LoaderTargetPlugin = require(webpackLib + "/LoaderTargetPlugin");
1111

12-
compiler.apply(
13-
new NsJsonpTemplatePlugin(options.output),
14-
new FunctionModulePlugin(options.output),
15-
new NodeSourcePlugin(options.node),
16-
new LoaderTargetPlugin("web")
17-
);
12+
new NsJsonpTemplatePlugin(options.output).apply(compiler);
13+
new FunctionModulePlugin(options.output).apply(compiler);
14+
new NodeSourcePlugin(options.node).apply(compiler);
15+
new LoaderTargetPlugin("web").apply(compiler);
1816
}

plugins/GenerateBundleStarterPlugin.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ exports.GenerateBundleStarterPlugin = (function() {
1010
GenerateBundleStarterPlugin.prototype.apply = function(compiler) {
1111
this.webpackContext = compiler.options.context;
1212

13-
compiler.plugin("emit", (compilation, cb) => {
13+
compiler.hooks.emit.tapAsync("GenerateBundleStarterPlugin", (compilation, cb) => {
1414
this.addAsset(compilation, "package.json", this.generatePackageJson());
1515
this.addAsset(compilation, "starter.js", this.generateStarterModule());
1616
this.generateTnsJavaClasses(compilation);

plugins/NativeScriptAngularCompilerPlugin.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ module.exports = (projectDir) => {
6666
apply(compiler) {
6767
super.apply(compiler);
6868
if (this.options.platformOptions && this.options.platformOptions.platform && this.options.platformOptions.platforms) {
69-
compiler.plugin('environment', () => {
69+
compiler.hooks.environment.tap("NativeScriptAngularCompilerPlugin", () => {
7070
compiler.inputFileSystem = mapFileSystem({
7171
fs: compiler.inputFileSystem,
7272
context: compiler.context,

plugins/NativeScriptSnapshotPlugin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ exports.NativeScriptSnapshotPlugin = (function() {
104104
NativeScriptSnapshotPlugin.prototype.apply = function (compiler) {
105105
const options = this.options;
106106

107-
compiler.plugin("after-emit", function (compilation, callback) {
107+
compiler.hooks.afterEmit.tapAsync("NativeScriptSnapshotPlugin", function (compilation, callback) {
108108
const chunksToSnapshot = options.chunks
109109
.map(name => ({ name, chunk: compilation.chunks.find(chunk => chunk.name === name) }));
110110
const unexistingChunks = chunksToSnapshot.filter(pair => !pair.chunk);

plugins/WatchStateLoggerPlugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ export class WatchStateLoggerPlugin {
1313
isRunningWatching: boolean;
1414
apply(compiler) {
1515
const plugin = this;
16-
compiler.plugin("watch-run", function (compiler, callback) {
16+
compiler.hooks.watchRun.tapAsync("WatchStateLoggerPlugin", function (compiler, callback) {
1717
plugin.isRunningWatching = true;
1818
if (plugin.isRunningWatching) {
1919
console.log(messages.changeDetected);
2020
}
2121
process.send && process.send(messages.changeDetected, error => null);
2222
callback();
2323
});
24-
compiler.plugin("after-emit", function (compilation, callback) {
24+
compiler.hooks.afterEmit.tapAsync("WatchStateLoggerPlugin", function (compilation, callback) {
2525
callback();
2626
if (plugin.isRunningWatching) {
2727
console.log(messages.startWatching);

0 commit comments

Comments
 (0)