vite-intlayer 8.4.1 → 8.4.2
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/esm/index.mjs +1 -1
- package/dist/esm/intlayerEditorPlugin.mjs +2 -0
- package/dist/esm/intlayerEditorPlugin.mjs.map +1 -0
- package/dist/esm/intlayerPlugin.mjs +1 -1
- package/dist/esm/intlayerPlugin.mjs.map +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/intlayerEditorPlugin.d.ts +16 -0
- package/dist/types/intlayerEditorPlugin.d.ts.map +1 -0
- package/dist/types/intlayerPlugin.d.ts.map +1 -1
- package/package.json +8 -8
package/dist/esm/index.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{intlayerCompiler as e}from"./IntlayerCompilerPlugin.mjs";import{
|
|
1
|
+
import{intlayerCompiler as e}from"./IntlayerCompilerPlugin.mjs";import{intlayerEditorPlugin as t}from"./intlayerEditorPlugin.mjs";import{intlayerOptimize as n}from"./intlayerOptimizePlugin.mjs";import{intLayerPlugin as r,intlayer as i,intlayerPlugin as a}from"./intlayerPlugin.mjs";import{intLayerMiddlewarePlugin as o,intlayerMiddleware as s,intlayerProxy as c}from"./intlayerProxyPlugin.mjs";export{o as intLayerMiddlewarePlugin,r as intLayerPlugin,i as intlayer,e as intlayerCompiler,t as intlayerEditorPlugin,s as intlayerMiddleware,n as intlayerOptimize,a as intlayerPlugin,c as intlayerProxy};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerEditorPlugin.mjs","names":[],"sources":["../../src/intlayerEditorPlugin.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types/config';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport type { Plugin } from 'vite';\n\n/**\n * Vite plugin that injects `process.env.INTLAYER_EDITOR_ENABLED` as a\n * compile-time constant so bundlers can dead-code-eliminate all\n * `import('@intlayer/editor')` calls when the editor is disabled.\n *\n * Returning a partial config object from the `config` hook is the idiomatic\n * Vite approach — Vite deep-merges it automatically via `mergeConfig`.\n */\nexport const intlayerEditorPlugin = (\n intlayerConfig: IntlayerConfig\n): Plugin => ({\n name: 'vite-intlayer-editor-plugin',\n config: () => ({\n define: {\n 'process.env.INTLAYER_EDITOR_ENABLED': JSON.stringify(\n intlayerConfig.editor?.enabled === false ? 'false' : 'true'\n ),\n },\n }),\n});\n"],"mappings":"AAYA,MAAa,EACX,IACY,CACZ,KAAM,8BACN,YAAe,CACb,OAAQ,CACN,sCAAuC,KAAK,UAC1C,EAAe,QAAQ,UAAY,GAAQ,QAAU,OACtD,CACF,CACF,EACF"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{intlayerEditorPlugin as e}from"./intlayerEditorPlugin.mjs";import{intlayerOptimize as t}from"./intlayerOptimizePlugin.mjs";import{resolve as n}from"node:path";import{getConfiguration as r}from"@intlayer/config/node";import{prepareIntlayer as i}from"@intlayer/chokidar/build";import{logConfigDetails as a}from"@intlayer/chokidar/cli";import{watch as o}from"@intlayer/chokidar/watcher";import{getAlias as s}from"@intlayer/config/utils";import{mergeConfig as c}from"vite";const l=l=>{let u=r(l);a(l);let d=s({configuration:u,formatter:e=>n(e)}),f=Object.keys(d),p=[{name:`vite-intlayer-plugin`,config:async(e,t)=>{let{mode:n}=u.build,r=t.command===`serve`&&t.mode===`development`,a=t.command===`build`;return(r||a||n===`auto`)&&await i(u,{clean:a,cacheTimeoutMs:a?1e3*30:1e3*60*60,env:a?`prod`:`dev`}),c(e,{resolve:{alias:d},optimizeDeps:{exclude:f},ssr:{noExternal:[/(^@intlayer\/|intlayer$)/]}})},configureServer:async e=>{e.config.mode===`development`&&o({configuration:u})}}];return p.push(e(u)),p.push(t(u)),p},u=l,d=l;export{d as intLayerPlugin,u as intlayer,l as intlayerPlugin};
|
|
2
2
|
//# sourceMappingURL=intlayerPlugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport type
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.mjs","names":[],"sources":["../../src/intlayerPlugin.ts"],"sourcesContent":["import { resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport { watch } from '@intlayer/chokidar/watcher';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport { getAlias } from '@intlayer/config/utils';\n// @ts-ignore - Fix error Module '\"vite\"' has no exported member\nimport { mergeConfig, type PluginOption } from 'vite';\nimport { intlayerEditorPlugin } from './intlayerEditorPlugin';\nimport { intlayerOptimize } from './intlayerOptimizePlugin';\n\n/**\n * Vite plugin that integrates Intlayer into the Vite build process.\n *\n * It handles:\n * 1. Preparing Intlayer resources (dictionaries) before build.\n * 2. Configuring Vite aliases for dictionary access.\n * 3. Setting up dev-server watchers for content changes.\n * 4. Applying build optimizations (tree-shaking dictionaries).\n *\n * @param configOptions - Optional configuration to override default Intlayer settings.\n * @returns A Vite plugin option.\n *\n * @example\n * ```ts\n * import { intlayer } from 'vite-intlayer';\n *\n * export default defineConfig({\n * plugins: [intlayer()],\n * });\n *\n * ```\n * @deprecated Rename to intlayer instead\n */\nexport const intlayerPlugin = (\n configOptions?: GetConfigurationOptions\n): PluginOption => {\n const intlayerConfig = getConfiguration(configOptions);\n logConfigDetails(configOptions);\n\n const alias = getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value),\n });\n\n const aliasPackages = Object.keys(alias);\n\n const plugins: PluginOption[] = [\n {\n name: 'vite-intlayer-plugin',\n\n config: async (config, env) => {\n const { mode } = intlayerConfig.build;\n\n const isDevCommand =\n env.command === 'serve' && env.mode === 'development';\n const isBuildCommand = env.command === 'build';\n\n // Only call prepareIntlayer during `dev` or `build` (not during `start`)\n // If prod: clean and rebuild once\n // If dev: rebuild only once if it's more than 1 hour since last rebuild\n if (isDevCommand || isBuildCommand || mode === 'auto') {\n // prepareIntlayer use runOnce to ensure to run only once because will run twice on client and server side otherwise\n await prepareIntlayer(intlayerConfig, {\n clean: isBuildCommand,\n cacheTimeoutMs: isBuildCommand\n ? 1000 * 30 // 30 seconds for build (to ensure to rebuild all dictionaries)\n : 1000 * 60 * 60, // 1 hour for dev (default cache timeout)\n env: isBuildCommand ? 'prod' : 'dev',\n });\n }\n\n // mergeConfig handles both array and record alias formats,\n // and correctly appends to optimizeDeps.exclude / ssr.noExternal\n return mergeConfig(config, {\n resolve: {\n alias,\n },\n optimizeDeps: {\n // Exclude alias entry points since they're local files, not npm packages\n exclude: aliasPackages,\n },\n ssr: {\n // Ensure intlayer packages are bundled so aliases are applied\n noExternal: [/(^@intlayer\\/|intlayer$)/],\n },\n });\n },\n\n configureServer: async (server) => {\n if (server.config.mode === 'development') {\n // Start watching (assuming watch is also async)\n watch({ configuration: intlayerConfig });\n }\n },\n },\n ];\n\n plugins.push(intlayerEditorPlugin(intlayerConfig));\n\n // Add Babel transform plugin if enabled\n plugins.push(intlayerOptimize(intlayerConfig));\n\n return plugins;\n};\n\n/**\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intlayer = intlayerPlugin;\n/**\n * @deprecated Rename to intlayer instead\n *\n * A Vite plugin that integrates Intlayer configuration into the build process\n *\n * ```ts\n * // Example usage of the plugin in a Vite configuration\n * export default defineConfig({\n * plugins: [ intlayer() ],\n * });\n * ```\n */\nexport const intLayerPlugin = intlayerPlugin;\n"],"mappings":"4dAqCA,MAAa,EACX,GACiB,CACjB,IAAM,EAAiB,EAAiB,EAAc,CACtD,EAAiB,EAAc,CAE/B,IAAM,EAAQ,EAAS,CACrB,cAAe,EACf,UAAY,GAAkB,EAAQ,EAAM,CAC7C,CAAC,CAEI,EAAgB,OAAO,KAAK,EAAM,CAElC,EAA0B,CAC9B,CACE,KAAM,uBAEN,OAAQ,MAAO,EAAQ,IAAQ,CAC7B,GAAM,CAAE,QAAS,EAAe,MAE1B,EACJ,EAAI,UAAY,SAAW,EAAI,OAAS,cACpC,EAAiB,EAAI,UAAY,QAkBvC,OAbI,GAAgB,GAAkB,IAAS,SAE7C,MAAM,EAAgB,EAAgB,CACpC,MAAO,EACP,eAAgB,EACZ,IAAO,GACP,IAAO,GAAK,GAChB,IAAK,EAAiB,OAAS,MAChC,CAAC,CAKG,EAAY,EAAQ,CACzB,QAAS,CACP,QACD,CACD,aAAc,CAEZ,QAAS,EACV,CACD,IAAK,CAEH,WAAY,CAAC,2BAA2B,CACzC,CACF,CAAC,EAGJ,gBAAiB,KAAO,IAAW,CAC7B,EAAO,OAAO,OAAS,eAEzB,EAAM,CAAE,cAAe,EAAgB,CAAC,EAG7C,CACF,CAOD,OALA,EAAQ,KAAK,EAAqB,EAAe,CAAC,CAGlD,EAAQ,KAAK,EAAiB,EAAe,CAAC,CAEvC,GAaI,EAAW,EAaX,EAAiB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IntlayerCompilerOptions, intlayerCompiler } from "./IntlayerCompilerPlugin.js";
|
|
2
|
+
import { intlayerEditorPlugin } from "./intlayerEditorPlugin.js";
|
|
2
3
|
import { intlayerOptimize } from "./intlayerOptimizePlugin.js";
|
|
3
4
|
import { intLayerPlugin, intlayer, intlayerPlugin } from "./intlayerPlugin.js";
|
|
4
5
|
import { intLayerMiddlewarePlugin, intlayerMiddleware, intlayerProxy } from "./intlayerProxyPlugin.js";
|
|
5
|
-
export { IntlayerCompilerOptions, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerCompiler, intlayerMiddleware, intlayerOptimize, intlayerPlugin, intlayerProxy };
|
|
6
|
+
export { IntlayerCompilerOptions, intLayerMiddlewarePlugin, intLayerPlugin, intlayer, intlayerCompiler, intlayerEditorPlugin, intlayerMiddleware, intlayerOptimize, intlayerPlugin, intlayerProxy };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types/config";
|
|
2
|
+
import { Plugin } from "vite";
|
|
3
|
+
|
|
4
|
+
//#region src/intlayerEditorPlugin.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Vite plugin that injects `process.env.INTLAYER_EDITOR_ENABLED` as a
|
|
7
|
+
* compile-time constant so bundlers can dead-code-eliminate all
|
|
8
|
+
* `import('@intlayer/editor')` calls when the editor is disabled.
|
|
9
|
+
*
|
|
10
|
+
* Returning a partial config object from the `config` hook is the idiomatic
|
|
11
|
+
* Vite approach — Vite deep-merges it automatically via `mergeConfig`.
|
|
12
|
+
*/
|
|
13
|
+
declare const intlayerEditorPlugin: (intlayerConfig: IntlayerConfig) => Plugin;
|
|
14
|
+
//#endregion
|
|
15
|
+
export { intlayerEditorPlugin };
|
|
16
|
+
//# sourceMappingURL=intlayerEditorPlugin.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"intlayerEditorPlugin.d.ts","names":[],"sources":["../../src/intlayerEditorPlugin.ts"],"mappings":";;;;;;AAYA;;;;;;cAAa,oBAAA,GACX,cAAA,EAAgB,cAAA,KACf,MAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;
|
|
1
|
+
{"version":3,"file":"intlayerPlugin.d.ts","names":[],"sources":["../../src/intlayerPlugin.ts"],"mappings":";;;;;;AAqCA;;;;;;;;;AAkFA;;;;;;;;;AAaA;;;cA/Fa,cAAA,GACX,aAAA,GAAgB,uBAAA,KACf,YAAA;;;;;;;;;;;cAgFU,QAAA,GAAQ,aAAA,GAjFH,uBAAA,KACf,YAAA;;;;;;;;;;;;;cA6FU,cAAA,GAAc,aAAA,GA9FT,uBAAA,KACf,YAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vite-intlayer",
|
|
3
|
-
"version": "8.4.
|
|
3
|
+
"version": "8.4.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A Vite plugin for seamless internationalization (i18n), providing locale detection, redirection, and environment-based configuration",
|
|
6
6
|
"keywords": [
|
|
@@ -77,13 +77,13 @@
|
|
|
77
77
|
},
|
|
78
78
|
"dependencies": {
|
|
79
79
|
"@babel/core": "7.29.0",
|
|
80
|
-
"@intlayer/babel": "8.4.
|
|
81
|
-
"@intlayer/chokidar": "8.4.
|
|
82
|
-
"@intlayer/config": "8.4.
|
|
83
|
-
"@intlayer/core": "8.4.
|
|
84
|
-
"@intlayer/dictionaries-entry": "8.4.
|
|
85
|
-
"@intlayer/types": "8.4.
|
|
86
|
-
"intlayer": "8.4.
|
|
80
|
+
"@intlayer/babel": "8.4.2",
|
|
81
|
+
"@intlayer/chokidar": "8.4.2",
|
|
82
|
+
"@intlayer/config": "8.4.2",
|
|
83
|
+
"@intlayer/core": "8.4.2",
|
|
84
|
+
"@intlayer/dictionaries-entry": "8.4.2",
|
|
85
|
+
"@intlayer/types": "8.4.2",
|
|
86
|
+
"intlayer": "8.4.2"
|
|
87
87
|
},
|
|
88
88
|
"devDependencies": {
|
|
89
89
|
"@types/babel__core": "7.20.5",
|