next-intl 4.0.0-beta-9e73cbe → 4.0.0-beta-c4c5986
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/development/plugin.cjs +19 -4
- package/dist/esm/development/plugin/createMessagesDeclaration.js +3 -4
- package/dist/esm/development/plugin/watchFile.js +21 -0
- package/dist/esm/production/plugin/createMessagesDeclaration.js +1 -1
- package/dist/esm/production/plugin/watchFile.js +1 -0
- package/dist/types/plugin/watchFile.d.ts +6 -0
- package/package.json +3 -3
|
@@ -13,6 +13,23 @@ function warn(message) {
|
|
|
13
13
|
console.warn(formatMessage(message));
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Wrapper around `fs.watch` that provides a workaround
|
|
18
|
+
* for https://github.com/nodejs/node/issues/5039.
|
|
19
|
+
*/
|
|
20
|
+
function watchFile(filepath, callback) {
|
|
21
|
+
const directory = path.dirname(filepath);
|
|
22
|
+
const filename = path.basename(filepath);
|
|
23
|
+
return fs.watch(directory, {
|
|
24
|
+
persistent: false,
|
|
25
|
+
recursive: false
|
|
26
|
+
}, (event, changedFilename) => {
|
|
27
|
+
if (changedFilename === filename) {
|
|
28
|
+
callback();
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
|
|
16
33
|
function runOnce(fn) {
|
|
17
34
|
if (process.env._NEXT_INTL_COMPILE_MESSAGES === '1') {
|
|
18
35
|
return;
|
|
@@ -43,10 +60,8 @@ function createMessagesDeclaration(messagesPath) {
|
|
|
43
60
|
});
|
|
44
61
|
}
|
|
45
62
|
function startWatching(messagesPath) {
|
|
46
|
-
const watcher =
|
|
47
|
-
|
|
48
|
-
compileDeclaration(messagesPath, true);
|
|
49
|
-
}
|
|
63
|
+
const watcher = watchFile(messagesPath, () => {
|
|
64
|
+
compileDeclaration(messagesPath, true);
|
|
50
65
|
});
|
|
51
66
|
process.on('exit', () => {
|
|
52
67
|
watcher.close();
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import fs from 'fs';
|
|
2
2
|
import path from 'path';
|
|
3
3
|
import { throwError } from './utils.js';
|
|
4
|
+
import watchFile from './watchFile.js';
|
|
4
5
|
|
|
5
6
|
function runOnce(fn) {
|
|
6
7
|
if (process.env._NEXT_INTL_COMPILE_MESSAGES === '1') {
|
|
@@ -32,10 +33,8 @@ function createMessagesDeclaration(messagesPath) {
|
|
|
32
33
|
});
|
|
33
34
|
}
|
|
34
35
|
function startWatching(messagesPath) {
|
|
35
|
-
const watcher =
|
|
36
|
-
|
|
37
|
-
compileDeclaration(messagesPath, true);
|
|
38
|
-
}
|
|
36
|
+
const watcher = watchFile(messagesPath, () => {
|
|
37
|
+
compileDeclaration(messagesPath, true);
|
|
39
38
|
});
|
|
40
39
|
process.on('exit', () => {
|
|
41
40
|
watcher.close();
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Wrapper around `fs.watch` that provides a workaround
|
|
6
|
+
* for https://github.com/nodejs/node/issues/5039.
|
|
7
|
+
*/
|
|
8
|
+
function watchFile(filepath, callback) {
|
|
9
|
+
const directory = path.dirname(filepath);
|
|
10
|
+
const filename = path.basename(filepath);
|
|
11
|
+
return fs.watch(directory, {
|
|
12
|
+
persistent: false,
|
|
13
|
+
recursive: false
|
|
14
|
+
}, (event, changedFilename) => {
|
|
15
|
+
if (changedFilename === filename) {
|
|
16
|
+
callback();
|
|
17
|
+
}
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { watchFile as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"fs";import t from"path";import{throwError as s}from"./utils.js";function
|
|
1
|
+
import e from"fs";import t from"path";import{throwError as s}from"./utils.js";import n from"./watchFile.js";function o(o){const r=t.resolve(o);e.existsSync(r)||s(`\`createMessagesDeclaration\` points to a non-existent file: ${r}`),r.endsWith(".json")||s(`\`createMessagesDeclaration\` needs to point to a JSON file. Received: ${r}`);const c=process.env["NODE_ENV".trim()];var a;a=()=>{i(o),"development"===c&&function(e){const t=n(e,(()=>{i(e,!0)}));process.on("exit",(()=>{t.close()}))}(o)},"1"!==process.env._NEXT_INTL_COMPILE_MESSAGES&&(process.env._NEXT_INTL_COMPILE_MESSAGES="1",a())}function i(t,s=!1){const n=t.replace(/\.json$/,".d.json.ts");function o(e){return`// This file is auto-generated by next-intl, do not edit directly.\n// See: https://next-intl.dev/docs/workflows/typescript#messages-arguments\n\ndeclare const messages: ${e.trim()};\nexport default messages;`}if(s)return e.promises.readFile(t,"utf-8").then((t=>e.promises.writeFile(n,o(t))));const i=e.readFileSync(t,"utf-8");e.writeFileSync(n,o(i))}export{o as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"fs";import t from"path";function e(e,a){const n=t.dirname(e),o=t.basename(e);return r.watch(n,{persistent:!1,recursive:!1},((r,t)=>{t===o&&a()}))}export{e as default};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intl",
|
|
3
|
-
"version": "4.0.0-beta-
|
|
3
|
+
"version": "4.0.0-beta-c4c5986",
|
|
4
4
|
"sideEffects": false,
|
|
5
5
|
"author": "Jan Amann <jan@amann.work>",
|
|
6
6
|
"funding": [
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"dependencies": {
|
|
113
113
|
"@formatjs/intl-localematcher": "^0.5.4",
|
|
114
114
|
"negotiator": "^1.0.0",
|
|
115
|
-
"use-intl": "4.0.0-beta-
|
|
115
|
+
"use-intl": "4.0.0-beta-c4c5986"
|
|
116
116
|
},
|
|
117
117
|
"peerDependencies": {
|
|
118
118
|
"next": "^12.0.0 || ^13.0.0 || ^14.0.0 || ^15.0.0",
|
|
@@ -124,5 +124,5 @@
|
|
|
124
124
|
"optional": true
|
|
125
125
|
}
|
|
126
126
|
},
|
|
127
|
-
"gitHead": "
|
|
127
|
+
"gitHead": "a73e83b96977b9e56b1ea8fadcf4c67505d7c7d3"
|
|
128
128
|
}
|