From 27fefdc2c896050035efb4117154b4495ca2055d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Greg=20Zi=C3=B3=C5=82kowski?= Date: Mon, 6 Mar 2023 11:59:41 +0100 Subject: [PATCH] Packages: Remove completely two deprecated webpack plugins (#48770) --- .github/CODEOWNERS | 2 - docs/manifest.json | 12 ---- .../.npmrc | 1 - .../CHANGELOG.md | 59 --------------- .../README.md | 71 ------------------- .../index.js | 64 ----------------- .../package.json | 39 ---------- .../test/fixtures/entry/index.js | 1 - .../test/fixtures/webpack.config.js | 38 ---------- .../test/index.js | 40 ----------- .../.npmrc | 1 - .../CHANGELOG.md | 43 ----------- .../README.md | 51 ------------- .../index.js | 41 ----------- .../package.json | 40 ----------- 15 files changed, 503 deletions(-) delete mode 100644 packages/custom-templated-path-webpack-plugin/.npmrc delete mode 100644 packages/custom-templated-path-webpack-plugin/CHANGELOG.md delete mode 100644 packages/custom-templated-path-webpack-plugin/README.md delete mode 100644 packages/custom-templated-path-webpack-plugin/index.js delete mode 100644 packages/custom-templated-path-webpack-plugin/package.json delete mode 100644 packages/custom-templated-path-webpack-plugin/test/fixtures/entry/index.js delete mode 100644 packages/custom-templated-path-webpack-plugin/test/fixtures/webpack.config.js delete mode 100644 packages/custom-templated-path-webpack-plugin/test/index.js delete mode 100644 packages/library-export-default-webpack-plugin/.npmrc delete mode 100644 packages/library-export-default-webpack-plugin/CHANGELOG.md delete mode 100644 packages/library-export-default-webpack-plugin/README.md delete mode 100644 packages/library-export-default-webpack-plugin/index.js delete mode 100644 packages/library-export-default-webpack-plugin/package.json diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index c6e2e1bb38858d..d3ba813d3cd8ab 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -64,7 +64,6 @@ /packages/browserslist-config @ntwb @nerrad @ajitbohra /packages/create-block @gziolo @ryanwelcher /packages/create-block-tutorial-template @gziolo @ryanwelcher -/packages/custom-templated-path-webpack-plugin @ntwb @nerrad @ajitbohra /packages/dependency-extraction-webpack-plugin @gziolo /packages/docgen /packages/e2e-test-utils @ntwb @nerrad @ajitbohra @@ -74,7 +73,6 @@ /packages/jest-console @gziolo @ntwb @nerrad @ajitbohra /packages/jest-preset-default @gziolo @ntwb @nerrad @ajitbohra /packages/jest-puppeteer-axe @gziolo @ntwb @nerrad @ajitbohra -/packages/library-export-default-webpack-plugin @ntwb @nerrad @ajitbohra /packages/npm-package-json-lint-config @gziolo @ntwb @nerrad @ajitbohra /packages/postcss-themes @ntwb @nerrad @ajitbohra /packages/prettier-config @ntwb @gziolo diff --git a/docs/manifest.json b/docs/manifest.json index d7aa98b85a4cfa..b99fec46551367 100644 --- a/docs/manifest.json +++ b/docs/manifest.json @@ -1499,12 +1499,6 @@ "markdown_source": "../packages/create-block/docs/external-template.md", "parent": "packages-create-block" }, - { - "title": "@wordpress/custom-templated-path-webpack-plugin", - "slug": "packages-custom-templated-path-webpack-plugin", - "markdown_source": "../packages/custom-templated-path-webpack-plugin/README.md", - "parent": "packages" - }, { "title": "@wordpress/customize-widgets", "slug": "packages-customize-widgets", @@ -1697,12 +1691,6 @@ "markdown_source": "../packages/lazy-import/README.md", "parent": "packages" }, - { - "title": "@wordpress/library-export-default-webpack-plugin", - "slug": "packages-library-export-default-webpack-plugin", - "markdown_source": "../packages/library-export-default-webpack-plugin/README.md", - "parent": "packages" - }, { "title": "@wordpress/list-reusable-blocks", "slug": "packages-list-reusable-blocks", diff --git a/packages/custom-templated-path-webpack-plugin/.npmrc b/packages/custom-templated-path-webpack-plugin/.npmrc deleted file mode 100644 index 43c97e719a5a82..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/packages/custom-templated-path-webpack-plugin/CHANGELOG.md b/packages/custom-templated-path-webpack-plugin/CHANGELOG.md deleted file mode 100644 index 695f215b12b99c..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/CHANGELOG.md +++ /dev/null @@ -1,59 +0,0 @@ - - -## Unreleased - -## 2.13.0 (2023-03-06) - -### Deprecations - -- This plugin is deprecated for webpack 5. Please use [`output.filename`](https://webpack.js.org/configuration/output/#outputfilename) instead. - -## 2.12.0 (2023-03-01) - -## 2.11.0 (2023-02-15) - -## 2.10.0 (2023-02-01) - -## 2.9.0 (2023-01-11) - -## 2.8.0 (2023-01-02) - -## 2.7.0 (2022-12-14) - -## 2.6.0 (2022-11-16) - -## 2.5.0 (2022-11-02) - -## 2.4.0 (2022-10-19) - -## 2.3.0 (2022-10-05) - -## 2.2.0 (2022-09-21) - -## 2.0.0 (2021-01-21) - -### Breaking Changes - -- Increase the minimum Node.js version to 12 ([#27934](https://github.com/WordPress/gutenberg/pull/27934)). - -## 1.4.0 (2019-06-12) - -### Bug Fixes - -- Resolved an issue where only the value of the first matched tag would be produced. - -### Internal - -- The module is no longer transpiled as part of a build process, and instead exposes its source directly as the `main` file. - -## 1.1.0 (2018-07-12) - -### Internal - -- Moved `@WordPress/packages` repository to `@WordPress/gutenberg` ([#7805](https://github.com/WordPress/gutenberg/pull/7805)) - -## 1.0.2 (2018-05-18) - -### Polish - -- Fix: Standardized `package.json` format ([#119](https://github.com/WordPress/packages/pull/119)) diff --git a/packages/custom-templated-path-webpack-plugin/README.md b/packages/custom-templated-path-webpack-plugin/README.md deleted file mode 100644 index ecf7bf2e97eaac..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/README.md +++ /dev/null @@ -1,71 +0,0 @@ -# Custom Templated Path Webpack Plugin - -> **DEPRECATED for webpack v5**: please use [`output.filename`](https://webpack.js.org/configuration/output/#outputfilename) instead. - -Webpack plugin for creating custom path template tags. Extend the [default set of template tags](https://webpack.js.org/configuration/output/#output-filename) with your own custom behavior. Hooks into Webpack's compilation process to allow you to replace tags with a substitute value. - -## Installation - -Install the module - -```bash -npm install @wordpress/custom-templated-path-webpack-plugin --save-dev -``` - -**Note**: This package requires Node.js 12.0.0 or later. It is not compatible with older versions. It works only with webpack v4. - -## Usage - -Construct an instance of `CustomTemplatedPathPlugin` in your Webpack configurations `plugins` entry, passing an object where keys correspond to the template tag name. The value for each key is a function passed the original intended path and data corresponding to the asset. - -The following example creates a new `basename` tag to substitute the basename of each entry file in the build output file. When compiled, the built file will be output as `build-entry.js`. - -```js -const { basename } = require( 'path' ); -const CustomTemplatedPathPlugin = require( '@wordpress/custom-templated-path-webpack-plugin' ); - -module.exports = { - // ... - - entry: './entry', - - output: { - filename: 'build-[basename].js', - }, - - plugins: [ - new CustomTemplatedPathPlugin( { - basename( path, data ) { - let rawRequest; - - const entryModule = get( data, [ 'chunk', 'entryModule' ], {} ); - switch ( entryModule.type ) { - case 'javascript/auto': - rawRequest = entryModule.rawRequest; - break; - - case 'javascript/esm': - rawRequest = entryModule.rootModule.rawRequest; - break; - } - - if ( rawRequest ) { - return basename( rawRequest ); - } - - return path; - }, - } ), - ], -}; -``` - -For more examples, refer to Webpack's own [`TemplatedPathPlugin.js`](https://github.com/webpack/webpack/blob/v4.1.1/lib/TemplatedPathPlugin.js), which implements the base set of template tags. - -## Contributing to this package - -This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects. - -To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md). - -

Code is Poetry.

diff --git a/packages/custom-templated-path-webpack-plugin/index.js b/packages/custom-templated-path-webpack-plugin/index.js deleted file mode 100644 index 7d7bd317aa48bf..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/index.js +++ /dev/null @@ -1,64 +0,0 @@ -/** - * External dependencies - */ -const escapeStringRegexp = require( 'escape-string-regexp' ); - -/** - * Webpack plugin for handling specific template tags in Webpack configuration - * values like those supported in the base Webpack functionality (e.g. `name`). - * - * @see webpack.TemplatedPathPlugin - */ -class CustomTemplatedPathPlugin { - /** - * CustomTemplatedPathPlugin constructor. Initializes handlers as a tuple - * set of RegExp, handler, where the regular expression is used in matching - * a Webpack asset path. - * - * @param {Object.} handlers Object keyed by tag to match, - * with function value returning - * replacement string. - */ - constructor( handlers ) { - this.handlers = []; - - for ( const [ key, handler ] of Object.entries( handlers ) ) { - const regexp = new RegExp( - `\\[${ escapeStringRegexp( key ) }\\]`, - 'gi' - ); - this.handlers.push( [ regexp, handler ] ); - } - } - - /** - * Webpack plugin application logic. - * - * @param {Object} compiler Webpack compiler - */ - apply( compiler ) { - compiler.hooks.compilation.tap( - 'CustomTemplatedPathPlugin', - ( compilation ) => { - compilation.mainTemplate.hooks.assetPath.tap( - 'CustomTemplatedPathPlugin', - ( path, data ) => { - for ( let i = 0; i < this.handlers.length; i++ ) { - const [ regexp, handler ] = this.handlers[ i ]; - if ( regexp.test( path ) ) { - path = path.replace( - regexp, - handler( path, data ) - ); - } - } - - return path; - } - ); - } - ); - } -} - -module.exports = CustomTemplatedPathPlugin; diff --git a/packages/custom-templated-path-webpack-plugin/package.json b/packages/custom-templated-path-webpack-plugin/package.json deleted file mode 100644 index 99ff25d82438c2..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/package.json +++ /dev/null @@ -1,39 +0,0 @@ -{ - "name": "@wordpress/custom-templated-path-webpack-plugin", - "version": "2.13.0", - "description": "Webpack plugin for creating custom path template tags.", - "author": "The WordPress Contributors", - "license": "GPL-2.0-or-later", - "keywords": [ - "wordpress", - "gutenberg", - "webpack", - "plugin", - "webpack-plugin" - ], - "homepage": "https://github.com/WordPress/gutenberg/blob/HEAD/packages/custom-templated-path-webpack-plugin/README.md", - "repository": { - "type": "git", - "url": "https://github.com/WordPress/gutenberg.git", - "directory": "packages/custom-templated-path-webpack-plugin" - }, - "bugs": { - "url": "https://github.com/WordPress/gutenberg/issues" - }, - "engines": { - "node": ">=12" - }, - "files": [ - "index.js" - ], - "main": "index.js", - "dependencies": { - "escape-string-regexp": "^1.0.5" - }, - "peerDependencies": { - "webpack": "^4.0.0" - }, - "publishConfig": { - "access": "public" - } -} diff --git a/packages/custom-templated-path-webpack-plugin/test/fixtures/entry/index.js b/packages/custom-templated-path-webpack-plugin/test/fixtures/entry/index.js deleted file mode 100644 index b894a23a24d56c..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/test/fixtures/entry/index.js +++ /dev/null @@ -1 +0,0 @@ -module.exports = null; diff --git a/packages/custom-templated-path-webpack-plugin/test/fixtures/webpack.config.js b/packages/custom-templated-path-webpack-plugin/test/fixtures/webpack.config.js deleted file mode 100644 index 0e9c46cb63c320..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/test/fixtures/webpack.config.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * External dependencies - */ -const { basename } = require( 'path' ); - -/** - * Internal dependencies - */ -const CustomTemplatedPathPlugin = require( '../../' ); - -module.exports = { - mode: 'development', - context: __dirname, - entry: './entry', - output: { - filename: 'build/[basename]-[theanswertolife].js', - path: __dirname, - }, - plugins: [ - new CustomTemplatedPathPlugin( { - basename( path, data ) { - let rawRequest; - if ( data && data.chunk && data.chunk.entryModule ) { - rawRequest = data.chunk.entryModule.rawRequest; - } - - if ( rawRequest ) { - return basename( rawRequest ); - } - - return path; - }, - theanswertolife() { - return 42; - }, - } ), - ], -}; diff --git a/packages/custom-templated-path-webpack-plugin/test/index.js b/packages/custom-templated-path-webpack-plugin/test/index.js deleted file mode 100644 index 72a39d215e6ed3..00000000000000 --- a/packages/custom-templated-path-webpack-plugin/test/index.js +++ /dev/null @@ -1,40 +0,0 @@ -/** - * External dependencies - */ -import { access, unlink } from 'fs'; -import path from 'path'; -import { promisify } from 'util'; -import webpack from 'webpack'; - -/** - * Internal dependencies - */ -import config from './fixtures/webpack.config.js'; - -/** - * Local variables - */ -const accessAsync = promisify( access ); -const unlinkAsync = promisify( unlink ); -const webpackAsync = promisify( webpack ); - -jest.useRealTimers(); - -describe( 'CustomTemplatedPathPlugin', () => { - const outputFile = path.join( __dirname, '/fixtures/build/entry-42.js' ); - - beforeAll( async () => { - // Remove output file so as not to report false positive from previous - // test. Absorb error since the file may not exist (unlink will throw). - try { - await unlinkAsync( outputFile ); - } catch ( error ) {} - } ); - - it( 'should resolve with basename output', async () => { - expect( async () => { - await webpackAsync( config ); - await accessAsync( outputFile ); - } ).not.toThrow(); - } ); -} ); diff --git a/packages/library-export-default-webpack-plugin/.npmrc b/packages/library-export-default-webpack-plugin/.npmrc deleted file mode 100644 index 43c97e719a5a82..00000000000000 --- a/packages/library-export-default-webpack-plugin/.npmrc +++ /dev/null @@ -1 +0,0 @@ -package-lock=false diff --git a/packages/library-export-default-webpack-plugin/CHANGELOG.md b/packages/library-export-default-webpack-plugin/CHANGELOG.md deleted file mode 100644 index 107e1ecfdb281c..00000000000000 --- a/packages/library-export-default-webpack-plugin/CHANGELOG.md +++ /dev/null @@ -1,43 +0,0 @@ - - -## Unreleased - -## 2.14.0 (2023-03-01) - -## 2.13.0 (2023-02-15) - -## 2.12.0 (2023-02-01) - -## 2.11.0 (2023-01-11) - -## 2.10.0 (2023-01-02) - -## 2.9.0 (2022-12-14) - -## 2.8.0 (2022-11-16) - -## 2.7.0 (2022-11-02) - -## 2.6.0 (2022-10-19) - -## 2.5.0 (2022-10-05) - -## 2.4.0 (2022-09-21) - -## 2.2.0 (2021-08-23) - -### Deprecations - -- This plugin is deprecated for webpack 5. Please use [`output.library.export`](https://webpack.js.org/configuration/output/#outputlibraryexport) instead ([#33818](https://github.com/WordPress/gutenberg/pull/33818)). - -## 2.0.0 (2021-01-21) - -### Breaking Changes - -- Increase the minimum Node.js version to 12 ([#27934](https://github.com/WordPress/gutenberg/pull/27934)). - -## 1.3.0 (2019-06-12) - -### Internal - -- The module is no longer transpiled as part of a build process, and instead exposes its source directly as the `main` file. diff --git a/packages/library-export-default-webpack-plugin/README.md b/packages/library-export-default-webpack-plugin/README.md deleted file mode 100644 index c806260200b98e..00000000000000 --- a/packages/library-export-default-webpack-plugin/README.md +++ /dev/null @@ -1,51 +0,0 @@ -# Library Export Default Webpack Plugin - -> **DEPRECATED for webpack v5**: please use [`output.library.export`](https://webpack.js.org/configuration/output/#outputlibraryexport) instead. - -Webpack plugin for exporting `default` property for selected libraries which use ES6 Modules. Implementation is based on the Webpack's core plugin [ExportPropertyMainTemplatePlugin](https://github.com/webpack/webpack/blob/51b0df77e4f366163730ee465f01458bfad81f34/lib/ExportPropertyMainTemplatePlugin.js). The only difference is that this plugin allows to include all entry point names where the default export of your entry point will be assigned to the library target. - -## Installation - -Install the module - -```bash -npm install @wordpress/library-export-default-webpack-plugin --save -``` - -**Note**: This package requires Node.js 12.0.0 or later. It is not compatible with older versions. It works only with webpack v4. - -## Usage - -Construct an instance of `LibraryExportDefaultPlugin` in your Webpack configurations plugins entry, passing an array where values correspond to the entry point name. - -The following example selects `boo` entry point to be updated by the plugin. When compiled, the built file will ensure that `default` value exported for the chunk will be assigned to the global variable `wp.boo`. `foo` chunk will remain untouched. - -```js -const LibraryExportDefaultPlugin = require( '@wordpress/library-export-default-webpack-plugin' ); - -module.exports = { - // ... - - entry: { - boo: './packages/boo', - foo: './packages/foo', - }, - - output: { - filename: 'build/[name].js', - path: __dirname, - library: [ 'wp', '[name]' ], - libraryTarget: 'this', - }, - - plugins: [ new LibraryExportDefaultPlugin( [ 'boo' ] ) ], -}; -``` - -## Contributing to this package - -This is an individual package that's part of the Gutenberg project. The project is organized as a monorepo. It's made up of multiple self-contained software packages, each with a specific purpose. The packages in this monorepo are published to [npm](https://www.npmjs.com/) and used by [WordPress](https://make.wordpress.org/core/) as well as other software projects. - -To find out more about contributing to this package or Gutenberg as a whole, please read the project's main [contributor guide](https://github.com/WordPress/gutenberg/tree/HEAD/CONTRIBUTING.md). - -

Code is Poetry.

diff --git a/packages/library-export-default-webpack-plugin/index.js b/packages/library-export-default-webpack-plugin/index.js deleted file mode 100644 index 55f0f1b92fe6a7..00000000000000 --- a/packages/library-export-default-webpack-plugin/index.js +++ /dev/null @@ -1,41 +0,0 @@ -/** - * External dependencies - */ -const { ConcatSource } = require( 'webpack-sources' ); - -module.exports = class LibraryExportDefaultPlugin { - constructor( entryPointNames = [] ) { - this.entryPointNames = entryPointNames; - } - - apply( compiler ) { - compiler.hooks.compilation.tap( - 'LibraryExportDefaultPlugin', - ( compilation ) => { - const { mainTemplate, chunkTemplate } = compilation; - - const onRenderWithEntry = ( source, chunk ) => { - if ( ! this.entryPointNames.includes( chunk.name ) ) { - return source; - } - return new ConcatSource( source, '["default"]' ); - }; - - for ( const template of [ mainTemplate, chunkTemplate ] ) { - template.hooks.renderWithEntry.tap( - 'LibraryExportDefaultPlugin', - onRenderWithEntry - ); - } - - mainTemplate.hooks.hash.tap( - 'LibraryExportDefaultPlugin', - ( hash ) => { - hash.update( 'export property' ); - hash.update( 'default' ); - } - ); - } - ); - } -}; diff --git a/packages/library-export-default-webpack-plugin/package.json b/packages/library-export-default-webpack-plugin/package.json deleted file mode 100644 index 2692237414541c..00000000000000 --- a/packages/library-export-default-webpack-plugin/package.json +++ /dev/null @@ -1,40 +0,0 @@ -{ - "name": "@wordpress/library-export-default-webpack-plugin", - "version": "2.14.0", - "description": "Webpack plugin for exporting default property for selected libraries.", - "author": "The WordPress Contributors", - "license": "GPL-2.0-or-later", - "keywords": [ - "wordpress", - "gutenberg", - "webpack", - "plugin", - "webpack-plugin", - "export" - ], - "homepage": "https://github.com/WordPress/gutenberg/tree/HEAD/packages/library-export-default-webpack-plugin/README.md", - "repository": { - "type": "git", - "url": "https://github.com/WordPress/gutenberg.git", - "directory": "packages/library-export-default-webpack-plugin" - }, - "bugs": { - "url": "https://github.com/WordPress/gutenberg/issues" - }, - "engines": { - "node": ">=12" - }, - "files": [ - "index.js" - ], - "main": "index.js", - "dependencies": { - "webpack-sources": "^3.2.2" - }, - "peerDependencies": { - "webpack": "^4.0.0" - }, - "publishConfig": { - "access": "public" - } -}