Skip to content

Commit

Permalink
fix(parcel-plugin): support "parcel" and "parcel-bundler"
Browse files Browse the repository at this point in the history
Closes #410
  • Loading branch information
gregberge committed Mar 22, 2020
1 parent 928ee77 commit 853db4e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
3 changes: 0 additions & 3 deletions packages/parcel-plugin-svgr/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,6 @@
"build": "babel --config-file ../../babel.config.js -d lib --ignore \"**/*.test.js\" src",
"prepublishOnly": "yarn run build"
},
"peerDependencies": {
"parcel": "^1.10.0"
},
"dependencies": {
"@babel/core": "^7.7.5",
"@babel/plugin-transform-react-constant-elements": "^7.7.4",
Expand Down
13 changes: 12 additions & 1 deletion packages/parcel-plugin-svgr/src/asset.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { Asset } from 'parcel'
import { transformAsync, createConfigItem } from '@babel/core'
import svgo from '@svgr/plugin-svgo'
import jsx from '@svgr/plugin-jsx'
Expand All @@ -7,6 +6,18 @@ import presetReact from '@babel/preset-react'
import presetEnv from '@babel/preset-env'
import pluginTransformReactConstantElements from '@babel/plugin-transform-react-constant-elements'

/* eslint-disable global-require, import/no-unresolved */
function requireParcel() {
try {
return require('parcel')
} catch (error) {
return require('parcel-bundler')
}
}
/* eslint-enable global-require, import/no-unresolved */

const { Asset } = requireParcel()

const babelOptions = {
babelrc: false,
configFile: false,
Expand Down

1 comment on commit 853db4e

@vercel
Copy link

@vercel vercel bot commented on 853db4e Mar 22, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.