@lingo.dev/_compiler 0.1.11 → 0.1.12
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/build/index.cjs +34 -2
- package/build/index.mjs +34 -2
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -4,7 +4,7 @@ var _unplugin = require('unplugin');
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.12",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -624,6 +624,33 @@ var LCP = class _LCP {
|
|
|
624
624
|
this.filePath = filePath;
|
|
625
625
|
this.data = data;
|
|
626
626
|
}
|
|
627
|
+
static ensureFile(params) {
|
|
628
|
+
const filePath = path.resolve(
|
|
629
|
+
process.cwd(),
|
|
630
|
+
params.sourceRoot,
|
|
631
|
+
params.lingoDir,
|
|
632
|
+
LCP_FILE_NAME
|
|
633
|
+
);
|
|
634
|
+
if (!fs.existsSync(filePath)) {
|
|
635
|
+
const dir = path.dirname(filePath);
|
|
636
|
+
if (!fs.existsSync(dir)) {
|
|
637
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
638
|
+
}
|
|
639
|
+
fs.writeFileSync(filePath, "{}");
|
|
640
|
+
console.log(_dedent2.default`
|
|
641
|
+
\n
|
|
642
|
+
⚠️ Lingo.dev Compiler detected missing meta.json file in lingo directory.
|
|
643
|
+
Please restart the build / watch command to regenerate all Lingo.dev Compiler files.
|
|
644
|
+
`);
|
|
645
|
+
try {
|
|
646
|
+
fs.rmdirSync(path.resolve(process.cwd(), ".next"), {
|
|
647
|
+
recursive: true
|
|
648
|
+
});
|
|
649
|
+
} catch (error) {
|
|
650
|
+
}
|
|
651
|
+
process.exit(1);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
627
654
|
static getInstance(params) {
|
|
628
655
|
const filePath = path.resolve(
|
|
629
656
|
process.cwd(),
|
|
@@ -639,6 +666,9 @@ var LCP = class _LCP {
|
|
|
639
666
|
// wait until LCP file stops updating
|
|
640
667
|
// this ensures all files were transformed before loading / translating dictionaries
|
|
641
668
|
static async ready(params) {
|
|
669
|
+
if (params.isDev) {
|
|
670
|
+
_LCP.ensureFile(params);
|
|
671
|
+
}
|
|
642
672
|
const filePath = path.resolve(
|
|
643
673
|
process.cwd(),
|
|
644
674
|
params.sourceRoot,
|
|
@@ -2339,6 +2369,7 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
2339
2369
|
sourceRoot: params.sourceRoot,
|
|
2340
2370
|
lingoDir: params.lingoDir
|
|
2341
2371
|
});
|
|
2372
|
+
const isDev = "dev" in _meta ? !!_meta.dev : process.env.NODE_ENV !== "production";
|
|
2342
2373
|
return {
|
|
2343
2374
|
name: package_default.name,
|
|
2344
2375
|
loadInclude: (id) => !!id.match(LCP_DICTIONARY_FILE_NAME),
|
|
@@ -2346,7 +2377,8 @@ var unplugin = _unplugin.createUnplugin.call(void 0,
|
|
|
2346
2377
|
const moduleInfo = parseParametrizedModuleId(id);
|
|
2347
2378
|
const lcpParams = {
|
|
2348
2379
|
sourceRoot: params.sourceRoot,
|
|
2349
|
-
lingoDir: params.lingoDir
|
|
2380
|
+
lingoDir: params.lingoDir,
|
|
2381
|
+
isDev
|
|
2350
2382
|
};
|
|
2351
2383
|
await LCP.ready(lcpParams);
|
|
2352
2384
|
const lcp = LCP.getInstance(lcpParams);
|
package/build/index.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import { createUnplugin } from "unplugin";
|
|
|
4
4
|
// package.json
|
|
5
5
|
var package_default = {
|
|
6
6
|
name: "@lingo.dev/_compiler",
|
|
7
|
-
version: "0.1.
|
|
7
|
+
version: "0.1.12",
|
|
8
8
|
description: "Lingo.dev Compiler",
|
|
9
9
|
private: false,
|
|
10
10
|
publishConfig: {
|
|
@@ -624,6 +624,33 @@ var LCP = class _LCP {
|
|
|
624
624
|
this.filePath = filePath;
|
|
625
625
|
this.data = data;
|
|
626
626
|
}
|
|
627
|
+
static ensureFile(params) {
|
|
628
|
+
const filePath = path.resolve(
|
|
629
|
+
process.cwd(),
|
|
630
|
+
params.sourceRoot,
|
|
631
|
+
params.lingoDir,
|
|
632
|
+
LCP_FILE_NAME
|
|
633
|
+
);
|
|
634
|
+
if (!fs.existsSync(filePath)) {
|
|
635
|
+
const dir = path.dirname(filePath);
|
|
636
|
+
if (!fs.existsSync(dir)) {
|
|
637
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
638
|
+
}
|
|
639
|
+
fs.writeFileSync(filePath, "{}");
|
|
640
|
+
console.log(dedent`
|
|
641
|
+
\n
|
|
642
|
+
⚠️ Lingo.dev Compiler detected missing meta.json file in lingo directory.
|
|
643
|
+
Please restart the build / watch command to regenerate all Lingo.dev Compiler files.
|
|
644
|
+
`);
|
|
645
|
+
try {
|
|
646
|
+
fs.rmdirSync(path.resolve(process.cwd(), ".next"), {
|
|
647
|
+
recursive: true
|
|
648
|
+
});
|
|
649
|
+
} catch (error) {
|
|
650
|
+
}
|
|
651
|
+
process.exit(1);
|
|
652
|
+
}
|
|
653
|
+
}
|
|
627
654
|
static getInstance(params) {
|
|
628
655
|
const filePath = path.resolve(
|
|
629
656
|
process.cwd(),
|
|
@@ -639,6 +666,9 @@ var LCP = class _LCP {
|
|
|
639
666
|
// wait until LCP file stops updating
|
|
640
667
|
// this ensures all files were transformed before loading / translating dictionaries
|
|
641
668
|
static async ready(params) {
|
|
669
|
+
if (params.isDev) {
|
|
670
|
+
_LCP.ensureFile(params);
|
|
671
|
+
}
|
|
642
672
|
const filePath = path.resolve(
|
|
643
673
|
process.cwd(),
|
|
644
674
|
params.sourceRoot,
|
|
@@ -2339,6 +2369,7 @@ var unplugin = createUnplugin(
|
|
|
2339
2369
|
sourceRoot: params.sourceRoot,
|
|
2340
2370
|
lingoDir: params.lingoDir
|
|
2341
2371
|
});
|
|
2372
|
+
const isDev = "dev" in _meta ? !!_meta.dev : process.env.NODE_ENV !== "production";
|
|
2342
2373
|
return {
|
|
2343
2374
|
name: package_default.name,
|
|
2344
2375
|
loadInclude: (id) => !!id.match(LCP_DICTIONARY_FILE_NAME),
|
|
@@ -2346,7 +2377,8 @@ var unplugin = createUnplugin(
|
|
|
2346
2377
|
const moduleInfo = parseParametrizedModuleId(id);
|
|
2347
2378
|
const lcpParams = {
|
|
2348
2379
|
sourceRoot: params.sourceRoot,
|
|
2349
|
-
lingoDir: params.lingoDir
|
|
2380
|
+
lingoDir: params.lingoDir,
|
|
2381
|
+
isDev
|
|
2350
2382
|
};
|
|
2351
2383
|
await LCP.ready(lcpParams);
|
|
2352
2384
|
const lcp = LCP.getInstance(lcpParams);
|