Re-exported JSON imports are undefined

Do you want to request a feature or report a bug?

What is the current behavior?
I have a module that imports some JSON objects and re-exports them as named exports, e.g.:

import someJson1 from './some-json-1';
import someJson2 from './some-json-2';

export {

Then when I import these exports in another module they are undefined, e.g.:

import { someJson1, someJson2 } from 'jsonModule';

someJson1 and someJson2 are now undefined.

However, the two imports are valid within the jsonModule, and if I copy them to local variables and then export those then it does work, e.g.:

import someJson1_ from './some-json-1';
import someJson2_ from './some-json-2';

const someJson1 = someJson1_;
const someJson2 = someJson2_;

export {

Now when I import these exports in an other module (as above) they are no longer undefined.

If the current behavior is a bug, please provide the steps to reproduce.
See current behaviour above

What is the expected behavior?
I expect imported JSON should be able to be re-exported without it being undefined, and without having to copy the imports before re-exporting them.

Please mention other relevant information such as the browser version, Node.js version, webpack version, and Operating System.
macOS 10.13.3 (17D102)
node v9.7.1

Author: Fantashit

3 thoughts on “Re-exported JSON imports are undefined

  1. a.json

       "nameA": "A"


       "nameB": "B"


    export * from './a.json'
    export * from './b.json'


    import * as ns from './x.js'  
    import { nameA, nameB } from './x.js'  
    import { a, b } from './x.js'  
    console.log(nameA, nameB)
    // => 'A', 'B'
    console.log(ns.nameA, ns.nameB)
    // => 'A', 'B'

    Otherwise you need to reassign it


    import a from './a.json'
    import b from './b.json'
    const c = Object.assign({}, a, b)
    export default c


    import c from './c.js'  
    import { nameA, nameB } from './c.js'  
    // => { nameA: '', nameB: '' } {Object}

    ES Modules (especially export) syntax is very weird… 😛

  2. Is the bug related to the fact that what I was attempting works in production mode, or that it doesn’t work in development mode?

Comments are closed.