diff --git a/packages/parcel-plugin-svgr/package.json b/packages/parcel-plugin-svgr/package.json index 12d6733b..2d08cfb2 100644 --- a/packages/parcel-plugin-svgr/package.json +++ b/packages/parcel-plugin-svgr/package.json @@ -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", diff --git a/packages/parcel-plugin-svgr/src/asset.js b/packages/parcel-plugin-svgr/src/asset.js index 081af60c..0a4617bd 100644 --- a/packages/parcel-plugin-svgr/src/asset.js +++ b/packages/parcel-plugin-svgr/src/asset.js @@ -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' @@ -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,