Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

svgo 2 throws "SVGO is not a constructor" #193

Open
timiyay opened this issue May 3, 2021 · 3 comments
Open

svgo 2 throws "SVGO is not a constructor" #193

timiyay opened this issue May 3, 2021 · 3 comments
Labels

Comments

@timiyay
Copy link

timiyay commented May 3, 2021

🐞 Bug Report

Describe the bug

Our Ember app supplies its own version of svgo to ember-svg-jar, via the optimizer config option: https://github.com/ivanvotti/ember-svg-jar/blob/master/docs/configuration.md#optimizer-can-be-redefined-on-a-strategy-level

If we try to upgrade our app's version of svgo to >=2 (https://github.com/svg/svgo/releases/tag/v2.0.0), our app no longer builds. It throws an error SVGO is not a constructor.

Full Stack Trace
TypeError: SVGO is not a constructor
at new SVGOFilter (my-ember-app/node_modules/broccoli-svg-optimizer/index.js:49:16)
at Class.optimizedSvgsFor (my-ember-app/node_modules/ember-svg-jar/lib/index.js:114:12)
at Class.svgsFor (my-ember-app/node_modules/ember-svg-jar/lib/index.js:125:14)
at Class.getInlineStrategyTree (my-ember-app/node_modules/ember-svg-jar/lib/index.js:155:34)
at Class.treeForAddon (my-ember-app/node_modules/ember-svg-jar/lib/index.js:68:23)
at Class.superWrapper (my-ember-app/node_modules/core-object/lib/assign-properties.js:34:20)
at Class._treeFor (my-ember-app/node_modules/ember-cli/lib/models/addon.js:668:33)
at Class.treeFor (my-ember-app/node_modules/ember-cli/lib/models/addon.js:628:21)
at my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:701:26
at Array.reduce (<anonymous>:null:null)
at EmberApp._addonTreesFor (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:699:32)
at EmberApp._addonBundles (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1112:31)
at EmberApp.createAddonTree (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1125:29)
at EmberApp.addonTree (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1143:36)
at EmberApp.getExternalTree (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1191:25)
at EmberApp.toArray (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1543:12)
at EmberApp.toTree (my-ember-app/node_modules/ember-cli/lib/broccoli/ember-app.js:1647:36)
at EmberApp.appInstance.toTree (my-ember-app/node_modules/ember-cli-mirage/node_modules/@embroider/macros/src/ember-addon-main.js:48:35)
at EmberApp.appInstance.toTree (my-ember-app/node_modules/@embroider/macros/src/ember-addon-main.js:48:35)
at EmberApp.appInstance.toTree (my-ember-app/node_modules/ember-exam/node_modules/@embroider/macros/src/ember-addon-main.js:48:35)
at module.exports (my-ember-app/ember-cli-build.js:186:16)
at Builder.readBuildFile (my-ember-app/node_modules/ember-cli/lib/models/builder.js:49:14)
at Builder.setupBroccoliBuilder (my-ember-app/node_modules/ember-cli/lib/models/builder.js:63:22)
at new Builder (my-ember-app/node_modules/ember-cli/lib/models/builder.js:29:10)
at BuildTask.run (my-ember-app/node_modules/ember-cli/lib/tasks/build.js:13:19)
at my-ember-app/node_modules/ember-cli/lib/models/command.js:238:24
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at Class.run (my-ember-app/node_modules/ember-cli/lib/commands/build.js:29:5)
at my-ember-app/node_modules/ember-cli/lib/cli/cli.js:204:32
at CLI.run (my-ember-app/node_modules/ember-cli/lib/cli/cli.js:251:14)
at module.exports (my-ember-app/node_modules/ember-cli/lib/cli/index.js:145:12)

Reproduce the bug

// package.json
{
  "devDependencies": {
    "ember-svg-jar": "^2.3.3",
    "svgo": "^2.0.0"
  }
}
// ember-cli-build.js
const svgoModule = require('svgo')

const app = new EmberApp(defaults, {
  svgJar: {
    optimizer: { svgoModule }
  }
}

Expected behavior

Ember app builds should not crash, and SVGs should render as normal.

@timiyay timiyay added the bug label May 3, 2021
@jherdman
Copy link
Collaborator

jherdman commented Feb 8, 2022

It's my intention to migrate this addon to v2 once I sort out a few test failures with the current code. If you're interested, a pull request migrating to v2 would be accepted as well.

@NullVoxPopuli
Copy link

I just ran in to this with svgo 3 -- seems still a problem.

@evoactivity
Copy link
Owner

@bertdeblock was working on a PR to upgrade svgo but it looks like he closed it
#256

Any plans to revisit this, what was the reason you closed the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants