next-intlayer 8.6.0 → 8.6.1
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/server/withIntlayer.cjs +16 -10
- package/dist/cjs/server/withIntlayer.cjs.map +1 -1
- package/dist/esm/server/withIntlayer.mjs +17 -11
- package/dist/esm/server/withIntlayer.mjs.map +1 -1
- package/dist/types/index.d.ts +12 -12
- package/dist/types/server/withIntlayer.d.ts +2 -1
- package/dist/types/server/withIntlayer.d.ts.map +1 -1
- package/package.json +15 -9
|
@@ -66,12 +66,12 @@ const getPruneConfig = (intlayerConfig, isBuildCommand, isTurbopackEnabled, isDe
|
|
|
66
66
|
if (!isGteNext13) return {};
|
|
67
67
|
const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);
|
|
68
68
|
(0, _intlayer_chokidar_utils.runOnce)((0, node_path.join)(baseDir, ".intlayer", "cache", "intlayer-prune-plugin-enabled.lock"), () => {
|
|
69
|
-
if (isSwcPluginAvailable) logger(
|
|
69
|
+
if (isSwcPluginAvailable) logger([
|
|
70
70
|
"Build optimization enabled",
|
|
71
71
|
(0, _intlayer_config_logger.colorize)(`(import mode:`, _intlayer_config_colors.GREY_DARK),
|
|
72
72
|
(0, _intlayer_config_logger.colorize)(importMode ?? _intlayer_config_defaultValues.IMPORT_MODE, _intlayer_config_colors.BLUE),
|
|
73
73
|
(0, _intlayer_config_logger.colorize)(`)`, _intlayer_config_colors.GREY_DARK)
|
|
74
|
-
])
|
|
74
|
+
]);
|
|
75
75
|
else logger([
|
|
76
76
|
(0, _intlayer_config_logger.colorize)("Recommended: Install", _intlayer_config_colors.GREY),
|
|
77
77
|
(0, _intlayer_config_logger.colorize)("@intlayer/swc", _intlayer_config_colors.GREY_LIGHT),
|
|
@@ -137,15 +137,15 @@ const getCommandsEvent = () => {
|
|
|
137
137
|
* export default withIntlayerSync(nextConfig)
|
|
138
138
|
* ```
|
|
139
139
|
*/
|
|
140
|
-
const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
140
|
+
const withIntlayerSync = (nextConfig = {}, configOptions, unusedNodeTypesFromAsync) => {
|
|
141
141
|
if (typeof nextConfig !== "object") nextConfig = {};
|
|
142
142
|
const intlayerConfig = (0, _intlayer_config_node.getConfiguration)(configOptions);
|
|
143
143
|
(0, _intlayer_chokidar_cli.logConfigDetails)(configOptions);
|
|
144
|
-
const
|
|
144
|
+
const appLogger = (0, _intlayer_config_logger.getAppLogger)(intlayerConfig);
|
|
145
145
|
const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } = getNextVersionFlags(intlayerConfig);
|
|
146
146
|
const isTurbopackEnabledFromCommand = isGteNext16 ? !process.env.npm_lifecycle_script?.includes("--webpack") : process.env.npm_lifecycle_script?.includes("--turbo");
|
|
147
147
|
const isTurbopackEnabled = configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;
|
|
148
|
-
if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined")
|
|
148
|
+
if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined") appLogger("Turbopack is enabled but a custom webpack config is present. It will be ignored.");
|
|
149
149
|
const { isBuildCommand, isDevCommand } = getCommandsEvent();
|
|
150
150
|
const turboConfig = {
|
|
151
151
|
resolveAlias: (0, _intlayer_config_utils.getAlias)({
|
|
@@ -167,11 +167,14 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
|
167
167
|
"@intlayer/chokidar",
|
|
168
168
|
"@intlayer/webpack"
|
|
169
169
|
];
|
|
170
|
-
|
|
170
|
+
let unusedNodeTypes = unusedNodeTypesFromAsync;
|
|
171
|
+
if (isBuildCommand && !unusedNodeTypes) unusedNodeTypes = (0, _intlayer_chokidar_utils.getUnusedNodeTypes)((0, _intlayer_dictionaries_entry.getDictionaries)(intlayerConfig));
|
|
172
|
+
if (unusedNodeTypes && unusedNodeTypes.length > 0) appLogger(["Filtering out plugins:", unusedNodeTypes.map((key) => (0, _intlayer_config_logger.colorize)(key, _intlayer_config_colors.BLUE)).join(", ")], { isVerbose: true });
|
|
173
|
+
const nodeTypeEnvVars = unusedNodeTypes ? (0, _intlayer_chokidar_utils.formatNodeTypeToEnvVar)(unusedNodeTypes, false) : {};
|
|
171
174
|
const getNewConfig = () => {
|
|
172
175
|
let config = { env: {
|
|
173
|
-
|
|
174
|
-
...
|
|
176
|
+
...nodeTypeEnvVars,
|
|
177
|
+
...intlayerConfig.editor?.enabled === false ? { INTLAYER_EDITOR_ENABLED: "\"false\"" } : {}
|
|
175
178
|
} };
|
|
176
179
|
if (isGteNext15) config = {
|
|
177
180
|
...config,
|
|
@@ -211,7 +214,7 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
|
211
214
|
]);
|
|
212
215
|
const externalPrefixes = ["@intlayer/chokidar", "@intlayer/webpack"];
|
|
213
216
|
config.externals.push(({ request }, callback) => {
|
|
214
|
-
if (request && (externalExact.has(request) || externalPrefixes.some((
|
|
217
|
+
if (request && (externalExact.has(request) || externalPrefixes.some((prefix) => request === prefix || request.startsWith(`${prefix}/`)))) return callback(null, `commonjs ${request}`);
|
|
215
218
|
callback(null);
|
|
216
219
|
});
|
|
217
220
|
config.module.rules.push({
|
|
@@ -259,7 +262,10 @@ const withIntlayer = async (nextConfig = {}, configOptions) => {
|
|
|
259
262
|
cacheTimeoutMs: isBuildCommand ? 1e3 * 30 : 1e3 * 60 * 60,
|
|
260
263
|
env: isBuildCommand ? "prod" : "dev"
|
|
261
264
|
});
|
|
262
|
-
|
|
265
|
+
const nextConfigResolved = await nextConfig;
|
|
266
|
+
let unusedNodeTypes;
|
|
267
|
+
if (isBuildCommand) unusedNodeTypes = await (0, _intlayer_chokidar_utils.getUnusedNodeTypesAsync)((0, _intlayer_dictionaries_entry.getDictionaries)(intlayerConfig));
|
|
268
|
+
return withIntlayerSync(nextConfigResolved, configOptions, unusedNodeTypes);
|
|
263
269
|
};
|
|
264
270
|
|
|
265
271
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","ANSIColors","IMPORT_MODE","IntlayerPlugin"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport {\n buildComponentFilesList,\n getNodeTypeDefineVars,\n getUsedNodeTypes,\n runOnce,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean,\n isGteNext13: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger(\n logger([\n 'Build optimization enabled',\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ])\n );\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n } else {\n logger('Intlayer compiler disabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n\n logConfigDetails(configOptions);\n\n const logger = getAppLogger(intlayerConfig);\n\n const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } =\n getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n logger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/chokidar',\n '@intlayer/webpack',\n ];\n\n const nodeTypeEnvVars = isBuildCommand\n ? getNodeTypeDefineVars(\n getUsedNodeTypes(\n getDictionaries(intlayerConfig) as Record<string, Dictionary>\n )\n )\n : {};\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env: {\n INTLAYER_EDITOR_ENABLED:\n intlayerConfig.editor?.enabled === false ? 'false' : 'true',\n ...nodeTypeEnvVars,\n },\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/chokidar', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (p) => request === p || request.startsWith(`${p}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.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 (!isStartCommand && (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 const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, configOptions);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAcA,0BAAgB;AAElC,KAAI;AAIF,iBAFE,eAAe,OAAO,0DAA8B,EAC1B,oBAAoB,CAC9B;SACZ;AAIR,QAAO;EACL,yDAA6B,aAAa,KAAK,SAAS;EACxD,yDAA6B,aAAa,KAAK,SAAS;EACxD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O,KACP,MAAO,KAAK;EAChB,KAAK,iBAAiB,SAAS;EAChC,CAAC;AAKJ,QAAO,iBAFoB,MAAM,YAEW,cAAc"}
|
|
1
|
+
{"version":3,"file":"withIntlayer.cjs","names":["nextPackageJSON","ANSIColors","IMPORT_MODE","IntlayerPlugin"],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport {\n buildComponentFilesList,\n formatNodeTypeToEnvVar,\n getUnusedNodeTypes,\n getUnusedNodeTypesAsync,\n type PluginNodeType,\n runOnce,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean,\n isGteNext13: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger([\n 'Build optimization enabled',\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n } else {\n logger('Intlayer compiler disabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions,\n unusedNodeTypesFromAsync?: PluginNodeType[]\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } =\n getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/chokidar',\n '@intlayer/webpack',\n ];\n\n let unusedNodeTypes = unusedNodeTypesFromAsync;\n\n if (isBuildCommand && !unusedNodeTypes) {\n const dictionaries = getDictionaries(intlayerConfig) as Record<\n string,\n Dictionary\n >;\n unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n }\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, ANSIColors.BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n const nodeTypeEnvVars = unusedNodeTypes\n ? formatNodeTypeToEnvVar(unusedNodeTypes, false)\n : {};\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env: {\n ...nodeTypeEnvVars,\n ...(intlayerConfig.editor?.enabled === false\n ? { INTLAYER_EDITOR_ENABLED: '\"false\"' }\n : {}),\n },\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/chokidar', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.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 (!isStartCommand && (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 const nextConfigResolved = await nextConfig;\n\n let unusedNodeTypes: PluginNodeType[] | undefined;\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n }\n\n return withIntlayerSync(nextConfigResolved, configOptions, unusedNodeTypes);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAsCA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAcA,0BAAgB;AAElC,KAAI;AAIF,iBAFE,eAAe,OAAO,0DAA8B,EAC1B,oBAAoB,CAC9B;SACZ;AAIR,QAAO;EACL,yDAA6B,aAAa,KAAK,SAAS;EACxD,yDAA6B,aAAa,KAAK,SAAS;EACxD,yDAA6B,aAAa,KAAK,SAAS;EACxD,+DAAmC,aAAa,KAAK,SAAS;EAC/D;;AAIH,MAAM,2BAA2B,mBAAmC;AAClE,KAAI;AAGF,GADE,eAAe,OAAO,0DAA8B,EACtC,QAAQ,gBAAgB;AACxC,SAAO;UACA,IAAI;AACX,SAAO;;;AAKX,MAAM,oCAAoC,mBAAmC;AAC3E,KAAI;AAGF,GADE,eAAe,OAAO,0DAA8B,EACtC,QAAQ,kBAAkB;AAC1C,SAAO;UACA,IAAI;AACX,SAAO;;;AAIX,MAAM,qBACJ,YACA,gBACA,uBACW;CAEX,MAAM,sBADkB,eAAe,OAAO,0DAA8B,GAChC,QAAQ,WAAW;AAE/D,KAAI,mBAEF,kDAAqB,6BAAc,QAAQ,KAAK,EAAE,mBAAmB,GAAG;AAG1E,QAAO;;AAGT,MAAM,kBACJ,gBACA,gBACA,oBACA,cACA,gBACwB;CACxB,MAAM,EAAE,aAAa,eAAe;CACpC,MAAM,aACJ,eAAe,MAAM,cAAc,eAAe,YAAY;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,QAAQ,WAAW,GAAG,OAAO,GAAG,CACzD,EAEH,QAAO,SAAS,MAAM,YAAY,UAAU;AAE9C,cAAS,KAAK;MAEjB;AAGD,WAAO,OAAO,MAAM,KAAK;KACvB,MAAM;KACN,QAAQ;KACT,CAAC;AAIF,WAAO,QAAQ,QAAQ;KACrB,GAAG,OAAO,QAAQ;KAClB,wCAAY;MACV,eAAe;MACf,YAAY,iCAA0B,MAAM;MAC7C,CAAC;KACH;AAGD,QAAI,gBAAgB,YAAY,gBAAgB,SAE9C,QAAO,QAAQ,KAAK,IAAIE,iCAAe,eAAe,CAAC;AAGzD,WAAO;;GAEV;AAGH,SAAO;;CAGT,MAAM,cAAmC,eACvC,gBACA,gBACA,sBAAsB,OACtB,cACA,YACD;AAUD,sCAPE,cAAc,EACd,YACD,EAGuC,WAAW;;;;;;;;;;;;;;;;;AAoBrD,MAAa,eAAe,OAC1B,aAA6B,EAAE,EAC/B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,cAAc,mBAAmB,kBAAkB;AAE3E,SAAQ,IAAI,0BAA0B,eAAe,SAAS;CAE9D,MAAM,6DAAkC,cAAc;CAEtD,MAAM,EAAE,SAAS,eAAe;AAKhC,KAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,QAEjE,qDAAsB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MAAO,KACP,MAAO,KAAK;EAChB,KAAK,iBAAiB,SAAS;EAChC,CAAC;CAGJ,MAAM,qBAAqB,MAAM;CAEjC,IAAI;AAEJ,KAAI,eAEF,mBAAkB,8GADmB,eAAe,CACS;AAG/D,QAAO,iBAAiB,oBAAoB,eAAe,gBAAgB"}
|
|
@@ -2,7 +2,7 @@ import { IMPORT_MODE } from "@intlayer/config/defaultValues";
|
|
|
2
2
|
import { join, relative, resolve } from "node:path";
|
|
3
3
|
import { prepareIntlayer } from "@intlayer/chokidar/build";
|
|
4
4
|
import { logConfigDetails } from "@intlayer/chokidar/cli";
|
|
5
|
-
import { buildComponentFilesList,
|
|
5
|
+
import { buildComponentFilesList, formatNodeTypeToEnvVar, getUnusedNodeTypes, getUnusedNodeTypesAsync, runOnce } from "@intlayer/chokidar/utils";
|
|
6
6
|
import * as ANSIColors from "@intlayer/config/colors";
|
|
7
7
|
import { colorize, getAppLogger } from "@intlayer/config/logger";
|
|
8
8
|
import { getConfiguration } from "@intlayer/config/node";
|
|
@@ -62,12 +62,12 @@ const getPruneConfig = (intlayerConfig, isBuildCommand, isTurbopackEnabled, isDe
|
|
|
62
62
|
if (!isGteNext13) return {};
|
|
63
63
|
const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);
|
|
64
64
|
runOnce(join(baseDir, ".intlayer", "cache", "intlayer-prune-plugin-enabled.lock"), () => {
|
|
65
|
-
if (isSwcPluginAvailable) logger(
|
|
65
|
+
if (isSwcPluginAvailable) logger([
|
|
66
66
|
"Build optimization enabled",
|
|
67
67
|
colorize(`(import mode:`, ANSIColors.GREY_DARK),
|
|
68
68
|
colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),
|
|
69
69
|
colorize(`)`, ANSIColors.GREY_DARK)
|
|
70
|
-
])
|
|
70
|
+
]);
|
|
71
71
|
else logger([
|
|
72
72
|
colorize("Recommended: Install", ANSIColors.GREY),
|
|
73
73
|
colorize("@intlayer/swc", ANSIColors.GREY_LIGHT),
|
|
@@ -133,15 +133,15 @@ const getCommandsEvent = () => {
|
|
|
133
133
|
* export default withIntlayerSync(nextConfig)
|
|
134
134
|
* ```
|
|
135
135
|
*/
|
|
136
|
-
const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
136
|
+
const withIntlayerSync = (nextConfig = {}, configOptions, unusedNodeTypesFromAsync) => {
|
|
137
137
|
if (typeof nextConfig !== "object") nextConfig = {};
|
|
138
138
|
const intlayerConfig = getConfiguration(configOptions);
|
|
139
139
|
logConfigDetails(configOptions);
|
|
140
|
-
const
|
|
140
|
+
const appLogger = getAppLogger(intlayerConfig);
|
|
141
141
|
const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } = getNextVersionFlags(intlayerConfig);
|
|
142
142
|
const isTurbopackEnabledFromCommand = isGteNext16 ? !process.env.npm_lifecycle_script?.includes("--webpack") : process.env.npm_lifecycle_script?.includes("--turbo");
|
|
143
143
|
const isTurbopackEnabled = configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;
|
|
144
|
-
if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined")
|
|
144
|
+
if (isTurbopackEnabled && typeof nextConfig.webpack !== "undefined") appLogger("Turbopack is enabled but a custom webpack config is present. It will be ignored.");
|
|
145
145
|
const { isBuildCommand, isDevCommand } = getCommandsEvent();
|
|
146
146
|
const turboConfig = {
|
|
147
147
|
resolveAlias: getAlias({
|
|
@@ -163,11 +163,14 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
|
163
163
|
"@intlayer/chokidar",
|
|
164
164
|
"@intlayer/webpack"
|
|
165
165
|
];
|
|
166
|
-
|
|
166
|
+
let unusedNodeTypes = unusedNodeTypesFromAsync;
|
|
167
|
+
if (isBuildCommand && !unusedNodeTypes) unusedNodeTypes = getUnusedNodeTypes(getDictionaries(intlayerConfig));
|
|
168
|
+
if (unusedNodeTypes && unusedNodeTypes.length > 0) appLogger(["Filtering out plugins:", unusedNodeTypes.map((key) => colorize(key, ANSIColors.BLUE)).join(", ")], { isVerbose: true });
|
|
169
|
+
const nodeTypeEnvVars = unusedNodeTypes ? formatNodeTypeToEnvVar(unusedNodeTypes, false) : {};
|
|
167
170
|
const getNewConfig = () => {
|
|
168
171
|
let config = { env: {
|
|
169
|
-
|
|
170
|
-
...
|
|
172
|
+
...nodeTypeEnvVars,
|
|
173
|
+
...intlayerConfig.editor?.enabled === false ? { INTLAYER_EDITOR_ENABLED: "\"false\"" } : {}
|
|
171
174
|
} };
|
|
172
175
|
if (isGteNext15) config = {
|
|
173
176
|
...config,
|
|
@@ -207,7 +210,7 @@ const withIntlayerSync = (nextConfig = {}, configOptions) => {
|
|
|
207
210
|
]);
|
|
208
211
|
const externalPrefixes = ["@intlayer/chokidar", "@intlayer/webpack"];
|
|
209
212
|
config.externals.push(({ request }, callback) => {
|
|
210
|
-
if (request && (externalExact.has(request) || externalPrefixes.some((
|
|
213
|
+
if (request && (externalExact.has(request) || externalPrefixes.some((prefix) => request === prefix || request.startsWith(`${prefix}/`)))) return callback(null, `commonjs ${request}`);
|
|
211
214
|
callback(null);
|
|
212
215
|
});
|
|
213
216
|
config.module.rules.push({
|
|
@@ -255,7 +258,10 @@ const withIntlayer = async (nextConfig = {}, configOptions) => {
|
|
|
255
258
|
cacheTimeoutMs: isBuildCommand ? 1e3 * 30 : 1e3 * 60 * 60,
|
|
256
259
|
env: isBuildCommand ? "prod" : "dev"
|
|
257
260
|
});
|
|
258
|
-
|
|
261
|
+
const nextConfigResolved = await nextConfig;
|
|
262
|
+
let unusedNodeTypes;
|
|
263
|
+
if (isBuildCommand) unusedNodeTypes = await getUnusedNodeTypesAsync(getDictionaries(intlayerConfig));
|
|
264
|
+
return withIntlayerSync(nextConfigResolved, configOptions, unusedNodeTypes);
|
|
259
265
|
};
|
|
260
266
|
|
|
261
267
|
//#endregion
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIntlayer.mjs","names":[],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport {\n buildComponentFilesList,\n getNodeTypeDefineVars,\n getUsedNodeTypes,\n runOnce,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean,\n isGteNext13: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger(\n logger([\n 'Build optimization enabled',\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ])\n );\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n } else {\n logger('Intlayer compiler disabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n\n logConfigDetails(configOptions);\n\n const logger = getAppLogger(intlayerConfig);\n\n const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } =\n getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n logger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/chokidar',\n '@intlayer/webpack',\n ];\n\n const nodeTypeEnvVars = isBuildCommand\n ? getNodeTypeDefineVars(\n getUsedNodeTypes(\n getDictionaries(intlayerConfig) as Record<string, Dictionary>\n )\n )\n : {};\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env: {\n INTLAYER_EDITOR_ENABLED:\n intlayerConfig.editor?.enabled === false ? 'false' : 'true',\n ...nodeTypeEnvVars,\n },\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/chokidar', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (p) => request === p || request.startsWith(`${p}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.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 (!isStartCommand && (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 const nextConfigResolved = await nextConfig;\n\n return withIntlayerSync(nextConfigResolved, configOptions);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAoCA,MAAM,uBAAuB,mBAAmC;CAC9D,IAAI,cAAc,gBAAgB;AAElC,KAAI;AAIF,iBAFE,eAAe,OAAO,WAAW,mBAAmB,EAC1B,oBAAoB,CAC9B;SACZ;AAIR,QAAO;EACL,aAAa,gBAAgB,aAAa,KAAK,SAAS;EACxD,aAAa,gBAAgB,aAAa,KAAK,SAAS;EACxD,aAAa,gBAAgB,aAAa,KAAK,SAAS;EACxD,mBAAmB,gBAAgB,aAAa,KAAK,SAAS;EAC/D;;AAIH,MAAM,2BAA2B,mBAAmC;AAClE,KAAI;AAGF,GADE,eAAe,OAAO,WAAW,mBAAmB,EACtC,QAAQ,gBAAgB;AACxC,SAAO;UACA,IAAI;AACX,SAAO;;;AAKX,MAAM,oCAAoC,mBAAmC;AAC3E,KAAI;AAGF,GADE,eAAe,OAAO,WAAW,mBAAmB,EACtC,QAAQ,kBAAkB;AAC1C,SAAO;UACA,IAAI;AACX,SAAO;;;AAIX,MAAM,qBACJ,YACA,gBACA,uBACW;CAEX,MAAM,sBADkB,eAAe,OAAO,WAAW,mBAAmB,GAChC,QAAQ,WAAW;AAE/D,KAAI,mBAEF,QAAO,cAAc,KAAK,SAAS,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,MAAM,YAAY,KAAK,QAAQ,WAAW,GAAG,EAAE,GAAG,CACpD,EAEH,QAAO,SAAS,MAAM,YAAY,UAAU;AAE9C,cAAS,KAAK;MAEjB;AAGD,WAAO,OAAO,MAAM,KAAK;KACvB,MAAM;KACN,QAAQ;KACT,CAAC;AAIF,WAAO,QAAQ,QAAQ;KACrB,GAAG,OAAO,QAAQ;KAClB,GAAG,SAAS;MACV,eAAe;MACf,YAAY,UAAkB,QAAQ,MAAM;MAC7C,CAAC;KACH;AAGD,QAAI,gBAAgB,YAAY,gBAAgB,SAE9C,QAAO,QAAQ,KAAK,IAAI,eAAe,eAAe,CAAC;AAGzD,WAAO;;GAEV;AAGH,SAAO;;CAGT,MAAM,cAAmC,eACvC,gBACA,gBACA,sBAAsB,OACtB,cACA,YACD;AAUD,QAFe,KANiC,KAC9C,cAAc,EACd,YACD,EAGuC,WAAW;;;;;;;;;;;;;;;;;AAoBrD,MAAa,eAAe,OAC1B,aAA6B,EAAE,EAC/B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,cAAc,mBAAmB,kBAAkB;AAE3E,SAAQ,IAAI,0BAA0B,eAAe,SAAS;CAE9D,MAAM,iBAAiB,iBAAiB,cAAc;CAEtD,MAAM,EAAE,SAAS,eAAe;AAKhC,KAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,QAEjE,OAAM,gBAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MAAO,KACP,MAAO,KAAK;EAChB,KAAK,iBAAiB,SAAS;EAChC,CAAC;AAKJ,QAAO,iBAFoB,MAAM,YAEW,cAAc"}
|
|
1
|
+
{"version":3,"file":"withIntlayer.mjs","names":[],"sources":["../../../src/server/withIntlayer.ts"],"sourcesContent":["import { join, relative, resolve } from 'node:path';\nimport { prepareIntlayer } from '@intlayer/chokidar/build';\nimport { logConfigDetails } from '@intlayer/chokidar/cli';\nimport {\n buildComponentFilesList,\n formatNodeTypeToEnvVar,\n getUnusedNodeTypes,\n getUnusedNodeTypesAsync,\n type PluginNodeType,\n runOnce,\n} from '@intlayer/chokidar/utils';\nimport * as ANSIColors from '@intlayer/config/colors';\nimport { IMPORT_MODE } from '@intlayer/config/defaultValues';\nimport { colorize, getAppLogger } from '@intlayer/config/logger';\nimport {\n type GetConfigurationOptions,\n getConfiguration,\n} from '@intlayer/config/node';\nimport {\n compareVersions,\n getAlias,\n getProjectRequire,\n normalizePath,\n} from '@intlayer/config/utils';\nimport { getDictionaries } from '@intlayer/dictionaries-entry';\nimport type { IntlayerConfig } from '@intlayer/types/config';\nimport type { Dictionary } from '@intlayer/types/dictionary';\nimport { IntlayerPlugin } from '@intlayer/webpack';\nimport { defu } from 'defu';\nimport type { NextConfig } from 'next';\nimport type { NextJsWebpackConfig } from 'next/dist/server/config-shared';\nimport nextPackageJSON from 'next/package.json' with { type: 'json' };\n\n/**\n * Resolve the Next.js version from the *user's* project at runtime.\n * A static `import from 'next/package.json'` would resolve relative to\n * next-intlayer's own node_modules, which may differ in a monorepo.\n */\nconst getNextVersionFlags = (intlayerConfig: IntlayerConfig) => {\n let nextVersion = nextPackageJSON.version;\n\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n const pkg = requireFunction('next/package.json') as { version: string };\n nextVersion = pkg.version;\n } catch {\n // keep default\n }\n\n return {\n isGteNext13: compareVersions(nextVersion, '≥', '13.0.0'),\n isGteNext15: compareVersions(nextVersion, '≥', '15.0.0'),\n isGteNext16: compareVersions(nextVersion, '≥', '16.0.0'),\n isTurbopackStable: compareVersions(nextVersion, '≥', '15.3.0'),\n };\n};\n\n// Check if SWC plugin is available\nconst getIsSwcPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/swc');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\n// Check if Babel plugin is available\nconst getIsBabelExtractPluginAvailable = (intlayerConfig: IntlayerConfig) => {\n try {\n const requireFunction =\n intlayerConfig.build?.require ?? getProjectRequire();\n requireFunction.resolve('@intlayer/babel');\n return true;\n } catch (_e) {\n return false;\n }\n};\n\nconst resolvePluginPath = (\n pluginPath: string,\n intlayerConfig: IntlayerConfig,\n isTurbopackEnabled: boolean\n): string => {\n const requireFunction = intlayerConfig.build?.require ?? getProjectRequire();\n const pluginPathResolved = requireFunction?.resolve(pluginPath);\n\n if (isTurbopackEnabled)\n // Relative path for turbopack\n return normalizePath(`./${relative(process.cwd(), pluginPathResolved)}`);\n\n // Absolute path for webpack\n return pluginPathResolved;\n};\n\nconst getPruneConfig = (\n intlayerConfig: IntlayerConfig,\n isBuildCommand: boolean,\n isTurbopackEnabled: boolean,\n isDevCommand: boolean,\n isGteNext13: boolean\n): Partial<NextConfig> => {\n const { optimize } = intlayerConfig.build;\n const importMode =\n intlayerConfig.build.importMode ?? intlayerConfig.dictionary?.importMode;\n const {\n dictionariesDir,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n fetchDictionariesDir,\n mainDir,\n } = intlayerConfig.system;\n const { baseDir } = intlayerConfig.system;\n const logger = getAppLogger(intlayerConfig);\n\n if (optimize === false) {\n return {};\n }\n if (optimize === undefined && !isBuildCommand) {\n return {};\n }\n\n if (!isGteNext13) return {};\n\n const isSwcPluginAvailable = getIsSwcPluginAvailable(intlayerConfig);\n\n runOnce(\n join(baseDir, '.intlayer', 'cache', 'intlayer-prune-plugin-enabled.lock'),\n () => {\n if (isSwcPluginAvailable) {\n logger([\n 'Build optimization enabled',\n colorize(`(import mode:`, ANSIColors.GREY_DARK),\n colorize(importMode ?? IMPORT_MODE, ANSIColors.BLUE),\n colorize(`)`, ANSIColors.GREY_DARK),\n ]);\n } else {\n logger([\n colorize('Recommended: Install', ANSIColors.GREY),\n colorize('@intlayer/swc', ANSIColors.GREY_LIGHT),\n colorize(\n 'package to enable build optimization. See documentation:',\n ANSIColors.GREY\n ),\n colorize(\n 'https://intlayer.org/docs/bundle-optimization',\n ANSIColors.GREY_LIGHT\n ),\n ]);\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n runOnce(\n join(\n baseDir,\n '.intlayer',\n 'cache',\n 'intlayer-compiler-plugin-enabled.lock'\n ),\n () => {\n const isBabelExtractPluginAvailable =\n getIsBabelExtractPluginAvailable(intlayerConfig);\n\n if (isBabelExtractPluginAvailable) {\n let isEnabled = intlayerConfig.compiler?.enabled ?? true;\n\n if (isEnabled === 'build-only') {\n isEnabled = !isDevCommand;\n }\n\n if (isEnabled) {\n logger('Intlayer compiler enabled');\n } else {\n logger('Intlayer compiler disabled');\n }\n }\n },\n {\n cacheTimeoutMs: 1000 * 30, // 30 seconds\n }\n );\n\n if (!isSwcPluginAvailable) {\n return {};\n }\n\n const dictionariesEntryPath = join(mainDir, 'dictionaries.mjs');\n\n const dynamicDictionariesEntryPath = join(\n mainDir,\n 'dynamic_dictionaries.mjs'\n );\n\n const unmergedDictionariesEntryPath = join(\n mainDir,\n 'unmerged_dictionaries.mjs'\n );\n\n const fetchDictionariesEntryPath = join(mainDir, 'fetch_dictionaries.mjs');\n\n const filesListPattern = buildComponentFilesList(intlayerConfig);\n\n const filesList = [\n ...filesListPattern,\n dictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n unmergedDictionariesEntryPath, // should add dictionariesEntryPath to replace it by a empty object if import made dynamic\n ];\n\n const dictionaries = getDictionaries(intlayerConfig);\n\n const dictionaryModeMap: Record<string, 'static' | 'dynamic' | 'fetch'> = {};\n\n (Object.values(dictionaries) as Dictionary[]).forEach((dictionary) => {\n dictionaryModeMap[dictionary.key] =\n dictionary.importMode ?? importMode ?? IMPORT_MODE;\n });\n\n return {\n experimental: {\n swcPlugins: [\n [\n resolvePluginPath(\n '@intlayer/swc',\n intlayerConfig,\n isTurbopackEnabled\n ),\n {\n dictionariesDir,\n dictionariesEntryPath,\n unmergedDictionariesEntryPath,\n unmergedDictionariesDir,\n dynamicDictionariesDir,\n dynamicDictionariesEntryPath,\n fetchDictionariesDir,\n fetchDictionariesEntryPath,\n importMode,\n filesList,\n replaceDictionaryEntry: true,\n dictionaryModeMap,\n },\n ],\n ],\n },\n };\n};\n\nconst getCommandsEvent = () => {\n const lifecycleEvent = process.env.npm_lifecycle_event;\n const lifecycleScript = process.env.npm_lifecycle_script ?? '';\n\n const isDevCommand =\n lifecycleEvent === 'dev' ||\n process.argv.some((arg) => arg === 'dev') ||\n /(^|\\s)(next\\s+)?dev(\\s|$)/.test(lifecycleScript);\n\n const isBuildCommand =\n lifecycleEvent === 'build' ||\n process.argv.some((arg) => arg === 'build') ||\n /(^|\\s)(next\\s+)?build(\\s|$)/.test(lifecycleScript);\n\n const isStartCommand =\n lifecycleEvent === 'start' ||\n process.argv.some((arg) => arg === 'start') ||\n /(^|\\s)(next\\s+)?start(\\s|$)/.test(lifecycleScript);\n\n return {\n isDevCommand,\n isBuildCommand,\n isStartCommand,\n };\n};\n\ntype WebpackParams = Parameters<NextJsWebpackConfig>;\n\ntype WithIntlayerOptions = GetConfigurationOptions & {\n enableTurbopack?: boolean;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayerSync(nextConfig)\n * ```\n */\nexport const withIntlayerSync = <T extends Partial<NextConfig>>(\n nextConfig: T = {} as T,\n configOptions?: WithIntlayerOptions,\n unusedNodeTypesFromAsync?: PluginNodeType[]\n): NextConfig & T => {\n if (typeof nextConfig !== 'object') {\n nextConfig = {} as T;\n }\n\n const intlayerConfig = getConfiguration(configOptions);\n\n logConfigDetails(configOptions);\n\n const appLogger = getAppLogger(intlayerConfig);\n\n const { isGteNext13, isGteNext15, isGteNext16, isTurbopackStable } =\n getNextVersionFlags(intlayerConfig);\n\n const isTurbopackEnabledFromCommand = isGteNext16\n ? // Next@16 enables turbopack by default; disable with --webpack\n !process.env.npm_lifecycle_script?.includes('--webpack')\n : // Next@15 uses --turbopack, Next@14 uses --turbo\n process.env.npm_lifecycle_script?.includes('--turbo');\n\n const isTurbopackEnabled =\n configOptions?.enableTurbopack ?? isTurbopackEnabledFromCommand;\n\n if (isTurbopackEnabled && typeof nextConfig.webpack !== 'undefined') {\n appLogger(\n 'Turbopack is enabled but a custom webpack config is present. It will be ignored.'\n );\n }\n\n const { isBuildCommand, isDevCommand } = getCommandsEvent();\n\n // Only provide turbo-specific config if user explicitly sets it\n const turboConfig = {\n resolveAlias: getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => `./${value}`, // prefix by './' to consider the path as relative to the project root. This is necessary for turbopack to work correctly.\n }),\n\n rules: {\n '*.node': {\n as: '*.node',\n loaders: ['node-loader'],\n },\n },\n };\n\n const serverExternalPackages = [\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n '@intlayer/chokidar',\n '@intlayer/webpack',\n ];\n\n let unusedNodeTypes = unusedNodeTypesFromAsync;\n\n if (isBuildCommand && !unusedNodeTypes) {\n const dictionaries = getDictionaries(intlayerConfig) as Record<\n string,\n Dictionary\n >;\n unusedNodeTypes = getUnusedNodeTypes(dictionaries);\n }\n\n if (unusedNodeTypes && unusedNodeTypes.length > 0) {\n appLogger(\n [\n 'Filtering out plugins:',\n unusedNodeTypes.map((key) => colorize(key, ANSIColors.BLUE)).join(', '),\n ],\n {\n isVerbose: true,\n }\n );\n }\n\n const nodeTypeEnvVars = unusedNodeTypes\n ? formatNodeTypeToEnvVar(unusedNodeTypes, false)\n : {};\n\n const getNewConfig = (): Partial<NextConfig> => {\n let config: Partial<NextConfig> = {\n env: {\n ...nodeTypeEnvVars,\n ...(intlayerConfig.editor?.enabled === false\n ? { INTLAYER_EDITOR_ENABLED: '\"false\"' }\n : {}),\n },\n };\n\n if (isGteNext15) {\n config = {\n ...config,\n serverExternalPackages,\n };\n }\n\n if (isGteNext13 && !isGteNext15) {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n serverComponentsExternalPackages: serverExternalPackages,\n },\n };\n }\n\n if (isTurbopackEnabled) {\n if (isGteNext15 && isTurbopackStable) {\n config = {\n ...config,\n turbopack: turboConfig,\n };\n } else {\n config = {\n ...config,\n experimental: {\n ...(config?.experimental ?? {}),\n // @ts-ignore exist in next@14\n turbo: turboConfig,\n },\n };\n }\n } else {\n config = {\n ...config,\n webpack: (config: WebpackParams['0'], options: WebpackParams[1]) => {\n // Only add Intlayer plugin on server side (node runtime)\n const { isServer, nextRuntime } = options;\n\n // If the user has defined their own webpack config, call it\n if (typeof nextConfig.webpack === 'function') {\n config = nextConfig.webpack(config, options);\n }\n\n // Rspack set external as false by default\n // Overwrite it to allow pushing the desired externals\n if (config.externals === false) {\n config.externals = [];\n }\n\n // Mark server-only modules as externals (function form handles subpaths)\n const externalExact = new Set([\n 'esbuild',\n 'module',\n 'fs',\n 'chokidar',\n 'fsevents',\n 'recast',\n ]);\n const externalPrefixes = ['@intlayer/chokidar', '@intlayer/webpack'];\n config.externals.push(\n (\n { request }: { request?: string },\n callback: (err: Error | null, result?: string) => void\n ) => {\n if (\n request &&\n (externalExact.has(request) ||\n externalPrefixes.some(\n (prefix) =>\n request === prefix || request.startsWith(`${prefix}/`)\n ))\n ) {\n return callback(null, `commonjs ${request}`);\n }\n callback(null);\n }\n );\n\n // Use `node-loader` for any `.node` files\n config.module.rules.push({\n test: /\\.node$/,\n loader: 'node-loader',\n });\n\n // Always alias on the server (node/edge) for stability.\n // On the client, alias only when not using live sync.\n config.resolve.alias = {\n ...config.resolve.alias,\n ...getAlias({\n configuration: intlayerConfig,\n formatter: (value: string) => resolve(value), // get absolute path\n }),\n };\n\n // Activate watch mode webpack plugin\n if (isDevCommand && isServer && nextRuntime === 'nodejs') {\n // Optional as rspack not support plugin yet\n config.plugins.push(new IntlayerPlugin(intlayerConfig));\n }\n\n return config;\n },\n };\n }\n\n return config;\n };\n\n const pruneConfig: Partial<NextConfig> = getPruneConfig(\n intlayerConfig,\n isBuildCommand,\n isTurbopackEnabled ?? false,\n isDevCommand,\n isGteNext13\n );\n\n const intlayerNextConfig: Partial<NextConfig> = defu(\n getNewConfig(),\n pruneConfig\n );\n\n // Merge the new config with the user's config\n const result = defu(intlayerNextConfig, nextConfig) as NextConfig & T;\n\n return result;\n};\n\n/**\n * A Next.js plugin that adds the intlayer configuration to the webpack configuration\n * and sets the environment variables\n *\n * Usage:\n *\n * ```ts\n * // next.config.js\n * export default withIntlayer(nextConfig)\n * ```\n *\n * > Node withIntlayer is a promise function. Use withIntlayerSync instead if you want to use it synchronously.\n * > Using the promise allows to prepare the intlayer dictionaries before the build starts.\n *\n */\nexport const withIntlayer = async <T extends Partial<NextConfig>>(\n nextConfig: T | Promise<T> = {} as T,\n configOptions?: WithIntlayerOptions\n): Promise<NextConfig & T> => {\n const { isBuildCommand, isDevCommand, isStartCommand } = getCommandsEvent();\n\n process.env.INTLAYER_IS_DEV_COMMAND = isDevCommand ? 'true' : 'false';\n\n const intlayerConfig = getConfiguration(configOptions);\n\n const { mode } = intlayerConfig.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 (!isStartCommand && (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 const nextConfigResolved = await nextConfig;\n\n let unusedNodeTypes: PluginNodeType[] | undefined;\n\n if (isBuildCommand) {\n const dictionaries = getDictionaries(intlayerConfig);\n unusedNodeTypes = await getUnusedNodeTypesAsync(dictionaries);\n }\n\n return withIntlayerSync(nextConfigResolved, configOptions, unusedNodeTypes);\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;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ClB,GAAG,SAAS;MACV,eAAe;MACf,YAAY,UAAkB,QAAQ,MAAM;MAC7C,CAAC;KACH;AAGD,QAAI,gBAAgB,YAAY,gBAAgB,SAE9C,QAAO,QAAQ,KAAK,IAAI,eAAe,eAAe,CAAC;AAGzD,WAAO;;GAEV;AAGH,SAAO;;CAGT,MAAM,cAAmC,eACvC,gBACA,gBACA,sBAAsB,OACtB,cACA,YACD;AAUD,QAFe,KANiC,KAC9C,cAAc,EACd,YACD,EAGuC,WAAW;;;;;;;;;;;;;;;;;AAoBrD,MAAa,eAAe,OAC1B,aAA6B,EAAE,EAC/B,kBAC4B;CAC5B,MAAM,EAAE,gBAAgB,cAAc,mBAAmB,kBAAkB;AAE3E,SAAQ,IAAI,0BAA0B,eAAe,SAAS;CAE9D,MAAM,iBAAiB,iBAAiB,cAAc;CAEtD,MAAM,EAAE,SAAS,eAAe;AAKhC,KAAI,CAAC,mBAAmB,gBAAgB,kBAAkB,SAAS,QAEjE,OAAM,gBAAgB,gBAAgB;EACpC,OAAO;EACP,gBAAgB,iBACZ,MAAO,KACP,MAAO,KAAK;EAChB,KAAK,iBAAiB,SAAS;EAChC,CAAC;CAGJ,MAAM,qBAAqB,MAAM;CAEjC,IAAI;AAEJ,KAAI,eAEF,mBAAkB,MAAM,wBADH,gBAAgB,eAAe,CACS;AAG/D,QAAO,iBAAiB,oBAAoB,eAAe,gBAAgB"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -15,6 +15,9 @@ import { IntlayerClientContext, IntlayerNode, getDictionary, getIntlayer, locale
|
|
|
15
15
|
declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptions & {
|
|
16
16
|
components?: {} & {
|
|
17
17
|
object?: _$react.FC<_$react.DetailedHTMLProps<_$react.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
18
|
+
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
19
|
+
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
20
|
+
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
18
21
|
html?: _$react.FC<_$react.DetailedHTMLProps<_$react.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
19
22
|
head?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
20
23
|
body?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -68,8 +71,6 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
68
71
|
thead?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
69
72
|
tbody?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
70
73
|
tfoot?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
71
|
-
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
72
|
-
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
73
74
|
td?: _$react.FC<_$react.DetailedHTMLProps<_$react.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
74
75
|
caption?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
75
76
|
colgroup?: _$react.FC<_$react.DetailedHTMLProps<_$react.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -104,7 +105,6 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
104
105
|
summary?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
105
106
|
dialog?: _$react.FC<_$react.DetailedHTMLProps<_$react.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
106
107
|
br?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
107
|
-
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
108
108
|
wbr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
109
109
|
ruby?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
110
110
|
rt?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -120,6 +120,9 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
120
120
|
wrapper?: _$react.FC<_$react.HTMLAttributes<HTMLElement>>;
|
|
121
121
|
renderMarkdown?: (markdown: string, options?: index_d_exports.MarkdownProviderOptions, components?: {} & {
|
|
122
122
|
object?: _$react.FC<_$react.DetailedHTMLProps<_$react.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
123
|
+
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
124
|
+
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
125
|
+
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
123
126
|
html?: _$react.FC<_$react.DetailedHTMLProps<_$react.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
124
127
|
head?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
125
128
|
body?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -173,8 +176,6 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
173
176
|
thead?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
174
177
|
tbody?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
175
178
|
tfoot?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
176
|
-
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
177
|
-
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
178
179
|
td?: _$react.FC<_$react.DetailedHTMLProps<_$react.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
179
180
|
caption?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
180
181
|
colgroup?: _$react.FC<_$react.DetailedHTMLProps<_$react.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -209,7 +210,6 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
209
210
|
summary?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
210
211
|
dialog?: _$react.FC<_$react.DetailedHTMLProps<_$react.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
211
212
|
br?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
212
|
-
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
213
213
|
wbr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
214
214
|
ruby?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
215
215
|
rt?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -231,6 +231,9 @@ declare const MarkdownProvider: _$react.FC<index_d_exports.MarkdownProviderOptio
|
|
|
231
231
|
declare const useMarkdownContext: () => {
|
|
232
232
|
components?: {} & {
|
|
233
233
|
object?: _$react.FC<_$react.DetailedHTMLProps<_$react.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
234
|
+
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
235
|
+
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
236
|
+
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
234
237
|
html?: _$react.FC<_$react.DetailedHTMLProps<_$react.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
235
238
|
head?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
236
239
|
body?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -284,8 +287,6 @@ declare const useMarkdownContext: () => {
|
|
|
284
287
|
thead?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
285
288
|
tbody?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
286
289
|
tfoot?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
287
|
-
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
288
|
-
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
289
290
|
td?: _$react.FC<_$react.DetailedHTMLProps<_$react.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
290
291
|
caption?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
291
292
|
colgroup?: _$react.FC<_$react.DetailedHTMLProps<_$react.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -320,7 +321,6 @@ declare const useMarkdownContext: () => {
|
|
|
320
321
|
summary?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
321
322
|
dialog?: _$react.FC<_$react.DetailedHTMLProps<_$react.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
322
323
|
br?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
323
|
-
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
324
324
|
wbr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
325
325
|
ruby?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
326
326
|
rt?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -335,6 +335,9 @@ declare const useMarkdownContext: () => {
|
|
|
335
335
|
};
|
|
336
336
|
renderMarkdown: (markdown: string, options?: index_d_exports.MarkdownProviderOptions, components?: {} & {
|
|
337
337
|
object?: _$react.FC<_$react.DetailedHTMLProps<_$react.ObjectHTMLAttributes<HTMLObjectElement>, HTMLObjectElement>>;
|
|
338
|
+
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
339
|
+
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
340
|
+
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
338
341
|
html?: _$react.FC<_$react.DetailedHTMLProps<_$react.HtmlHTMLAttributes<HTMLHtmlElement>, HTMLHtmlElement>>;
|
|
339
342
|
head?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHeadElement>, HTMLHeadElement>>;
|
|
340
343
|
body?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBodyElement>, HTMLBodyElement>>;
|
|
@@ -388,8 +391,6 @@ declare const useMarkdownContext: () => {
|
|
|
388
391
|
thead?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
389
392
|
tbody?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
390
393
|
tfoot?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableSectionElement>, HTMLTableSectionElement>>;
|
|
391
|
-
tr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLTableRowElement>, HTMLTableRowElement>>;
|
|
392
|
-
th?: _$react.FC<_$react.DetailedHTMLProps<_$react.ThHTMLAttributes<HTMLTableHeaderCellElement>, HTMLTableHeaderCellElement>>;
|
|
393
394
|
td?: _$react.FC<_$react.DetailedHTMLProps<_$react.TdHTMLAttributes<HTMLTableDataCellElement>, HTMLTableDataCellElement>>;
|
|
394
395
|
caption?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
395
396
|
colgroup?: _$react.FC<_$react.DetailedHTMLProps<_$react.ColgroupHTMLAttributes<HTMLTableColElement>, HTMLTableColElement>>;
|
|
@@ -424,7 +425,6 @@ declare const useMarkdownContext: () => {
|
|
|
424
425
|
summary?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
425
426
|
dialog?: _$react.FC<_$react.DetailedHTMLProps<_$react.DialogHTMLAttributes<HTMLDialogElement>, HTMLDialogElement>>;
|
|
426
427
|
br?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLBRElement>, HTMLBRElement>>;
|
|
427
|
-
hr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLHRElement>, HTMLHRElement>>;
|
|
428
428
|
wbr?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
429
429
|
ruby?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
430
430
|
rt?: _$react.FC<_$react.DetailedHTMLProps<_$react.HTMLAttributes<HTMLElement>, HTMLElement>>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { NextConfig } from "next";
|
|
2
|
+
import { PluginNodeType } from "@intlayer/chokidar/utils";
|
|
2
3
|
import { GetConfigurationOptions } from "@intlayer/config/node";
|
|
3
4
|
|
|
4
5
|
//#region src/server/withIntlayer.d.ts
|
|
@@ -16,7 +17,7 @@ type WithIntlayerOptions = GetConfigurationOptions & {
|
|
|
16
17
|
* export default withIntlayerSync(nextConfig)
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
|
-
declare const withIntlayerSync: <T extends Partial<NextConfig>>(nextConfig?: T, configOptions?: WithIntlayerOptions) => NextConfig & T;
|
|
20
|
+
declare const withIntlayerSync: <T extends Partial<NextConfig>>(nextConfig?: T, configOptions?: WithIntlayerOptions, unusedNodeTypesFromAsync?: PluginNodeType[]) => NextConfig & T;
|
|
20
21
|
/**
|
|
21
22
|
* A Next.js plugin that adds the intlayer configuration to the webpack configuration
|
|
22
23
|
* and sets the environment variables
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"withIntlayer.d.ts","names":[],"sources":["../../../src/server/withIntlayer.ts"],"mappings":";;;;;KAyRK,mBAAA,GAAsB,uBAAA;EACzB,eAAA;AAAA;;;;;AAcF;;;;;;;cAAa,gBAAA,aAA8B,OAAA,CAAQ,UAAA,GACjD,UAAA,GAAY,CAAA,EACZ,aAAA,GAAgB,mBAAA,EAChB,wBAAA,GAA2B,cAAA,OAC1B,UAAA,GAAa,CAAA;;;;;;;;;;;;;;;;cA6OH,YAAA,aAAgC,OAAA,CAAQ,UAAA,GACnD,UAAA,GAAY,CAAA,GAAI,OAAA,CAAQ,CAAA,GACxB,aAAA,GAAgB,mBAAA,KACf,OAAA,CAAQ,UAAA,GAAa,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-intlayer",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Simplify internationalization i18n in Next.js with context providers, hooks, locale detection, and multilingual content integration.",
|
|
6
6
|
"keywords": [
|
|
@@ -129,15 +129,15 @@
|
|
|
129
129
|
"typecheck": "tsc --noEmit --project tsconfig.types.json"
|
|
130
130
|
},
|
|
131
131
|
"dependencies": {
|
|
132
|
-
"@intlayer/chokidar": "8.6.
|
|
133
|
-
"@intlayer/config": "8.6.
|
|
134
|
-
"@intlayer/core": "8.6.
|
|
135
|
-
"@intlayer/dictionaries-entry": "8.6.
|
|
136
|
-
"@intlayer/types": "8.6.
|
|
137
|
-
"@intlayer/webpack": "8.6.
|
|
132
|
+
"@intlayer/chokidar": "8.6.1",
|
|
133
|
+
"@intlayer/config": "8.6.1",
|
|
134
|
+
"@intlayer/core": "8.6.1",
|
|
135
|
+
"@intlayer/dictionaries-entry": "8.6.1",
|
|
136
|
+
"@intlayer/types": "8.6.1",
|
|
137
|
+
"@intlayer/webpack": "8.6.1",
|
|
138
138
|
"defu": "6.1.4",
|
|
139
139
|
"node-loader": "2.1.0",
|
|
140
|
-
"react-intlayer": "8.6.
|
|
140
|
+
"react-intlayer": "8.6.1"
|
|
141
141
|
},
|
|
142
142
|
"devDependencies": {
|
|
143
143
|
"@types/node": "25.5.0",
|
|
@@ -154,7 +154,13 @@
|
|
|
154
154
|
"peerDependencies": {
|
|
155
155
|
"next": ">=14.0.0",
|
|
156
156
|
"react": ">=16.0.0",
|
|
157
|
-
"react-dom": ">=16.0.0"
|
|
157
|
+
"react-dom": ">=16.0.0",
|
|
158
|
+
"webpack": "^5.0.0"
|
|
159
|
+
},
|
|
160
|
+
"peerDependenciesMeta": {
|
|
161
|
+
"webpack": {
|
|
162
|
+
"optional": true
|
|
163
|
+
}
|
|
158
164
|
},
|
|
159
165
|
"engines": {
|
|
160
166
|
"node": ">=14.18"
|