@cypress/browserify-preprocessor
Advanced tools
Comparing version 2.1.4 to 2.2.0
44
index.js
@@ -5,3 +5,3 @@ 'use strict' | ||
const Promise = require('bluebird') | ||
const fs = require('./fs') | ||
const fs = require('./lib/fs') | ||
@@ -64,3 +64,3 @@ const cloneDeep = require('lodash.clonedeep') | ||
const getBrowserifyOptions = (entry, userBrowserifyOptions = {}) => { | ||
const getBrowserifyOptions = (entry, userBrowserifyOptions = {}, typescriptPath = null) => { | ||
let browserifyOptions = cloneDeep(defaultOptions.browserifyOptions) | ||
@@ -86,2 +86,32 @@ | ||
if (typescriptPath) { | ||
const transform = browserifyOptions.transform | ||
const hasTsifyTransform = transform.some(([name]) => name.includes('tsify')) | ||
const hastsifyPlugin = browserifyOptions.plugin.includes('tsify') | ||
if (hasTsifyTransform || hastsifyPlugin) { | ||
const type = hasTsifyTransform ? 'transform' : 'plugin' | ||
throw new Error(`Error running @cypress/browserify-preprocessor: | ||
It looks like you passed the 'typescript' option and also specified a browserify ${type} for TypeScript. This may cause conflicts. | ||
Please do one of the following: | ||
1) Pass in the 'typescript' option and omit the browserify ${type} (Recommmended) | ||
2) Omit the 'typescript' option and continue to use your own browserify ${type} | ||
`) | ||
} | ||
browserifyOptions.extensions.push('.ts', '.tsx') | ||
// remove babelify setting | ||
browserifyOptions.transform = transform.filter(([name]) => !name.includes('babelify')) | ||
// add typescript compiler | ||
browserifyOptions.transform.push([ | ||
path.join(__dirname, './lib/simple_tsify'), { | ||
typescript: require(typescriptPath), | ||
}, | ||
]) | ||
} | ||
debug('browserifyOptions: %o', browserifyOptions) | ||
@@ -133,3 +163,3 @@ | ||
const browserifyOptions = getBrowserifyOptions(filePath, options.browserifyOptions) | ||
const browserifyOptions = getBrowserifyOptions(filePath, options.browserifyOptions, options.typescript) | ||
const watchifyOptions = Object.assign({}, defaultOptions.watchifyOptions, options.watchifyOptions) | ||
@@ -229,2 +259,10 @@ | ||
if (process.env.__TESTING__) { | ||
preprocessor.reset = () => { | ||
for (let filePath in bundles) { | ||
delete bundles[filePath] | ||
} | ||
} | ||
} | ||
module.exports = preprocessor |
{ | ||
"name": "@cypress/browserify-preprocessor", | ||
"description": "Cypress preprocessor for bundling JavaScript via browserify", | ||
"version": "2.1.4", | ||
"version": "2.2.0", | ||
"author": "Chris Breiding <chris@cypress.io>", | ||
@@ -55,6 +55,9 @@ "bugs": "https://github.com/cypress-io/cypress-browserify-preprocessor/issues", | ||
"nsp": "3.2.1", | ||
"react": "16.13.1", | ||
"react-dom": "16.13.1", | ||
"semantic-release": "15.13.15", | ||
"sinon": "7.2.3", | ||
"sinon-chai": "3.3.0", | ||
"snap-shot-it": "7.9.2" | ||
"snap-shot-it": "7.9.2", | ||
"typescript": "3.8.3" | ||
}, | ||
@@ -78,3 +81,4 @@ "dependencies": { | ||
"lodash.clonedeep": "4.5.0", | ||
"watchify": "3.11.1" | ||
"watchify": "3.11.1", | ||
"through2": "^2.0.0" | ||
}, | ||
@@ -81,0 +85,0 @@ "release": { |
@@ -149,2 +149,12 @@ # Cypress Browserify Preprocessor [![CircleCI](https://circleci.com/gh/cypress-io/cypress-browserify-preprocessor/tree/master.svg?style=svg)](https://circleci.com/gh/cypress-io/cypress-browserify-preprocessor/tree/master) | ||
### typescript | ||
When the path to the TypeScript package is given, Cypress will automatically transpile `.ts` spec, plugin, support files. Note that this **DOES NOT** check types. | ||
```javascript | ||
browserify({ | ||
typescript: require.resolve('typescript') | ||
}) | ||
``` | ||
**Default**: `undefined` | ||
@@ -151,0 +161,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
17149
219
199
18
20
4
2
+ Addedthrough2@^2.0.0