webpack-contrib / json-loader

json loader module for webpack - UNMAINTAINED

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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

sasidhar opened this issue · comments

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

@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 :)