Skip to content

Commit

Permalink
fix: align named export with v2
Browse files Browse the repository at this point in the history
  • Loading branch information
felixmosh committed Sep 18, 2023
1 parent f99e651 commit c931611
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __tests__/webpack/server-hmr.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ jest.mock('../../lib/webpack/trigger.js', () => {
return changedData;
});
const applyServerHMR = require('../../lib/webpack/server-hmr');
const plugin = require('../../lib/webpack/plugin');
const plugin = require('../../lib/webpack/plugin').I18NextHMRPlugin;

function whenNativeHMRTriggeredWith(changedFiles) {
changedData.changedFiles = changedFiles;
Expand Down
14 changes: 7 additions & 7 deletions lib/webpack/plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const DEFAULT_OPTIONS = {
localesDirs: [],
};

class I18nextHMRPlugin {
class I18NextHMRPlugin {
constructor(options) {
this.options = { ...DEFAULT_OPTIONS, ...options };
this.options.localesDirs = []
Expand Down Expand Up @@ -64,7 +64,7 @@ class I18nextHMRPlugin {

this.lastUpdate = { changedFiles };

I18nextHMRPlugin.callbacks.forEach((cb) => cb({ changedFiles }));
I18NextHMRPlugin.callbacks.forEach((cb) => cb({ changedFiles }));
});

compiler.hooks.normalModuleFactory.tap(pluginName, (nmf) => {
Expand All @@ -87,11 +87,11 @@ class I18nextHMRPlugin {
}
}

I18nextHMRPlugin.callbacks = [];
I18NextHMRPlugin.callbacks = [];

I18nextHMRPlugin.addListener = function (cb) {
I18nextHMRPlugin.callbacks.length = 0;
I18nextHMRPlugin.callbacks.push(cb);
I18NextHMRPlugin.addListener = function (cb) {
I18NextHMRPlugin.callbacks.length = 0;
I18NextHMRPlugin.callbacks.push(cb);
};

module.exports = I18nextHMRPlugin;
module.exports.I18NextHMRPlugin = I18NextHMRPlugin;
2 changes: 1 addition & 1 deletion lib/webpack/server-hmr.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = function applyServerHMR(i18nOrGetter) {
} else {
logOnce(`Server HMR has started - callback mode`);

const HMRPlugin = require('./plugin');
const HMRPlugin = require('./plugin').I18NextHMRPlugin;
HMRPlugin.addListener(reloadServerTranslation);
}
};

0 comments on commit c931611

Please sign in to comment.