babel-plugin-inline-react-svg: [Bugs] 0.5.2 breaking change: Path must be a string. Received undefined

Description

I have been working on a coworker implementation that uses this plugin though I don’t really know about it except my coworker use to have it working.

Reproduction

https://travis-ci.org/yeutech-lab/rollup-umd-documentation/jobs/403153237#L1155

This guy helped me found the error: https://github.com/splunk/battlecat-poll/issues/3

Proposed solution

Downgrade to 0.5.1:

$ npm uninstall babel-plugin-inline-react-svg --save-dev \
  && npm install babel-plugin-inline-react-svg@0.5.1 --save-dev 

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 18

Commits related to this issue

Most upvoted comments

v0.5.4 is released.

Thanks, that pinpointed it - export const pkg = require(path.join(pkgBase, 'package.json')); (ie, a dynamic require) broke it. I should be able to make a test case from that.

TypeError: Cannot create property '_babel' on string '[ undefined,
  [ Node {
      type: 'CallExpression',
      start: 615,
      end: 649,
      loc: [SourceLocation],
      callee: [Node],
      arguments: [Array] } ],
  Node {
    type: 'CallExpression',
    start: 607,
    end: 650,
    loc: SourceLocation { start: [Position], end: [Position] },
    callee:
     Node {
       type: 'Identifier',
       start: 607,
       end: 614,
       loc: [SourceLocation],
       name: 'require' },
    arguments: [ [Node] ] },
  [ Node {
      type: 'Identifier',
      start: 625,
      end: 632,
      loc: [SourceLocation],
      name: 'pkgBase' },
    Node {
      type: 'StringLiteral',
      start: 634,
      end: 648,
      loc: [SourceLocation],
      extra: [Object],
      value: 'package.json' } ] ]'
    at File.wrap (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-core/lib/transformation/file/index.js:538:20)
    at Pipeline.transform (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-core/lib/transformation/pipeline.js:47:17)
    at transform (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/util.js:50:22)
    at Object.compile (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/util.js:59:12)
    at write (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/dir.js:21:21)
    at handleFile (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/dir.js:43:7)
    at /home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/dir.js:61:9
    at Array.forEach (<anonymous>)
    at handle (/home/dka/workspace/github.com/yeutech-lab/rollup-umd-documentation/node_modules/babel-cli/lib/babel/dir.js:59:29)
    at Array.forEach (<anonymous>)

I didn’t realize but it is possible for you to validate your fix prior release because the project is on GitHub, see how we fixed the 0.5.1 here: https://github.com/yeutech-lab/rollup-umd-documentation/blob/master/package.json#L172