New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@wordpress/dependency-extraction-webpack-plugin

Package Overview
Dependencies
Maintainers
23
Versions
142
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@wordpress/dependency-extraction-webpack-plugin - npm Package Compare versions

Comparing version 3.2.2-next.5df0cd52b7.0 to 3.2.3-next.33ec3857e2.0

4

CHANGELOG.md

@@ -5,2 +5,6 @@ <!-- Learn how to maintain this file at https://github.com/WordPress/gutenberg/tree/HEAD/packages#maintaining-changelogs. -->

## 3.2.2-next.0 (2021-12-20)
- Add the optional `externalizedReportFile` option ([#35106](https://github.com/WordPress/gutenberg/pull/35106)).
## 3.0.0 (2021-01-21)

@@ -7,0 +11,0 @@

@@ -20,2 +20,4 @@ /**

const defaultExternalizedReportFileName = 'externalized-dependencies.json';
class DependencyExtractionWebpackPlugin {

@@ -27,4 +29,6 @@ constructor( options ) {

combinedOutputFile: null,
externalizedReport: false,
injectPolyfill: false,
outputFormat: 'php',
outputFilename: null,
useDefaults: true,

@@ -142,6 +146,22 @@ },

combinedOutputFile,
externalizedReport,
injectPolyfill,
outputFormat,
outputFilename,
} = this.options;
// Dump actually externalized dependencies to a report file.
if ( externalizedReport ) {
const externalizedReportFile =
typeof externalizedReport === 'string'
? externalizedReport
: defaultExternalizedReportFileName;
compilation.emitAsset(
externalizedReportFile,
new RawSource(
JSON.stringify( Array.from( this.externalizedDeps ).sort() )
)
);
}
const combinedAssetsData = {};

@@ -184,3 +204,5 @@

const runtimeChunk = entrypoint.getRuntimeChunk();
const entrypointChunk = isWebpack4
? entrypoint.chunks.find( ( c ) => c.name === entrypointName )
: entrypoint.getEntrypointChunk();

@@ -190,3 +212,3 @@ const assetData = {

dependencies: Array.from( entrypointExternalizedWpDeps ).sort(),
version: runtimeChunk.hash,
version: entrypointChunk.hash,
};

@@ -201,3 +223,3 @@

{
chunk: runtimeChunk,
chunk: entrypointChunk,
filename,

@@ -217,10 +239,26 @@ query,

const assetFilename = buildFilename.replace(
/\.js$/i,
'.asset.' + ( outputFormat === 'php' ? 'php' : 'json' )
);
let assetFilename;
if ( outputFilename ) {
assetFilename = compilation.getPath( outputFilename, {
chunk: entrypointChunk,
filename,
query,
basename: basename( filename ),
contentHash: createHash( 'md4' )
.update( assetString )
.digest( 'hex' ),
} );
} else {
assetFilename = buildFilename.replace(
/\.js$/i,
'.asset.' + ( outputFormat === 'php' ? 'php' : 'json' )
);
}
// Add source and file into compilation for webpack to output.
compilation.assets[ assetFilename ] = new RawSource( assetString );
runtimeChunk.files[ isWebpack4 ? 'push' : 'add' ]( assetFilename );
entrypointChunk.files[ isWebpack4 ? 'push' : 'add' ](
assetFilename
);
}

@@ -227,0 +265,0 @@

@@ -14,2 +14,3 @@ import { Compiler } from 'webpack';

outputFormat?: 'php' | 'json';
outputFilename?: string | Function,
requestToExternal?: ( request: string ) => string | string[] | undefined;

@@ -19,2 +20,3 @@ requestToHandle?: ( request: string ) => string | undefined;

combineAssets?: boolean;
externalizedReportFile?: string | undefined;
}

@@ -37,2 +37,6 @@ const WORDPRESS_NAMESPACE = '@wordpress/';

if ( request.includes( 'react-refresh/runtime' ) ) {
return 'ReactRefreshRuntime';
}
if ( BUNDLED_PACKAGES.includes( request ) ) {

@@ -70,2 +74,6 @@ return undefined;

if ( request.includes( 'react-refresh/runtime' ) ) {
return 'wp-react-refresh-runtime';
}
if ( request.startsWith( WORDPRESS_NAMESPACE ) ) {

@@ -72,0 +80,0 @@ return 'wp-' + request.substring( WORDPRESS_NAMESPACE.length );

6

package.json
{
"name": "@wordpress/dependency-extraction-webpack-plugin",
"version": "3.2.2-next.5df0cd52b7.0",
"version": "3.2.3-next.33ec3857e2.0",
"description": "Extract WordPress script dependencies from webpack bundles.",

@@ -33,3 +33,3 @@ "author": "The WordPress Contributors",

"json2php": "^0.0.4",
"webpack-sources": "^2.2.0"
"webpack-sources": "^3.2.2"
},

@@ -42,3 +42,3 @@ "peerDependencies": {

},
"gitHead": "558d577d12bec15f05e694eb49a094836d885cca"
"gitHead": "51c7917ea7fac72953702f24d6daac87d99e7617"
}

@@ -110,2 +110,9 @@ # Dependency Extraction Webpack Plugin

##### `outputFilename`
- Type: string | function
- Default: null
The filename for the generated asset file. Accepts the same values as the Webpack `output.filename` option.
##### `combineAssets`

@@ -139,2 +146,10 @@

##### `externalizedReport`
- Type: boolean | string
- Default: `false`
Report all externalized dependencies as an array in JSON format. It could be used for further manual or automated inspection.
You can provide a filename, or set it to `true` to report to a default `externalized-dependencies.json`.
##### `requestToExternal`

@@ -141,0 +156,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc