Git Product home page Git Product logo

bit-emotion-reproduce's Introduction

This repo is a repo to reproduce a bug when trying to transpile source code using @emotion/style. There are 2 folders:

  • using the bable cli
  • using babel programmatic

The source code in both folders (index.js) is the same.

running the cli version:

cd babel-cli
npm i
npm run build

running the programmatic version:

cd babel-programmatic
npm i
node run-babel.js

when running the cli version, everything works fine. When running the programmatic version you will see an error:

/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:341
  var finalPath = filename === rootPath ? 'root' : filename.slice(rootPath.length);
                                                            ^

TypeError: Cannot read property 'slice' of undefined
    at getTargetClassName (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:341:61)
    at getStyledOptions (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:515:78)
    at /private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:685:54
    at Array.forEach (<anonymous>)
    at /private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:643:26
    at Object.macroWrapper [as @emotion/styled] (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-macros/dist/index.js:61:12)
    at PluginPass.ImportDeclaration (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/babel-plugin-emotion/dist/babel-plugin-emotion.cjs.dev.js:891:45)
    at newFn (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/@babel/traverse/lib/visitors.js:193:21)
    at NodePath._call (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/@babel/traverse/lib/path/context.js:53:20)
    at NodePath.call (/private/tmp/bit-emotion-reproduce/babel-programmatic/node_modules/@babel/traverse/lib/path/context.js:40:17)

Removing those lines from the source code, will make the error go away:

const Container = styled.div`
  height: ${({ size }) => size ? `${size}rem` : `100%`};
  width: ${({ size }) => size ? `${size}rem` : `100%`};
  animation: ${fullSpin} 750ms linear infinite;
  margin: 0 auto;
`

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.