diff --git a/packages/webpack5/src/configuration/base.ts b/packages/webpack5/src/configuration/base.ts index f9b408863..2350782d2 100644 --- a/packages/webpack5/src/configuration/base.ts +++ b/packages/webpack5/src/configuration/base.ts @@ -7,7 +7,6 @@ import FilterWarningsPlugin from 'webpack-filter-warnings-plugin'; import { BundleAnalyzerPlugin } from 'webpack-bundle-analyzer'; import TerserPlugin from 'terser-webpack-plugin'; -// import { WatchStateLoggerPlugin } from '../plugins/WatchStateLoggerPlugin'; import { getProjectFilePath, getProjectRootPath } from '../helpers/project'; import { PlatformSuffixPlugin } from '../plugins/PlatformSuffixPlugin'; import { addCopyRule, applyCopyRules } from '../helpers/copyRules'; @@ -308,8 +307,6 @@ export default function (config: Config, env: IWebpackEnv = _env): Config { applyCopyRules(config); - // add the WatchStateLogger plugin used to notify the CLI of build state - // config.plugin('WatchStateLoggerPlugin').use(WatchStateLoggerPlugin); config.plugin('WatchStatePlugin').use(WatchStatePlugin); config.when(env.hmr, (config) => { diff --git a/packages/webpack5/src/loaders/nativescript-hot-loader/hmr.runtime.ts b/packages/webpack5/src/loaders/nativescript-hot-loader/hmr.runtime.ts index 7a5e8a020..3c612c1fe 100644 --- a/packages/webpack5/src/loaders/nativescript-hot-loader/hmr.runtime.ts +++ b/packages/webpack5/src/loaders/nativescript-hot-loader/hmr.runtime.ts @@ -1,6 +1,7 @@ // @ts-nocheck // This is a runtime module - included by nativescript-hot-loader // this file should not include external dependencies +// todo: add verbose logs when enabled // --- if (module.hot) { diff --git a/packages/webpack5/src/platforms/ios.ts b/packages/webpack5/src/platforms/ios.ts index 8f8896ab5..dd2d3defb 100644 --- a/packages/webpack5/src/platforms/ios.ts +++ b/packages/webpack5/src/platforms/ios.ts @@ -4,10 +4,9 @@ import { INativeScriptPlatform } from "../helpers/platform"; import { getProjectRootPath } from "../helpers/project"; function sanitizeName(appName: string): string { - const sanitizedName = appName.split("").filter((c) => + return appName.split("").filter((c) => /[a-zA-Z0-9]/.test(c) ).join(""); - return sanitizedName; } function getDistPath() { const appName = sanitizeName(basename(getProjectRootPath())); diff --git a/packages/webpack5/src/plugins/WatchStateLoggerPlugin.ts b/packages/webpack5/src/plugins/WatchStateLoggerPlugin.ts deleted file mode 100644 index 78c9a19e0..000000000 --- a/packages/webpack5/src/plugins/WatchStateLoggerPlugin.ts +++ /dev/null @@ -1,83 +0,0 @@ -import webpack from 'webpack'; - -const id = 'WatchStateLoggerPlugin'; - -export enum messages { - compilationComplete = 'Webpack compilation complete.', - startWatching = 'Webpack compilation complete. Watching for file changes.', - changeDetected = 'File change detected. Starting incremental webpack compilation...', -} - -/** - * This little plugin will report the webpack state through the console. - * So the {N} CLI can get some idea when compilation completes. - * @deprecated todo: remove soon - */ -export class WatchStateLoggerPlugin { - isRunningWatching: boolean; - - apply(compiler) { - const plugin = this; - - compiler.hooks.watchRun.tapAsync(id, function (compiler, callback) { - plugin.isRunningWatching = true; - - if (plugin.isRunningWatching) { - console.log(messages.changeDetected); - } - - notify(messages.changeDetected); - - callback(); - }); - - compiler.hooks.afterEmit.tapAsync(id, function (compilation, callback) { - callback(); - - if (plugin.isRunningWatching) { - console.log(messages.startWatching); - } else { - console.log(messages.compilationComplete); - } - - const emittedFiles = Array.from(compilation.emittedAssets); - const chunkFiles = getChunkFiles(compilation); - - notify(messages.compilationComplete); - - // Send emitted files so they can be LiveSynced if need be - notify({ emittedFiles, chunkFiles, hash: compilation.hash }); - }); - } -} - -function getChunkFiles(compilation: webpack.Compilation) { - const chunkFiles = []; - try { - compilation.chunks.forEach((chunk) => { - chunk.files.forEach((file) => { - if (file.indexOf('hot-update') === -1) { - chunkFiles.push(file); - } - }); - }); - } catch (e) { - console.log('Warning: Unable to find chunk files.'); - } - - return chunkFiles; -} - -function notify(message: any) { - if (!process.send) { - return; - } - - process.send(message, (error) => { - if (error) { - console.error(`[${id}] Process Send Error: `, error); - } - - return null; - }); -} diff --git a/packages/webpack5/src/plugins/WatchStatePlugin.ts b/packages/webpack5/src/plugins/WatchStatePlugin.ts index 06ca2a869..a87b77c5f 100644 --- a/packages/webpack5/src/plugins/WatchStatePlugin.ts +++ b/packages/webpack5/src/plugins/WatchStatePlugin.ts @@ -9,8 +9,8 @@ export enum messages { } /** - * This little plugin will report the webpack state through the console. - * So the {N} CLI can get some idea when compilation completes. + * This little plugin will report the webpack state through the console + * and send status updates through IPC to the {N} CLI. */ export class WatchStatePlugin { apply(compiler: any) {