speedskater / babel-plugin-rewire

A babel plugin adding the ability to rewire module dependencies. This enables to mock modules for testing purposes.
842 stars 90 forks source link

Question: Rewire JSON file via json-loader #170

Closed vernak2539 closed 7 years ago

vernak2539 commented 7 years ago

Does this support loading JSON file via json-loader;

I'm using webpack, babel, bable-plugin-rewire and the sample code looks like something below. It works when importing js files but not json it seems

de.json

{}

i18n.js

import DE from './de'

....

export default class i18nObject

spec.js

import i18nObject from './i18n'

i18nObject.__Rewire__('DE', { "KEY": 'de-key' });

const i18 = new i18nObject();
// DE is still empty after this happens

i18nObject.__ResetDependency__('DE');
vernak2539 commented 7 years ago

sorry, i was being an idiot. great plugin, by the way