Socket
Socket
Sign inDemoInstall

@cypress/webpack-preprocessor

Package Overview
Dependencies
Maintainers
1
Versions
73
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@cypress/webpack-preprocessor - npm Package Compare versions

Comparing version 5.16.3 to 5.17.0

3

dist/index.d.ts

@@ -7,5 +7,2 @@ /// <reference types="webpack-dev-server" />

import webpack from 'webpack';
declare global {
var __cypressCallbackReplacementCommands: string[] | undefined;
}
declare type FilePath = string;

@@ -12,0 +9,0 @@ /**

@@ -34,5 +34,3 @@ "use strict";

var utils_1 = __importDefault(require("./lib/utils"));
var cross_origin_callback_store_1 = require("./lib/cross-origin-callback-store");
var typescript_overrides_1 = require("./lib/typescript-overrides");
var cross_origin_callback_compile_1 = require("./lib/cross-origin-callback-compile");
var debug = (0, debug_1.default)('cypress:webpack');

@@ -115,3 +113,2 @@ var debugStats = (0, debug_1.default)('cypress:webpack:stats');

debug('user options: %o', options);
var crossOriginCallbackLoaderAdded = false;
// we return function that accepts the arguments provided by

@@ -179,18 +176,2 @@ // the event 'file:preprocessor'

.value();
var callbackReplacementCommands = global.__cypressCallbackReplacementCommands;
if (!crossOriginCallbackLoaderAdded && !!callbackReplacementCommands) {
// webpack runs loaders last-to-first and we want ours to run last
// so that it's working with plain javascript
webpackOptions.module.rules.unshift({
test: /\.(js|ts|jsx|tsx)$/,
exclude: /node_modules/,
use: [{
loader: require.resolve('@cypress/webpack-preprocessor/dist/lib/cross-origin-callback-loader.js'),
options: {
commands: callbackReplacementCommands,
},
}],
});
crossOriginCallbackLoaderAdded = true;
}
debug('webpackOptions: %o', webpackOptions);

@@ -249,3 +230,8 @@ debug('watchOptions: %o', watchOptions);

}
var resolveAllBundles = function () {
// seems to be a race condition where changing file before next tick
// does not cause build to rerun
bluebird_1.default.delay(0).then(function () {
if (!bundles[filePath]) {
return;
}
bundles[filePath].deferreds.forEach(function (deferred) {

@@ -257,50 +243,2 @@ // resolve with the outputPath so Cypress knows where to serve

bundles[filePath].deferreds.length = 0;
};
// the cross-origin-callback-loader extracts any cross-origin callback
// functions that require dependencies and stores their sources
// in the CrossOriginCallbackStore. it saves the callbacks per source
// files, since that's the context it has. here we need to unfurl
// what dependencies the input source file has so we can know which
// files stored in the CrossOriginCallbackStore to compile
var handleCrossOriginCallbackFiles = function () {
// get the source file and any of its dependencies
var sourceFiles = jsonStats.modules
.filter(function (module) {
// entries have duplicate modules whose ids are numbers
return lodash_1.default.isString(module.id);
})
.map(function (module) {
// module id is the path relative to the cwd,
// e.g. ./cypress/support/e2e.js, but we need it absolute
return path.join(process.cwd(), module.id);
});
if (!cross_origin_callback_store_1.crossOriginCallbackStore.hasFilesFor(sourceFiles)) {
debug('no cross-origin callback files');
return resolveAllBundles();
}
(0, cross_origin_callback_compile_1.compileCrossOriginCallbackFiles)(cross_origin_callback_store_1.crossOriginCallbackStore.getFilesFor(sourceFiles), {
originalFilePath: filePath,
webpackOptions: webpackOptions,
})
.then(function () {
debug('resolve all after handling cross-origin callback files');
resolveAllBundles();
})
.catch(function (err) {
rejectWithErr(err);
})
.finally(function () {
cross_origin_callback_store_1.crossOriginCallbackStore.reset(filePath);
});
};
// seems to be a race condition where changing file before next tick
// does not cause build to rerun
bluebird_1.default.delay(0).then(function () {
if (!bundles[filePath]) {
return;
}
if (!callbackReplacementCommands) {
return resolveAllBundles();
}
handleCrossOriginCallbackFiles();
});

@@ -359,10 +297,2 @@ };

}
// clean up temp dir where cross-origin callback files are output
var tmpdir = utils_1.default.tmpdir(utils_1.default.hash(filePath));
debug('remove temp directory:', tmpdir);
utils_1.default.rmdir(tmpdir).catch(function (err) {
// not the end of the world if removing the tmpdir fails, but we
// don't want it to crash the whole process by going uncaught
debug('failed removing temp directory: %s', err.stack);
});
});

@@ -369,0 +299,0 @@ // return the promise, which will resolve with the outputPath or reject

@@ -7,11 +7,5 @@ import Bluebird from 'bluebird';

};
declare function hash(contents: string): any;
declare function rmdir(dirPath: string): Promise<void>;
declare function tmpdir(dirname?: string): string;
declare const _default: {
createDeferred: typeof createDeferred;
hash: typeof hash;
rmdir: typeof rmdir;
tmpdir: typeof tmpdir;
};
export default _default;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -29,8 +6,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
var lodash_1 = __importDefault(require("lodash"));
var os = __importStar(require("os"));
var path_1 = __importDefault(require("path"));
var md5_1 = __importDefault(require("md5"));
var bluebird_1 = __importDefault(require("bluebird"));
var fs_extra_1 = __importDefault(require("fs-extra"));
function createDeferred() {

@@ -50,17 +22,4 @@ var resolve;

}
function hash(contents) {
return (0, md5_1.default)(contents);
}
function rmdir(dirPath) {
return fs_extra_1.default.emptyDir(dirPath);
}
function tmpdir(dirname) {
var pathParts = lodash_1.default.compact([os.tmpdir(), 'cypress', 'webpack-preprocessor', dirname]);
return path_1.default.join.apply(path_1.default, pathParts);
}
exports.default = {
createDeferred: createDeferred,
hash: hash,
rmdir: rmdir,
tmpdir: tmpdir,
};

15

package.json
{
"name": "@cypress/webpack-preprocessor",
"version": "5.16.3",
"version": "5.17.0",
"description": "Cypress preprocessor for bundling JavaScript via webpack",

@@ -24,16 +24,8 @@ "private": false,

"dependencies": {
"@babel/core": "^7.0.1",
"@babel/generator": "^7.17.9",
"@babel/parser": "^7.13.0",
"@babel/traverse": "^7.17.9",
"bluebird": "3.7.1",
"debug": "^4.3.4",
"fs-extra": "^10.1.0",
"loader-utils": "^2.0.0",
"lodash": "^4.17.20",
"md5": "2.3.0",
"source-map": "^0.6.1",
"webpack-virtual-modules": "^0.4.4"
"lodash": "^4.17.20"
},
"devDependencies": {
"@babel/core": "^7.0.1",
"@babel/preset-env": "^7.0.0",

@@ -52,2 +44,3 @@ "@types/mocha": "9.0.0",

"find-webpack": "1.5.0",
"fs-extra": "^10.1.0",
"mocha": "^7.1.0",

@@ -54,0 +47,0 @@ "mockery": "2.1.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