Skip to content
This repository was archived by the owner on Aug 20, 2018. It is now read-only.

[v0.5.5] : JSON Object gets exported with default key (harmony export) #54

Closed
sasidhar opened this issue Jul 22, 2017 · 1 comment
Closed

Comments

@sasidhar
Copy link

sasidhar commented Jul 22, 2017

Example :
sample.json

{
   "key1": "value1",
   "key2": "value2"
}

Usage

let data = require('./sample.json');
console.log(data);

With json-loader 0.5.4

{
    "key1": "value1",
    "key2": "value2"
}

With json-loader 0.5.5 : It is adding a wrapper object with key : 'default'.

{
    "default": {
        "key1": "value1",
        "key2": "value2"
    }
}

With this existing code is breaking.

FYI : Using https://github.com/AngularClass/angular-starter

@michael-ciniawsky
Copy link
Member

michael-ciniawsky commented Jul 22, 2017

@sasidhar Angular Starter uses webpack >= v2.0.0, which has native JSON support. This is a bug in Angular Starter aswell, so please open an issue there to remove json-loader from the seed :) The line causing this is here and needs to be reverted to

var module = `module.exports = ${value}`

Ideally with a ⚠️ warning in case this.version >= 2, I will send PR asap :)

@michael-ciniawsky michael-ciniawsky changed the title json-loader version 0.5.5 : JSON Object - default key [v0.5.5] : JSON Object gets exported with default key (harmony export) Jul 22, 2017
@michael-ciniawsky michael-ciniawsky added this to the 0.5.6 milestone Jul 22, 2017
gre added a commit to gre/gl-react that referenced this issue Jul 26, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants