Skip to content

Babel transpile on Import statement with query string not working as expected #416

@ask-imran

Description

@ask-imran

Hey everyone,

I have got a react app which uses svg-react-loader and in the import statements that import svg I have a querystring for the componentName. During webpack build the babel loader resolves everything and is working as expected.

But, when I try to run babel transpile via the cli just to transpile the files alone, I end up in a strange behavior,

import MyLogo from 'images/mylogo.svg?name=MyLogo';

I have got resolve set to src in webpack which allows me to provide the above path. but babel transpile results as below,

var _mylogo = require('images/mylogo.svg?name=MyLogo');

my expected output would be,

var _mylogo = require('../images/mylogo.svg?name=MyLogo');

If I remove the query string in the import statement it transpiles to what I expect. with query string it doesn't. Is there a config or something I am missing ? I am also using Module-resolver plugin in babel.

React version : 15.6
Babel version: 6.26.3

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions