Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

asset-map-webpack-plugin

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asset-map-webpack-plugin - npm Package Compare versions

Comparing version 1.2.0 to 1.2.1

19

lib/index.js

@@ -19,2 +19,4 @@ "use strict";

var previousChunks = {};
function ExtractAssets(modules, requestShortener, publicPath) {

@@ -47,4 +49,3 @@ var emitted = false;

function ExtractChunks(chunks, publicPath) {
var emitted = false;
var chunks = chunks.map(function (c) {
var mappedChunks = chunks.map(function (c) {
return {

@@ -63,3 +64,6 @@ name: c.name,

return [emitted, chunks];
var emitted = JSON.stringify(previousChunks) !== JSON.stringify(mappedChunks);
previousChunks = mappedChunks;
return [emitted, mappedChunks];
}

@@ -85,7 +89,8 @@

var _this = this;
compiler.plugin("done", function (stats) {
var publicPath = stats.compilation.outputOptions.publicPath;
compiler.plugin("done", function (_ref) {
var compilation = _ref.compilation;
var publicPath = compilation.outputOptions.publicPath;
var requestShortener = new RequestShortener(_this.relativeTo || path.dirname(_this.outputFile));
var _ExtractAssets = ExtractAssets(stats.compilation.modules, requestShortener, publicPath);
var _ExtractAssets = ExtractAssets(compilation.modules, requestShortener, publicPath);

@@ -96,3 +101,3 @@ var _ExtractAssets2 = _slicedToArray(_ExtractAssets, 2);

var assets = _ExtractAssets2[1];
var _ExtractChunks = ExtractChunks(stats.compilation.chunks, publicPath);
var _ExtractChunks = ExtractChunks(compilation.chunks, publicPath);

@@ -99,0 +104,0 @@ var _ExtractChunks2 = _slicedToArray(_ExtractChunks, 2);

{
"name": "asset-map-webpack-plugin",
"version": "1.2.0",
"version": "1.2.1",
"description": "Webpack plugin that creates a map of assets to public url slug for server agnostic usage.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -6,2 +6,4 @@ import fs from 'fs';

let previousChunks = {};
function ExtractAssets(modules, requestShortener, publicPath) {

@@ -35,4 +37,3 @@ var emitted = false;

function ExtractChunks(chunks, publicPath) {
var emitted = false;
var chunks = chunks
var mappedChunks = chunks
.map(c => {

@@ -51,3 +52,6 @@ return {

return [emitted, chunks];
const emitted = JSON.stringify(previousChunks) !== JSON.stringify(mappedChunks);
previousChunks = mappedChunks;
return [emitted, mappedChunks];
}

@@ -68,8 +72,8 @@

apply(compiler) {
compiler.plugin('done', stats => {
var publicPath = stats.compilation.outputOptions.publicPath;
compiler.plugin('done', ({ compilation }) => {
var publicPath = compilation.outputOptions.publicPath;
var requestShortener = new RequestShortener(this.relativeTo || path.dirname(this.outputFile));
var [assetsEmitted, assets] = ExtractAssets(stats.compilation.modules, requestShortener, publicPath);
var [chunksEmitted, chunks] = ExtractChunks(stats.compilation.chunks, publicPath);
var [assetsEmitted, assets] = ExtractAssets(compilation.modules, requestShortener, publicPath);
var [chunksEmitted, chunks] = ExtractChunks(compilation.chunks, publicPath);

@@ -76,0 +80,0 @@ if (assetsEmitted || chunksEmitted) {

@@ -1,1 +0,14 @@

{"assets":{"./test-checklist.jpeg":"/assets/test-checklist-b3b0fe76f4485db43467876f664d1f62.jpeg","./smiley.jpeg":"/assets/smiley-db4f287d06928156270ca185fef0e026.jpeg"},"chunks":{"entry2":["/assets/entry2-4d146569820f49b0556a.js"],"entry1":["/assets/entry1-4d146569820f49b0556a.js"]}}
{
"assets": {
"./test-checklist.jpeg": "/assets/test-checklist-b3b0fe76f4485db43467876f664d1f62.jpeg",
"./smiley.jpeg": "/assets/smiley-db4f287d06928156270ca185fef0e026.jpeg"
},
"chunks": {
"entry2": [
"/assets/entry2-4d146569820f49b0556a.js"
],
"entry1": [
"/assets/entry1-4d146569820f49b0556a.js"
]
}
}

@@ -64,3 +64,3 @@ import _ from 'lodash';

it('Only emits if an asset has changed', function(done) {
this.timeout(5000);
this.timeout(6000);

@@ -74,2 +74,3 @@ rimraf(config.output.path, () => {

var smiley = __dirname + '/app/smiley.jpeg';
let buffer;
var watchCompletions = [

@@ -88,4 +89,11 @@ function FirstWatchComplete() {

newStats.mtime.should.not.eql(lastMapStats.mtime);
touch.sync(entry1Js);
lastMapStats = newStats;
buffer = fs.readFileSync(entry1Js, 'utf8');
fs.writeFileSync(entry1Js, buffer + "console.log('we made it!');", null, 2);
},
function TestChunkRewrite() {
let newStats = fs.statSync(assetMap);
newStats.mtime.should.not.eql(lastMapStats.mtime);
fs.writeFileSync(entry1Js, buffer, null, 2);
},
function LastWatchComplete() {

@@ -92,0 +100,0 @@ watcher.close(done);

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