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

Commit

Permalink
major: Update deps, remove cjsx support
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisbreiding committed Feb 14, 2019
1 parent f8baedc commit e6d60cb
Show file tree
Hide file tree
Showing 7 changed files with 1,809 additions and 1,312 deletions.
2 changes: 1 addition & 1 deletion .node-version
@@ -1 +1 @@
8.11.3
8.2.1
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -60,18 +60,18 @@ browserify({
})
```

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`, `.coffee`, or `.cjsx`. If you wish to add to or modify existing options, read about [modifying the default options](#modifying-default-options).
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).

[watchify](https://github.com/browserify/watchify) is automatically configured as a plugin (as needed), so it's not necessary to manually specify it.

**Default**:

```javascript
{
extensions: ['.js', '.jsx', '.coffee', '.cjsx'],
extensions: ['.js', '.jsx', '.coffee'],
transform: [
[
'cjsxify',
'coffeeify',
{}
],
[
Expand Down
11 changes: 0 additions & 11 deletions cjsxify.js

This file was deleted.

13 changes: 9 additions & 4 deletions index.js
Expand Up @@ -11,14 +11,14 @@ const debug = require('debug')('cypress:browserify')

const bundles = {}

// by default, we transform JavaScript (up to anything at stage-4), JSX,
// CoffeeScript, and CJSX (CoffeeScript + JSX)
// by default, we transform JavaScript (including some proposal features),
// JSX, & CoffeeScript
const defaultOptions = {
browserifyOptions: {
extensions: ['.js', '.jsx', '.coffee', '.cjsx'],
extensions: ['.js', '.jsx', '.coffee'],
transform: [
[
require.resolve('./cjsxify'),
require.resolve('coffeeify'),
{},
],
[
Expand Down Expand Up @@ -81,13 +81,15 @@ const preprocessor = (options = {}) => {
// the supported file and spec file to be requested again
return (file) => {
const filePath = file.filePath

debug('get:', filePath)

// since this function can get called multiple times with the same
// filePath, we return the cached bundle promise if we already have one
// since we don't want or need to re-initiate browserify/watchify for it
if (bundles[filePath]) {
debug('already have bundle for:', filePath)

return bundles[filePath]
}

Expand Down Expand Up @@ -123,6 +125,7 @@ const preprocessor = (options = {}) => {
// yield the bundle if onBundle is specified so the user can modify it
// as need via `bundle.external()`, `bundle.plugin()`, etc
const onBundle = options.onBundle

if (typeof onBundle === 'function') {
onBundle(bundler)
}
Expand All @@ -145,6 +148,7 @@ const preprocessor = (options = {}) => {
}

const ws = fs.createWriteStream(outputPath)

ws.on('finish', () => {
debug('finished bundling:', outputPath)
resolve(outputPath)
Expand All @@ -168,6 +172,7 @@ const preprocessor = (options = {}) => {
debug('- update finished for:', filePath)
file.emit('rerun')
})

bundles[filePath] = bundlePromise
// we suppress unhandled rejections so they don't bubble up to the
// unhandledRejection handler and crash the app. Cypress will eventually
Expand Down

0 comments on commit e6d60cb

Please sign in to comment.