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

Strict mode #155

Open
Turbo87 opened this issue Apr 10, 2020 · 2 comments
Open

Strict mode #155

Turbo87 opened this issue Apr 10, 2020 · 2 comments

Comments

@Turbo87
Copy link
Contributor

Turbo87 commented Apr 10, 2020

🍩 Feature Request

Is your feature request related to a problem? Please describe.

In a few of our apps the testing setup is a little incomplete which sometimes causes "svg could not be found" warnings on the console. I'd like to ensure that such warnings are not ignored, by making the test fail when an inlined SVG could not be found.

Describe the solution you'd like

I was thinking that maybe a strict: true/false option could be added to the svgJar object in the ember-cli-build.js file. To not make this a breaking change it would be false by default, but people could set it to true for their dev and test environment builds.

The makeSvg() helper would then look at the state of that flag and either console.warn() like we do today, or throw new Error() if strict is true.

Describe alternatives you've considered

export function enableStrictSvgJar() {
  let originalWarn = console.warn;
  console.warn = function (...args) {
    if (args.length > 0 && args[0].startsWith('ember-svg-jar: ')) {
      throw new Error(args[0]);
    }

    originalWarn.call(console, ...args);
  };
}

I've hacked it together for now, but this is probably not a good long-term solution to the problem.

Additional context

@voltidev
Copy link
Collaborator

voltidev commented Apr 10, 2020

That makes sense. Please feel free to make a PR for the feature. And let me know if something is not clear in the addon's code.

@Turbo87
Copy link
Contributor Author

Turbo87 commented Apr 10, 2020

hmm, thinking some more about this, I guess it would also be nice if in production mode we could trigger a Sentry error report instead of showing the warnings, so maybe it would be better to generally be able to overwrite the warning handler. 🤔

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

No branches or pull requests

2 participants