i18next-hmr
Advanced tools
Comparing version 1.6.3 to 1.7.0
@@ -23,17 +23,7 @@ --- | ||
**Screenshots** | ||
If applicable, add screenshots to help explain your problem. | ||
**Desktop (please complete the following information):** | ||
**please complete the following information:** | ||
- OS: [e.g. iOS] | ||
- Browser [e.g. chrome, safari] | ||
- Version [e.g. 22] | ||
- Version: [e.g. 1.x] | ||
**Smartphone (please complete the following information):** | ||
- Device: [e.g. iPhone6] | ||
- OS: [e.g. iOS8.1] | ||
- Browser [e.g. stock browser, safari] | ||
- Version [e.g. 22] | ||
**Additional context** | ||
Add any other context about the problem here. |
@@ -7,2 +7,11 @@ ### Changelog | ||
#### [v1.7.0](https://github.com/felixmosh/i18next-hmr/compare/v1.6.3...v1.7.0) | ||
- Bump ini from 1.3.5 to 1.3.8 in /examples/razzle-ssr [`#24`](https://github.com/felixmosh/i18next-hmr/pull/24) | ||
- Bump ini from 1.3.5 to 1.3.8 in /examples/next-with-next-i18next-without-custom-server [`#25`](https://github.com/felixmosh/i18next-hmr/pull/25) | ||
- Add webpack 5 support, closes #26 [`#26`](https://github.com/felixmosh/i18next-hmr/issues/26) | ||
- Bump deps [`55d8773`](https://github.com/felixmosh/i18next-hmr/commit/55d87739f4b3c1cdb7fa34f62764a5688ab416ac) | ||
- Bump dev-deps [`d4604c9`](https://github.com/felixmosh/i18next-hmr/commit/d4604c9f96db9fe50e85b68ad74d16b2174dfa4e) | ||
- Update bug_report.md [`eb78fd1`](https://github.com/felixmosh/i18next-hmr/commit/eb78fd1a79af33f8ca6bc76fe38736a39aa08931) | ||
#### [v1.6.3](https://github.com/felixmosh/i18next-hmr/compare/v1.6.2...v1.6.3) | ||
@@ -16,3 +25,3 @@ | ||
- Update issue templates [`e983cb8`](https://github.com/felixmosh/i18next-hmr/commit/e983cb86aa0329b4745623c85c5d8f7493dd52c2) | ||
- Update README.md [`88693fd`](https://github.com/felixmosh/i18next-hmr/commit/88693fd7b4d5aee062c5ad6bd86d07e43251acd8) | ||
- Release 1.6.3 [`448c2ee`](https://github.com/felixmosh/i18next-hmr/commit/448c2ee0cb8ce5af6bf0fa4074a506377e9f3190) | ||
@@ -19,0 +28,0 @@ #### [v1.6.2](https://github.com/felixmosh/i18next-hmr/compare/v1.6.1...v1.6.2) |
@@ -1,5 +0,6 @@ | ||
const pluginName = 'I18nextHMRPlugin'; | ||
const path = require('path'); | ||
const fs = require('fs'); | ||
const pluginName = 'I18nextHMRPlugin'; | ||
const DEFAULT_OPTIONS = { | ||
@@ -12,6 +13,8 @@ localesDir: '', | ||
this.options = { ...DEFAULT_OPTIONS, ...options }; | ||
this.lastUpdate = {}; | ||
this.lastUpdate = { changedFiles: [] }; | ||
} | ||
apply(compiler) { | ||
const isWebpack5 = compiler.webpack ? parseInt(compiler.webpack.version, 10) === 5 : false; | ||
compiler.hooks.beforeCompile.tapAsync(pluginName, (params, callback) => { | ||
@@ -25,10 +28,16 @@ if (fs.existsSync(this.options.localesDir)) { | ||
compiler.hooks.watchRun.tap(pluginName, (compiler) => { | ||
const changedTimes = isWebpack5 | ||
? compiler.watchFileSystem.watcher.getTimes() | ||
: (compiler.watchFileSystem.wfs || compiler.watchFileSystem).watcher.mtimes; | ||
const changedTimes = (compiler.watchFileSystem.wfs || compiler.watchFileSystem).watcher | ||
.mtimes || {}; | ||
const { startTime = 0 } = compiler.watchFileSystem.watcher; | ||
const files = Object.keys(changedTimes).filter((file) => | ||
file.includes(this.options.localesDir) | ||
); | ||
const files = Object.keys(changedTimes).filter((file) => { | ||
const fileExt = path.extname(file); | ||
return ( | ||
file.includes(this.options.localesDir) && !!fileExt && changedTimes[file] > startTime | ||
); | ||
}); | ||
if (!files.length) { | ||
@@ -52,3 +61,3 @@ return; | ||
compiler.hooks.normalModuleFactory.tap(pluginName, (nmf) => { | ||
nmf.hooks.afterResolve.tap(pluginName, (module) => { | ||
nmf.hooks.createModule.tap(pluginName, (module) => { | ||
const triggerPath = path.resolve(__dirname, 'trigger.js'); | ||
@@ -55,0 +64,0 @@ if (module.resource !== triggerPath) { |
{ | ||
"name": "i18next-hmr", | ||
"version": "1.6.3", | ||
"version": "1.7.0", | ||
"description": "I18Next HMR webpack plugin that allows reloading translation resources on the client & the server.", | ||
@@ -28,8 +28,8 @@ "homepage": "https://github.com/felixmosh/i18next-hmr", | ||
"devDependencies": { | ||
"@types/jest": "^25.1.4", | ||
"@types/node": "^13.9.2", | ||
"auto-changelog": "^2.0.0", | ||
"jest": "^26.0.1", | ||
"prettier": "^2.0.5", | ||
"release-it": "^13.6.6" | ||
"@types/jest": "^25.2.3", | ||
"@types/node": "^13.13.38", | ||
"auto-changelog": "^2.2.1", | ||
"jest": "^26.6.3", | ||
"prettier": "^2.2.1", | ||
"release-it": "^13.7.1" | ||
}, | ||
@@ -36,0 +36,0 @@ "jest": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26015
211