Code Monkey home page Code Monkey logo

jest-svg-transformer's Introduction

jest-svg-transformer

transform svgs for for jest+react to declutter snapshots

jest-svg-transformer's People

Contributors

cwmoo740 avatar

Watchers

 avatar  avatar

Forkers

myst1349

jest-svg-transformer's Issues

Support Jest 27

When upgrading to Jest 27 and using this transform, this is the output:

Jest: a transform must export something

I’m guessing it’s just something tiny about how Jest transform now expects things, like in this breaking change:

[jest-transform] [BREAKING] Do not export ScriptTransformer class, instead export the async function createScriptTransformer (#11163) (source)

Create-react-app support

Hi @cwmoo740,

We are using your transformer within our React native application, right now we are adding support for react native web, thus we are using CRA and they are forcing us to switch from:
import Logo from './logo.svg'; -> import {ReactComponent as Logo} from './logo.svg';
I have also mentioned these changes in this issue

What we need to do is change process.js module.exports to support both exports, default and named:
module.exports = { default: ${name}, ReactComponent: ${name} };

I believe this would not be a breaking change, It would be super cool if I could provide a pull request or if you could implement it.

Here is a quick fix for postinstall npm/yarn script:

"postinstall": "sed -e \"s|module.exports = \\${name};|module.exports = {default: \\${name}, ReactComponent: \\${name}};|g\" -i.bak ./node_modules/jest-svg-transformer/lib/process.js",

Source code

Hi! Would you be willing to add the source code of your NPM module to this repo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.