From fc5fb58c856d9506ea2d55cf4f9855d259040411 Mon Sep 17 00:00:00 2001 From: Pooya Parsa Date: Sat, 8 May 2021 22:35:27 +0200 Subject: [PATCH] hotfix: revert feat additions - 380ffb6481ad9c4f68b7d0a4927bd61aaf27a9e7 - 4d8077f8fee5b1ded6cb9eb557274580a3d8932d - 2ec62617ced873fef97c73a6d7aa1271911ccfd --- packages/config/src/config/generate.js | 1 - .../test/__snapshots__/options.test.js.snap | 1 - .../config/__snapshots__/index.test.js.snap | 2 - packages/generator/src/generator.js | 6 +- .../generator/test/generator.init.test.js | 1 - packages/types/config/generate.d.ts | 1 - packages/types/config/module.d.ts | 39 +----- packages/webpack/package.json | 1 - packages/webpack/src/config/base.js | 3 - packages/webpack/src/plugins/watchpack.js | 116 ------------------ yarn.lock | 13 -- 11 files changed, 4 insertions(+), 180 deletions(-) delete mode 100644 packages/webpack/src/plugins/watchpack.js diff --git a/packages/config/src/config/generate.js b/packages/config/src/config/generate.js index 76ad961f135d..4aa33eb1cf07 100644 --- a/packages/config/src/config/generate.js +++ b/packages/config/src/config/generate.js @@ -8,7 +8,6 @@ export default () => ({ fallback: '200.html', crawler: true, manifest: true, - nojekyll: true, cache: { ignore: [], globbyOptions: { diff --git a/packages/config/test/__snapshots__/options.test.js.snap b/packages/config/test/__snapshots__/options.test.js.snap index 44e21c60ef3f..dad432b2ed6e 100644 --- a/packages/config/test/__snapshots__/options.test.js.snap +++ b/packages/config/test/__snapshots__/options.test.js.snap @@ -221,7 +221,6 @@ Object { "fallback": "200.html", "interval": 0, "manifest": true, - "nojekyll": true, "routes": Array [], "staticAssets": Object { "base": "/_nuxt/static", diff --git a/packages/config/test/config/__snapshots__/index.test.js.snap b/packages/config/test/config/__snapshots__/index.test.js.snap index 46d9e806c4a5..6705cc2f5bec 100644 --- a/packages/config/test/config/__snapshots__/index.test.js.snap +++ b/packages/config/test/config/__snapshots__/index.test.js.snap @@ -196,7 +196,6 @@ Object { "fallback": "200.html", "interval": 0, "manifest": true, - "nojekyll": true, "routes": Array [], "staticAssets": Object { "base": undefined, @@ -585,7 +584,6 @@ Object { "fallback": "200.html", "interval": 0, "manifest": true, - "nojekyll": true, "routes": Array [], "staticAssets": Object { "base": undefined, diff --git a/packages/generator/src/generator.js b/packages/generator/src/generator.js index 7147e7713b21..6fe8bc61a01b 100644 --- a/packages/generator/src/generator.js +++ b/packages/generator/src/generator.js @@ -267,10 +267,8 @@ export default class Generator { // Add .nojekyll file to let GitHub Pages add the _nuxt/ folder // https://help.github.com/articles/files-that-start-with-an-underscore-are-missing/ - if (this.options.generate.nojekyll) { - const nojekyllPath = path.resolve(this.distPath, '.nojekyll') - await fsExtra.writeFile(nojekyllPath, '') - } + const nojekyllPath = path.resolve(this.distPath, '.nojekyll') + await fsExtra.writeFile(nojekyllPath, '') await this.nuxt.callHook('generate:distCopied', this) await this.nuxt.callHook('export:distCopied', this) diff --git a/packages/generator/test/generator.init.test.js b/packages/generator/test/generator.init.test.js index e2c977f61612..4f130e74e1a4 100644 --- a/packages/generator/test/generator.init.test.js +++ b/packages/generator/test/generator.init.test.js @@ -182,7 +182,6 @@ describe('generator: initialize', () => { test('should initialize destination folder', async () => { const nuxt = createNuxt() nuxt.options.generate.fallback = 'fallback.html' - nuxt.options.generate.nojekyll = true const generator = new Generator(nuxt) fsExtra.exists.mockReturnValueOnce(false) diff --git a/packages/types/config/generate.d.ts b/packages/types/config/generate.d.ts index c5e90b5057e9..72153abba29c 100644 --- a/packages/types/config/generate.d.ts +++ b/packages/types/config/generate.d.ts @@ -18,7 +18,6 @@ export interface NuxtOptionsGenerate { exclude?: RegExp[] fallback?: string | boolean interval?: number - nojekyll?: boolean routes?: NuxtOptionsGenerateRoute[] | NuxtOptionsGenerateRoutesFunction | NuxtOptionsGenerateRoutesFunctionWithCallback subFolders?: boolean cache?: false | { diff --git a/packages/types/config/module.d.ts b/packages/types/config/module.d.ts index c60245b6bfe1..fb97c8f1de8d 100644 --- a/packages/types/config/module.d.ts +++ b/packages/types/config/module.d.ts @@ -6,8 +6,6 @@ import { Configuration as WebpackConfiguration } from 'webpack' import { NuxtOptionsLoaders } from './build' -import { NuxtRouteConfig } from './router' -import { NuxtOptionsServerMiddleware } from './server-middleware' import { NuxtOptions } from '.' interface ExtendFunctionContext { @@ -19,43 +17,10 @@ interface ExtendFunctionContext { loaders: NuxtOptionsLoaders } -export interface ModuleTemplateConfig { - src: string, - fileName?: string - filename?: string - options?: Record - [key: string]: any -} - -export interface ModulePluginTemplateConfig extends ModuleTemplateConfig { - ssr?: boolean - mode?: 'all' | 'client' | 'server' -} - -export interface ModuleTemplateDest { - src: string - dst: string - options?: Record -} - -export type ModuleTemplate = ModuleTemplateConfig | string -export type ModulePluginTemplate = ModulePluginTemplateConfig | string - -type ExtendRoutesFunction = (routes: NuxtRouteConfig[], resolve: (...pathSegments: string[]) => string) => void -type ExtendBuildFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void +type ExtendFunction = (config: WebpackConfiguration, ctx: ExtendFunctionContext) => void interface ModuleThis { - addTemplate(template: ModuleTemplate): ModuleTemplateDest - addPlugin(template: ModulePluginTemplate): void - addLayout(template: ModuleTemplate, name?: string): void - addErrorLayout (dst: string): void - addServerMiddleware (middleware: NuxtOptionsServerMiddleware): void - extendBuild(fn: ExtendBuildFunction): void - extendRoutes(fn: ExtendRoutesFunction): void - // eslint-disable-next-line no-use-before-define - requireModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise - // eslint-disable-next-line no-use-before-define - addModule (moduleOpts: NuxtOptionsModule, paths?: string[]): Promise + extendBuild(fn: ExtendFunction): void options: NuxtOptions nuxt: any // TBD [key: string]: any // TBD diff --git a/packages/webpack/package.json b/packages/webpack/package.json index d6937aab2c6a..3d99481510ed 100644 --- a/packages/webpack/package.json +++ b/packages/webpack/package.json @@ -47,7 +47,6 @@ "vue-loader": "^15.9.7", "vue-style-loader": "^4.1.3", "vue-template-compiler": "^2.6.12", - "watchpack": "^2.1.1", "webpack": "^4.46.0", "webpack-bundle-analyzer": "^4.4.1", "webpack-dev-middleware": "^4.2.0", diff --git a/packages/webpack/src/config/base.js b/packages/webpack/src/config/base.js index eedf61600a84..551b85afc5a2 100644 --- a/packages/webpack/src/config/base.js +++ b/packages/webpack/src/config/base.js @@ -17,7 +17,6 @@ import { TARGETS, isUrl, urlJoin, getPKG, tryResolve, requireModule, resolveModu import PerfLoader from '../utils/perf-loader' import StyleLoader from '../utils/style-loader' import WarningIgnorePlugin from '../plugins/warning-ignore' -import { Watchpack2Plugin } from '../plugins/watchpack' import { reservedVueTags } from '../utils/reserved-tags' export default class WebpackBaseConfig { @@ -479,8 +478,6 @@ export default class WebpackBaseConfig { })) } - plugins.push(new Watchpack2Plugin()) - return plugins } diff --git a/packages/webpack/src/plugins/watchpack.js b/packages/webpack/src/plugins/watchpack.js deleted file mode 100644 index 5a49d3b2ea96..000000000000 --- a/packages/webpack/src/plugins/watchpack.js +++ /dev/null @@ -1,116 +0,0 @@ -/* - MIT License http://www.opensource.org/licenses/mit-license.php - Base: https://github.com/webpack/webpack/blob/v4.46.0/lib/node/NodeWatchFileSystem.js (Tobias Koppers @sokra) -*/ -import Watchpack from 'watchpack' -import objectToMap from 'webpack/lib/util/objectToMap' - -export class Watchpack2Plugin { - apply (compiler) { - if (compiler.watchFileSystem && compiler.watchFileSystem.watcher) { - compiler.watchFileSystem.watcher.close() - } - compiler.watchFileSystem = new NodeWatchFileSystem( - compiler.inputFileSystem - ) - } -} - -export class NodeWatchFileSystem { - constructor (inputFileSystem) { - this.inputFileSystem = inputFileSystem - this.watcherOptions = { - aggregateTimeout: 0 - } - this.watcher = new Watchpack(this.watcherOptions) - } - - watch (files, dirs, missing, startTime, options, callback, callbackUndelayed) { - if (!Array.isArray(files)) { - throw new TypeError("Invalid arguments: 'files'") - } - if (!Array.isArray(dirs)) { - throw new TypeError("Invalid arguments: 'dirs'") - } - if (!Array.isArray(missing)) { - throw new TypeError("Invalid arguments: 'missing'") - } - if (typeof callback !== 'function') { - throw new TypeError("Invalid arguments: 'callback'") - } - if (typeof startTime !== 'number' && startTime) { - throw new Error("Invalid arguments: 'startTime'") - } - if (typeof options !== 'object') { - throw new TypeError("Invalid arguments: 'options'") - } - if (typeof callbackUndelayed !== 'function' && callbackUndelayed) { - throw new Error("Invalid arguments: 'callbackUndelayed'") - } - const oldWatcher = this.watcher - this.watcher = new Watchpack(options) - - if (callbackUndelayed) { - this.watcher.once('change', callbackUndelayed) - } - const cachedFiles = files - const cachedDirs = dirs - this.watcher.once('aggregated', (_changes, _removals) => { - const removals = Array.from(_removals) - const changes = Array.from(_changes).concat(removals) - if (this.inputFileSystem && this.inputFileSystem.purge) { - this.inputFileSystem.purge(changes) - } - const times = objectToMap(this.watcher.getTimes()) - files = new Set(files) - dirs = new Set(dirs) - missing = new Set(missing) - callback( - null, - changes.filter(file => files.has(file)).sort(), - changes.filter(file => dirs.has(file)).sort(), - changes.filter(file => missing.has(file)).sort(), - times, - times, - new Set(removals.filter(file => files.has(file))) - ) - }) - - this.watcher.watch( - cachedFiles.concat(missing), - cachedDirs.concat(missing), - startTime - ) - - if (oldWatcher) { - oldWatcher.close() - } - return { - close: () => { - if (this.watcher) { - this.watcher.close() - this.watcher = null - } - }, - pause: () => { - if (this.watcher) { - this.watcher.pause() - } - }, - getFileTimestamps: () => { - if (this.watcher) { - return objectToMap(this.watcher.getTimes()) - } else { - return new Map() - } - }, - getContextTimestamps: () => { - if (this.watcher) { - return objectToMap(this.watcher.getTimes()) - } else { - return new Map() - } - } - } - } -} diff --git a/yarn.lock b/yarn.lock index a80ec6a30c75..1ac350b50fe6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6552,11 +6552,6 @@ glob-parent@^5.0.0, glob-parent@^5.1.0, glob-parent@^5.1.1, glob-parent@~5.1.0: dependencies: is-glob "^4.0.1" -glob-to-regexp@^0.4.1: - version "0.4.1" - resolved "https://registry.npmjs.org/glob-to-regexp/-/glob-to-regexp-0.4.1.tgz#c75297087c851b9a578bd217dd59a92f59fe546e" - integrity sha512-lkX1HJXwyMcprw/5YUZc2s7DrpAiHB21/V+E1rHUrVNokkvB6bqMzT0VfV6/86ZNabt1k14YOIaT7nDvOX3Iiw== - glob@7.1.6: version "7.1.6" resolved "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6" @@ -13358,14 +13353,6 @@ watchpack@^1.7.4: chokidar "^3.4.1" watchpack-chokidar2 "^2.0.1" -watchpack@^2.1.1: - version "2.1.1" - resolved "https://registry.npmjs.org/watchpack/-/watchpack-2.1.1.tgz#e99630550fca07df9f90a06056987baa40a689c7" - integrity sha512-Oo7LXCmc1eE1AjyuSBmtC3+Wy4HcV8PxWh2kP6fOl8yTlNS7r0K9l1ao2lrrUza7V39Y3D/BbJgY8VeSlc5JKw== - dependencies: - glob-to-regexp "^0.4.1" - graceful-fs "^4.1.2" - wcwidth@^1.0.0: version "1.0.1" resolved "https://registry.npmjs.org/wcwidth/-/wcwidth-1.0.1.tgz#f0b0dcf915bc5ff1528afadb2c0e17b532da2fe8"