Skip to content
This repository was archived by the owner on Jan 31, 2023. It is now read-only.

Commit d244bb8

Browse files
authored
Merge pull request #98 from cypress-io/revert-readme
2 parents ab111fd + 285f4e1 commit d244bb8

File tree

1 file changed

+30
-52
lines changed

1 file changed

+30
-52
lines changed

README.md

Lines changed: 30 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -18,51 +18,27 @@ npm install --save-dev @cypress/browserify-preprocessor
1818

1919
## Usage
2020

21-
### Prior to Cypress 10.0
22-
2321
In your project's [plugins file](https://on.cypress.io/plugins-guide):
2422

2523
```javascript
26-
const browserify = require("@cypress/browserify-preprocessor");
24+
const browserify = require('@cypress/browserify-preprocessor')
2725

2826
module.exports = (on) => {
29-
on("file:preprocessor", browserify());
30-
};
31-
```
32-
33-
### Cypress 10.0 and Beyond
34-
35-
In your project's [cypress config](https://on.cypress.io/plugins-api):
36-
37-
```javascript
38-
const { defineConfig } = require("cypress");
39-
const browserify = require("@cypress/browserify-preprocessor");
40-
41-
module.exports = defineConfig({
42-
e2e: {
43-
setupNodeEvents(on, config) {
44-
on("file:preprocessor", browserify());
45-
},
46-
},
47-
component: {
48-
setupNodeEvents(on, config) {
49-
on("file:preprocessor", browserify());
50-
},
51-
},
52-
});
27+
on('file:preprocessor', browserify())
28+
}
5329
```
5430

5531
## Options
5632

5733
Pass in options as the second argument to `browserify`:
5834

5935
```javascript
60-
{
36+
module.exports = (on) => {
6137
const options = {
6238
// options here
63-
};
39+
}
6440

65-
on("file:preprocessor", browserify(options));
41+
on('file:preprocessor', browserify(options))
6642
}
6743
```
6844

@@ -74,10 +50,12 @@ Object of options passed to [browserify](https://github.com/browserify/browserif
7450
// example
7551
browserify({
7652
browserifyOptions: {
77-
extensions: [".js", ".ts"],
78-
plugin: [["tsify"]],
79-
},
80-
});
53+
extensions: ['.js', '.ts'],
54+
plugin: [
55+
['tsify']
56+
]
57+
}
58+
})
8159
```
8260

8361
If you pass one of the top-level options in (`extensions`, `transform`, etc), it will override the default. In the above example, browserify will process `.js` and `.ts` files, but not `.jsx` or `.coffee`. If you wish to add to or modify existing options, read about [modifying the default options](#modifying-default-options).
@@ -102,7 +80,7 @@ Source maps are always enabled unless explicitly disabled by specifying `debug:
10280
ast: false,
10381
babelrc: false,
10482
plugins: [
105-
'@babel/plugin-transform-modules-commonjs',
83+
'@babel/plugin-transform-modules-commonjs',
10684
'@babel/plugin-proposal-class-properties',
10785
'@babel/plugin-proposal-object-rest-spread',
10886
'@babel/plugin-transform-runtime',
@@ -121,7 +99,7 @@ Source maps are always enabled unless explicitly disabled by specifying `debug:
12199
}
122100
```
123101

124-
_Note_: `cache` and `packageCache` are always set to `{}` and cannot be overridden. Otherwise, file watching would not function correctly.
102+
*Note*: `cache` and `packageCache` are always set to `{}` and cannot be overridden. Otherwise, file watching would not function correctly.
125103

126104
### watchifyOptions
127105

@@ -131,9 +109,9 @@ Object of options passed to [watchify](https://github.com/browserify/watchify#op
131109
// example
132110
browserify({
133111
watchifyOptions: {
134-
delay: 500,
135-
},
136-
});
112+
delay: 500
113+
}
114+
})
137115
```
138116

139117
**Default**:
@@ -158,12 +136,12 @@ A function that is called with the [browserify instance](https://github.com/brow
158136
```javascript
159137
// example
160138
browserify({
161-
onBundle(bundle) {
162-
bundle.external("react");
163-
bundle.plugin("some-plugin");
164-
bundle.ignore("pg-native");
165-
},
166-
});
139+
onBundle (bundle) {
140+
bundle.external('react')
141+
bundle.plugin('some-plugin')
142+
bundle.ignore('pg-native')
143+
}
144+
})
167145
```
168146

169147
### typescript
@@ -172,8 +150,8 @@ When the path to the TypeScript package is given, Cypress will automatically tra
172150

173151
```javascript
174152
browserify({
175-
typescript: require.resolve("typescript"),
176-
});
153+
typescript: require.resolve('typescript')
154+
})
177155
```
178156

179157
**Default**: `undefined`
@@ -185,13 +163,13 @@ The default options are provided as `browserify.defaultOptions` so they can be m
185163
If, for example, you want to update the options for the `babelify` transform to turn on `babelrc` loading, you could do the following:
186164

187165
```javascript
188-
const browserify = require("@cypress/browserify-preprocessor");
166+
const browserify = require('@cypress/browserify-preprocessor')
189167

190-
{
191-
const options = browserify.defaultOptions;
192-
options.browserifyOptions.transform[1][1].babelrc = true;
168+
module.exports = (on) => {
169+
const options = browserify.defaultOptions
170+
options.browserifyOptions.transform[1][1].babelrc = true
193171

194-
on("file:preprocessor", browserify(options));
172+
on('file:preprocessor', browserify(options))
195173
}
196174
```
197175

0 commit comments

Comments
 (0)