@varlock/nextjs-integration 1.0.0 → 1.0.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/README.md +3 -0
- package/dist/loader.js +88 -0
- package/dist/loader.js.map +1 -0
- package/dist/next-env-compat.js +17560 -101
- package/dist/next-env-compat.js.map +1 -1
- package/dist/plugin.js +434 -141
- package/dist/plugin.js.map +1 -1
- package/package.json +16 -16
- package/LICENSE +0 -21
- package/dist/patch-next-runtime.js +0 -14
- package/dist/patch-next-runtime.js.map +0 -1
- /package/dist/{patch-next-runtime.d.ts → loader.d.ts} +0 -0
package/dist/plugin.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/plugin.ts"],"names":["patchGlobalConsole","fs","scanForLeaks","varlockSettings","patchGlobalServerResponse","redactSensitiveConfig","path"],"mappings":";;;;;;;;;;;;;;AAgBA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,aAAA,EAAe;AAC9B,EAAA,OAAA,CAAQ,KAAA,CAAM;AAAA,IACZ,0DAAA;AAAA,IACA,EAAA;AAAA,IACA,gFAAA;AAAA,IACA,kEAAA;AAAA,IACA;AAAA,GACF,CAAE,IAAA,CAAK,IAAI,CAAC,CAAA;AACZ,EAAA,MAAM,IAAI,MAAM,oDAAoD,CAAA;AACtE;AAEAA,+BAAA,EAAmB;AAEnB,IAAM,SAAA,GAAY,CAAC,CAAC,OAAA,CAAQ,GAAA,CAAI,mBAAA;AAChC,SAAS,SAAS,IAAA,EAAkB;AAClC,EAAA,IAAI,CAAC,OAAA,CAAQ,GAAA,CAAI,8BAAA,EAAgC;AACjD,EAAA,OAAA,CAAQ,GAAA;AAAA,IACN,QAAA;AAAA,IACA,YAAY,WAAA,GAAc,UAAA;AAAA,IAC1B,IAAA;AAAA,IACA,GAAG;AAAA,GACL;AACF;AACA,KAAA,CAAM,wDAAmD,CAAA;AAEzD,IAAM,mBAAA,GAAsB,0BAAA;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AAEA,oBAAA,IAAI,WAAA,CAAY,QAAA,CAAS,yBAAyB,CAAA,EAAG;AACnD,sBAAA,WAAA,CAAY,WAAA,CAAY,yBAAA,EAA2B,mCAAA,CAAoC,IAAI,CAAC,CAAA;AAAA,oBAC9F;AAAA,kBACF;AAAA,iBACF;AAAA,cACF,CAAC,CAAA;AAAA,YACH;AAAA,WAED,CAAA;AAED,UAAA,OAAO,aAAA;AAAA,QACT;AAAA,OACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF","file":"plugin.js","sourcesContent":["/* eslint-disable no-console */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport type { NextConfig } from 'next';\n\nimport {\n redactSensitiveConfig, scanForLeaks, varlockSettings,\n} from 'varlock/env';\nimport { patchGlobalServerResponse } from 'varlock/patch-server-response';\nimport { patchGlobalConsole } from 'varlock/patch-console';\n\nimport { type SerializedEnvGraph } from 'varlock';\n\n// make sure varlock has acutally loaded the env files\n// NOTE - we dont need to call `initVarlockEnv` becuase the next-env-compat has already been loaded and called it\nif (!process.env.__VARLOCK_ENV) {\n console.error([\n '🚨 process.env.__VARLOCK_ENV is not set 🚨',\n '',\n 'To use this plugin, you must override @next/env with @varlock/next-integration',\n 'See https://varlock.dev/integrations/nextjs for more information',\n '',\n ].join('\\n'));\n throw new Error('VarlockNextWebpackPlugin: __VARLOCK_ENV is not set');\n}\n\npatchGlobalConsole();\n\nconst IS_WORKER = !!process.env.NEXT_PRIVATE_WORKER;\nfunction debug(...args: Array<any>) {\n if (!process.env.DEBUG_VARLOCK_NEXT_INTEGRATION) return;\n console.log(\n 'plugin',\n IS_WORKER ? '[worker] ' : '[server]',\n '--',\n ...args,\n );\n}\ndebug('✨ LOADED @varlock/next-integration/plugin module!');\n\nconst WEBPACK_PLUGIN_NAME = 'VarlockNextWebpackPlugin';\n\ntype VarlockPluginOptions = {\n // injectResolvedConfigAtBuildTime: boolean,\n};\n\nlet scannedStaticFiles = false;\nasync function scanStaticFiles(nextDirPath: string) {\n scannedStaticFiles = true;\n for await (const file of fs.promises.glob(`${nextDirPath}/**/*.html`)) {\n const fileContents = await fs.promises.readFile(file, 'utf8');\n scanForLeaks(fileContents, { method: 'nextjs scan static html files', file });\n }\n}\n\n// not all file writes go through this, at least in Next 15\n// (likely because webpack and prerendering are happening in workers)\n// but we can use this to monitor writing of certain files and give ourselves a \"hook\"\n// which we can then scan existing files\nfunction patchGlobalFsMethods() {\n // patch fs.promises.writeFile\n const origWriteFileFn = fs.promises.writeFile;\n fs.promises.writeFile = async function dmnoPatchedWriteFile(...args) {\n const filePath = args[0].toString();\n // const fileContents = args[1].toString();\n // console.log('⚡️ patched fs.promises.writeFile', filePath);\n\n if (filePath.endsWith('/.next/next-server.js.nft.json') && !scannedStaticFiles) {\n const nextDirPath = filePath.substring(0, filePath.lastIndexOf('/'));\n await scanStaticFiles(nextDirPath);\n }\n\n // // naively enable/disable detection based on file extension... probably not the best logic but it might be enough?\n // if (\n // filePath.endsWith('.html')\n // || filePath.endsWith('.rsc')\n // || filePath.endsWith('.body')\n // // we also need to scan .js files, but they are already built by webpack so we can't catch it here\n // ) {\n // // TODO: better error details to help user _find_ the problem\n // scanForLeaks(fileContents, { method: 'nextjs fs.writeFile', file: filePath });\n // }\n\n return origWriteFileFn.call(this, ...args);\n };\n}\n\n\n// We use a proxy object for the static replacements that we pass to webpack.DefinePlugin\n// because this plugin/webpack code is not invoked again when env files change\n// instead next is direcly messing with the existing plugins for their own changes\n// so instead we use a proxy object, and grab the values off of process.env.__VARLOCK_ENV\n// which will have been updated by our next-env-compat code\nlet latestLoadedVarlockEnv: SerializedEnvGraph | undefined;\nconst StaticReplacementsProxy = new Proxy({} as Record<string, string>, {\n ownKeys(_target) {\n latestLoadedVarlockEnv = JSON.parse(process.env.__VARLOCK_ENV || '{}') as SerializedEnvGraph;\n const replaceKeys = [] as Array<string>;\n for (const itemKey in latestLoadedVarlockEnv.config) {\n const item = latestLoadedVarlockEnv.config[itemKey];\n if (!item.isSensitive) replaceKeys.push(`ENV.${itemKey}`);\n }\n debug('reloaded static replacements keys', replaceKeys);\n return replaceKeys;\n },\n getOwnPropertyDescriptor(_target, prop) {\n const itemKey = prop.toString().split('.')[1];\n const item = latestLoadedVarlockEnv?.config[itemKey];\n if (!item || item.isSensitive) return;\n return {\n value: '', // this value is not used, the get handler will return the value\n writable: false,\n enumerable: true,\n configurable: true,\n };\n },\n get(_target, prop) {\n const itemKey = prop.toString().split('.')[1];\n const item = latestLoadedVarlockEnv?.config[itemKey];\n if (item && !item.isSensitive) return JSON.stringify(item.value);\n },\n});\n\n\n\n\nexport type NextConfigFunction = (\n phase: string,\n defaults: { defaultConfig: NextConfig },\n) => NextConfig | PromiseLike<NextConfig>;\n\n\n// we make this a plugin a function because we'll likely end up adding some options\nexport function varlockNextConfigPlugin(_pluginOptions?: VarlockPluginOptions) {\n // nextjs doesnt have a proper plugin system :(\n // so we use a function which takes in a config object and returns an augmented one\n return (nextConfig: any | NextConfig | NextConfigFunction): NextConfigFunction => {\n debug('varlockNextConfigPlugin init fn');\n\n return async (phase: string, defaults: { defaultConfig: NextConfig }) => {\n let resolvedNextConfig: NextConfig;\n if (typeof nextConfig === 'function') {\n const nextConfigFnResult = nextConfig(phase, defaults);\n resolvedNextConfig = await nextConfigFnResult;\n } else {\n resolvedNextConfig = nextConfig;\n }\n\n if (process.env.TURBOPACK || process.env.npm_config_turbopack) {\n console.error([\n '🚨 @varlock/nextjs-integration: Turbopack is not yet supported for varlockNextConfigPlugin 🚨',\n '',\n 'You can either stop using the `--turbopack` flag',\n 'or remove this plugin from your config, and only use the @next/env override.',\n \"However if you don't use the plugin, you will not get all the benefits of this integration.\",\n '',\n ].join('\\n'));\n throw new Error('varlockNextConfigPlugin: Turbopack is not yet supported');\n }\n\n return {\n ...resolvedNextConfig,\n webpack(webpackConfig, options) {\n debug('varlockNextConfigPlugin webpack config patching');\n\n const { dev } = options; // also available - isServer, nextRuntime\n\n if (varlockSettings.preventLeaks) {\n // we patch fs methods - ideally we would just path them to scan while files are written\n // but instead we use it to detect what phase the build is in, and then run our own scan on already built files\n patchGlobalFsMethods();\n\n // have to wait to run this until here when we know if this is dev mode or not\n patchGlobalServerResponse({\n // ignore sourcemaps - although we may in future want to scrub them?\n ignoreUrlPatterns: [/^\\/__nextjs_source-map\\?.*/],\n // in dev mode, we redact the secrets rather than throwing, because otherwise the dev server crashes\n redactInsteadOfThrow: dev,\n });\n }\n\n // webpack itself is passed in so we dont have to import it (or make it a dependency)\n const webpack = options.webpack;\n\n // apply existing user customizations if there are any\n if (resolvedNextConfig.webpack) {\n webpackConfig = resolvedNextConfig.webpack(webpackConfig, options);\n }\n\n if (!process.env.__VARLOCK_ENV) throw new Error('VarlockNextWebpackPlugin: __VARLOCK_ENV is not set');\n\n // Set up build-time replacements / rewrites - using webpack.DefinePlugin and a proxy\n // TODO: use shared helpers from core library?\n debug('adding ENV.xxx static replacements proxy object');\n webpackConfig.plugins.push(new webpack.DefinePlugin(StaticReplacementsProxy));\n\n if (varlockSettings.preventLeaks) {\n webpackConfig.plugins.push({\n apply(compiler: any) {\n compiler.hooks.assetEmitted.tap(WEBPACK_PLUGIN_NAME, (file: any, assetDetails: any) => {\n const { content, targetPath } = assetDetails;\n // debug('emit file: ', targetPath);\n\n if (\n targetPath.includes('/.next/static/chunks/')\n // Dont think these actually ever happen?\n || targetPath.endsWith('.html')\n || targetPath.endsWith('.body')\n || targetPath.endsWith('.rsc')\n ) {\n // NOTE - in dev mode the request hangs on the error, but the console error should help\n // and during a build, it will actually fail the build\n try {\n scanForLeaks(content, {\n method: '@varlock/nextjs-integration/plugin - assetEmitted hook',\n file: targetPath,\n });\n } catch (err) {\n if (dev) {\n // overwrite file with redacted version\n fs.writeFileSync(targetPath, redactSensitiveConfig(content.toString()));\n } else {\n throw err;\n }\n }\n }\n });\n },\n });\n }\n\n\n\n\n // we need to inject the dmno globals injector and call it\n // and in vercel/netlify etc where we can't run via `dmno run` we need to inject the resolved config into the build\n // not sure if this is the best way, but injecting into the `webpack-runtime.js` file seems to run everywhere\n\n // updates the webpack source to inject dmno global logic and call it\n // we run this on the runtimes for serverless and edge\n function injectVarlockInitIntoWebpackRuntime(_edgeRuntime = false) {\n return function assetUpdateFn(origSource: any) {\n const origSourceStr = origSource.source();\n\n // we will inline the injector code, but need a different version if we are running in the edge runtime\n // const injectorSrc = getCjsModuleSource(`dmno/injector-standalone${edgeRuntime ? '/edge' : ''}`);\n const injectorPath = path.resolve(__dirname, './patch-next-runtime.js');\n const injectorSrc = fs.readFileSync(injectorPath, 'utf8');\n\n\n const updatedSourceStr = [\n // TODO: reimplement dynamic/static functionality, which triggers a call to next/headers (or similar)\n // when accessing a dynamic env item. This will force the page into dynamic rendering mode\n // see DMNO integration for more details\n\n // inline the dmno injector code\n injectorSrc,\n origSourceStr,\n ].join('\\n');\n\n return new webpack.sources.RawSource(updatedSourceStr);\n };\n }\n\n webpackConfig.plugins.push({\n apply(compiler: any) {\n compiler.hooks.thisCompilation.tap(WEBPACK_PLUGIN_NAME, (compilation: any) => {\n compilation.hooks.processAssets.tap(\n {\n name: WEBPACK_PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n () => {\n // not sure why, but these paths are different in build vs dev\n if (compilation.getAsset('webpack-runtime.js')) {\n compilation.updateAsset('webpack-runtime.js', injectVarlockInitIntoWebpackRuntime());\n }\n if (compilation.getAsset('../webpack-runtime.js')) {\n compilation.updateAsset('../webpack-runtime.js', injectVarlockInitIntoWebpackRuntime());\n }\n if (compilation.getAsset('webpack-api-runtime.js')) {\n compilation.updateAsset('webpack-api-runtime.js', injectVarlockInitIntoWebpackRuntime());\n }\n if (compilation.getAsset('../webpack-api-runtime.js')) {\n compilation.updateAsset('../webpack-api-runtime.js', injectVarlockInitIntoWebpackRuntime());\n }\n\n if (compilation.getAsset('edge-runtime-webpack.js')) {\n compilation.updateAsset('edge-runtime-webpack.js', injectVarlockInitIntoWebpackRuntime(true));\n }\n },\n );\n });\n },\n\n });\n\n return webpackConfig; // must return the modified config\n },\n };\n };\n };\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/webpack-plugin.ts","../src/turbopack-runtime-inject.ts","../src/plugin.ts"],"names":["debug","patchGlobalFsMethods","varlockSettings","patchGlobalServerResponse","scanForLeaks","fs","redactSensitiveConfig","path","patchGlobalConsole","initVarlockEnv","getRedactionMapInfo"],"mappings":";;;;;;;;;;;;;;;;;;;;AAUA,IAAM,mBAAA,GAAsB,0BAAA;AAO5B,IAAI,sBAAA;AACJ,SAAS,8BAA8BA,MAAAA,EAAsC;AAC3E,EAAA,OAAO,IAAI,KAAA,CAAM,EAAC,EAA6B;AAAA,IAC7C,QAAQ,OAAA,EAAS;AACf,MAAA,sBAAA,GAAyB,IAAA,CAAK,KAAA,CAAM,OAAA,CAAQ,GAAA,CAAI,iBAAiB,IAAI,CAAA;AACrE,MAAA,MAAM,cAAc,EAAC;AACrB,MAAA,KAAA,MAAW,OAAA,IAAW,uBAAuB,MAAA,EAAQ;AACnD,QAAA,MAAM,IAAA,GAAO,sBAAA,CAAuB,MAAA,CAAO,OAAO,CAAA;AAClD,QAAA,IAAI,CAAC,IAAA,CAAK,WAAA,cAAyB,IAAA,CAAK,CAAA,IAAA,EAAO,OAAO,CAAA,CAAE,CAAA;AAAA,MAC1D;AACA,MAAAA,MAAAA,CAAM,qCAAqC,WAAW,CAAA;AACtD,MAAA,OAAO,WAAA;AAAA,IACT,CAAA;AAAA,IACA,wBAAA,CAAyB,SAAS,IAAA,EAAM;AACtC,MAAA,MAAM,UAAU,IAAA,CAAK,QAAA,GAAW,KAAA,CAAM,GAAG,EAAE,CAAC,CAAA;AAC5C,MAAA,MAAM,IAAA,GAAO,sBAAA,EAAwB,MAAA,CAAO,OAAO,CAAA;AACnD,MAAA,IAAI,CAAC,IAAA,IAAQ,IAAA,CAAK,WAAA,EAAa;AAC/B,MAAA,OAAO;AAAA,QACL,KAAA,EAAO,EAAA;AAAA;AAAA,QACP,QAAA,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CAAA,EAAGA,sBAAAA,CAAK,IAAA,CAAK,QAAA,EAAU,cAAc,CAAC,CAAA;AAC3F,YAAAP,MAAAA,CAAM,mCAAmC,QAAQ,CAAA;AAAA,UACnD,SAAS,GAAA,EAAK;AACZ,YAAA,OAAA,CAAQ,IAAA,CAAK,mDAAmD,GAAG,CAAA;AAAA,UACrE;AAEA,UAAA,eAAA,CAAgB,iBAAiB,EAAC;AAClC,UAAA,eAAA,CAAgB,YAAA,CAAa,aAAa,CAAA,GAAI,6CAAA;AAC9C,UAAA,eAAA,CAAgB,YAAA,CAAa,uBAAuB,CAAA,GAAI,uDAAA;AACxD,UAAA,eAAA,CAAgB,YAAA,CAAa,+BAA+B,CAAA,GAAI,+DAAA;AAChE,UAAA,eAAA,CAAgB,YAAA,CAAa,wBAAwB,CAAA,GAAI,wDAAA;AACzD,UAAA,eAAA,CAAgB,YAAA,CAAa,qBAAqB,CAAA,GAAI,sDAAA;AACtD,UAAA,eAAA,CAAgB,YAAA,CAAa,mBAAmB,CAAA,GAAI,oDAAA;AACpD,UAAAA,OAAM,2EAA2E,CAAA;AAAA,QACnF,CAAA,MAAO;AACL,UAAAA,OAAM,6DAA6D,CAAA;AAAA,QACrE;AAAA,MACF;AAEA,MAAA,OAAO;AAAA,QACL,GAAG,kBAAA;AAAA,QACH,GAAG,WAAA,IAAe;AAAA,UAChB,WAAY,kBAAA,CAA2B;AAAA,SACzC;AAAA,QACA,GAAG,CAAC,YAAA,IAAgB;AAAA,UAClB,OAAA,EAAS,qBAAA,CAAsB,kBAAA,EAAoB,oBAAA,EAAsBA,QAAO,OAAO;AAAA;AACzF,OACF;AAAA,IACF,CAAA;AAAA,EACF,CAAA;AACF","file":"plugin.js","sourcesContent":["import fs from 'node:fs';\n\nimport {\n redactSensitiveConfig, scanForLeaks, varlockSettings,\n} from 'varlock/env';\nimport { patchGlobalServerResponse } from 'varlock/patch-server-response';\n\nimport { type SerializedEnvGraph } from 'varlock';\nimport type { NextConfig } from 'next';\n\nconst WEBPACK_PLUGIN_NAME = 'VarlockNextWebpackPlugin';\n\n// We use a proxy object for the static replacements that we pass to webpack.DefinePlugin\n// because this plugin/webpack code is not invoked again when env files change\n// instead next is direcly messing with the existing plugins for their own changes\n// so instead we use a proxy object, and grab the values off of process.env.__VARLOCK_ENV\n// which will have been updated by our next-env-compat code\nlet latestLoadedVarlockEnv: SerializedEnvGraph | undefined;\nfunction createStaticReplacementsProxy(debug: (...args: Array<any>) => void) {\n return new Proxy({} as Record<string, string>, {\n ownKeys(_target) {\n latestLoadedVarlockEnv = JSON.parse(process.env.__VARLOCK_ENV || '{}') as SerializedEnvGraph;\n const replaceKeys = [] as Array<string>;\n for (const itemKey in latestLoadedVarlockEnv.config) {\n const item = latestLoadedVarlockEnv.config[itemKey];\n if (!item.isSensitive) replaceKeys.push(`ENV.${itemKey}`);\n }\n debug('reloaded static replacements keys', replaceKeys);\n return replaceKeys;\n },\n getOwnPropertyDescriptor(_target, prop) {\n const itemKey = prop.toString().split('.')[1];\n const item = latestLoadedVarlockEnv?.config[itemKey];\n if (!item || item.isSensitive) return;\n return {\n value: '', // this value is not used, the get handler will return the value\n writable: false,\n enumerable: true,\n configurable: true,\n };\n },\n get(_target, prop) {\n const itemKey = prop.toString().split('.')[1];\n const item = latestLoadedVarlockEnv?.config[itemKey];\n if (item && !item.isSensitive) return JSON.stringify(item.value);\n },\n });\n}\n\nexport function createWebpackConfigFn(\n resolvedNextConfig: NextConfig,\n patchGlobalFsMethods: () => void,\n debug: (...args: Array<any>) => void,\n isBuild: boolean,\n) {\n const staticReplacementsProxy = createStaticReplacementsProxy(debug);\n\n return function webpackConfigFn(webpackConfig: any, options: any) {\n debug('varlockNextConfigPlugin webpack config patching');\n\n const { dev } = options; // also available - isServer, nextRuntime\n\n // only patch fs methods during builds — they create \"hooks\" for post-build\n // scanning/scrubbing and are unnecessary during dev\n if (isBuild) patchGlobalFsMethods();\n\n if (varlockSettings.preventLeaks) {\n // have to wait to run this until here when we know if this is dev mode or not\n patchGlobalServerResponse({\n ignoreUrlPatterns: [\n /^\\/__nextjs_source-map\\?.*/, // sourcemaps\n /[?&]_rsc=/, // RSC payloads are server-side and expected to contain sensitive data\n ],\n // in dev mode, we redact the secrets rather than throwing, because otherwise the dev server crashes\n redactInsteadOfThrow: dev,\n });\n }\n\n // webpack itself is passed in so we dont have to import it (or make it a dependency)\n const webpack = options.webpack;\n\n // apply existing user customizations if there are any\n if (resolvedNextConfig.webpack) {\n webpackConfig = resolvedNextConfig.webpack(webpackConfig, options);\n }\n\n if (!process.env.__VARLOCK_ENV) throw new Error('VarlockNextWebpackPlugin: __VARLOCK_ENV is not set');\n\n // Add per-file init guard for server (non-edge) compilations.\n // Pre-rendering workers may receive compiled code via IPC rather than loading\n // runtime files from disk, so runtime injection alone isn't sufficient.\n // The loader ensures initVarlockEnv() and patchGlobalConsole() run in every worker.\n // alwaysRepatchConsole: in webpack, React wraps console for RSC dev replay AFTER\n // our initial patch in the runtime file, so we re-patch in each file to ensure\n // our redaction wraps React's wrapper. (Turbopack doesn't need this.)\n if (options.isServer && options.nextRuntime !== 'edge') {\n webpackConfig.module.rules.push({\n test: /\\.(js|jsx|ts|tsx|mjs|mts)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: require.resolve('./loader'),\n options: { bundler: 'webpack' },\n },\n ],\n });\n }\n // Edge compilation: also re-patch console to wrap React's RSC dev replay wrapper.\n // Edge can't use require(), so we call globalThis.__varlockPatchConsole which the\n // init-edge bundle exposes after running.\n if (options.isServer && options.nextRuntime === 'edge') {\n webpackConfig.module.rules.push({\n test: /\\.(js|jsx|ts|tsx|mjs|mts)$/,\n exclude: /node_modules/,\n use: [\n {\n loader: require.resolve('./loader'),\n options: { bundler: 'webpack', isEdge: true },\n },\n ],\n });\n }\n\n // Set up build-time replacements / rewrites - using webpack.DefinePlugin and a proxy\n // TODO: use shared helpers from core library?\n debug('adding ENV.xxx static replacements proxy object');\n webpackConfig.plugins.push(new webpack.DefinePlugin(staticReplacementsProxy));\n\n if (varlockSettings.preventLeaks) {\n webpackConfig.plugins.push({\n apply(compiler: any) {\n compiler.hooks.assetEmitted.tap(WEBPACK_PLUGIN_NAME, (_file: any, assetDetails: any) => {\n const { content, targetPath } = assetDetails;\n\n if (\n targetPath.includes('/.next/static/chunks/')\n || targetPath.endsWith('.html')\n // .rsc and .body are server-side (RSC payloads), not client-facing\n ) {\n // NOTE - in dev mode the request hangs on the error, but the console error should help\n // and during a build, it will actually fail the build\n try {\n scanForLeaks(content, {\n method: '@varlock/nextjs-integration/plugin - assetEmitted hook',\n file: targetPath,\n });\n } catch (err) {\n if (dev) {\n // overwrite file with redacted version\n fs.writeFileSync(targetPath, redactSensitiveConfig(content.toString()));\n } else {\n throw err;\n }\n }\n }\n });\n },\n });\n }\n\n // Inject varlock init into webpack runtime files.\n // We prepend the self-contained init bundle as raw JS so it runs before any module code.\n // Server runtimes get the full init (with server-response patching),\n // edge runtimes get the edge-safe init (no node:zlib/node:http).\n function injectVarlockInitIntoWebpackRuntime(edgeRuntime = false) {\n return function assetUpdateFn(origSource: any) {\n const origSourceStr = origSource.source();\n\n const initBundleName = edgeRuntime ? 'init-edge' : 'init-server';\n const injectorPath = require.resolve(`varlock/${initBundleName}`);\n const injectorSrc = fs.readFileSync(injectorPath, 'utf8');\n\n // inline the resolved env so it's baked into the build\n // this removes the need for a .env.production.local file on platforms like Vercel\n const rawEnv = process.env.__VARLOCK_ENV;\n const envInline = rawEnv\n ? `process.env.__VARLOCK_ENV = process.env.__VARLOCK_ENV || ${JSON.stringify(rawEnv)};`\n : '';\n\n const updatedSourceStr = [\n envInline,\n // Wrap in IIFE to avoid symbol collisions when bundlers concatenate files.\n // Provide dummy exports/module since the CJS bundle uses `exports.X = ...`\n `(function(exports,module){${injectorSrc}})({},{exports:{}});`,\n origSourceStr,\n ].join('\\n');\n\n return new webpack.sources.RawSource(updatedSourceStr);\n };\n }\n\n const isEdgeRuntime = options.nextRuntime === 'edge';\n webpackConfig.plugins.push({\n apply(compiler: any) {\n compiler.hooks.thisCompilation.tap(WEBPACK_PLUGIN_NAME, (compilation: any) => {\n compilation.hooks.processAssets.tap(\n {\n name: WEBPACK_PLUGIN_NAME,\n stage: webpack.Compilation.PROCESS_ASSETS_STAGE_ADDITIONS,\n },\n () => {\n if (isEdgeRuntime) {\n // Edge compilation — only inject the edge-safe init bundle (no node builtins)\n if (compilation.getAsset('edge-runtime-webpack.js')) {\n compilation.updateAsset('edge-runtime-webpack.js', injectVarlockInitIntoWebpackRuntime(true));\n }\n // Edge compilation also has webpack-runtime.js — inject init-edge there too\n for (const name of ['webpack-runtime.js', '../webpack-runtime.js']) {\n if (compilation.getAsset(name)) {\n compilation.updateAsset(name, injectVarlockInitIntoWebpackRuntime(true));\n }\n }\n } else if (options.isServer) {\n // Server (node.js) compilation — inject full init with server-response patching\n for (const name of ['webpack-runtime.js', '../webpack-runtime.js', 'webpack-api-runtime.js', '../webpack-api-runtime.js']) {\n if (compilation.getAsset(name)) {\n compilation.updateAsset(name, injectVarlockInitIntoWebpackRuntime());\n }\n }\n }\n },\n );\n });\n },\n });\n\n return webpackConfig; // must return the modified config\n };\n}\n","import fs from 'node:fs';\nimport path from 'node:path';\n\nfunction debug(...args: Array<any>) {\n if (!process.env.DEBUG_VARLOCK_NEXT_INTEGRATION) return;\n // eslint-disable-next-line no-console\n console.log('[varlock]', ...args);\n}\n\n/**\n * Inject varlock init bundle into turbopack runtime files (analogous to webpack runtime injection).\n * Turbopack writes `[turbopack]_runtime.js` files during compilation — these are loaded by\n * the deployed server before any user code runs, making them the ideal injection point.\n *\n * Note: pre-rendering workers during builds receive compiled code via IPC (not from disk),\n * so this injection only takes effect for the deployed server. Build-time init is handled\n * by the turbopack loader's init guard snippet.\n */\nlet injectedTurbopackRuntime = false;\nexport function injectVarlockInitIntoTurbopackRuntime(nextDirPath: string) {\n if (injectedTurbopackRuntime) return;\n\n const rawEnv = process.env.__VARLOCK_ENV;\n if (!rawEnv) {\n return;\n }\n\n // Find turbopack runtime files ([turbopack]_runtime.js) and edge-wrapper files.\n // Node.js SSR/build uses [turbopack]_runtime.js, while edge runtime uses\n // edge-wrapper JS files (no [turbopack]_runtime.js exists for edge).\n const serverRuntimeFiles: Array<string> = [];\n const edgeWrapperFiles: Array<string> = [];\n const walkDir = (dir: string) => {\n if (!fs.existsSync(dir)) return;\n for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {\n if (entry.isDirectory()) {\n walkDir(path.join(dir, entry.name));\n } else if (entry.name === '[turbopack]_runtime.js') {\n serverRuntimeFiles.push(path.join(dir, entry.name));\n } else if (entry.name.includes('edge-wrapper') && entry.name.endsWith('.js')) {\n edgeWrapperFiles.push(path.join(dir, entry.name));\n }\n }\n };\n walkDir(nextDirPath);\n\n debug(`turbopack runtime injection: found ${serverRuntimeFiles.length} server runtime files, ${edgeWrapperFiles.length} edge wrapper files`);\n\n if (!serverRuntimeFiles.length) {\n // Runtime files may not exist yet — turbopack (Rust) writes them directly.\n // We'll retry on subsequent fs writes until they appear.\n return;\n }\n\n // Mark as done so we don't retry\n injectedTurbopackRuntime = true;\n\n // Load both init bundles — server (full, node:zlib/node:http) and edge (no node builtins)\n const initServerSrc = fs.readFileSync(require.resolve('varlock/init-server'), 'utf8');\n const initEdgeSrc = fs.readFileSync(require.resolve('varlock/init-edge'), 'utf8');\n const envInline = `process.env.__VARLOCK_ENV = process.env.__VARLOCK_ENV || ${JSON.stringify(rawEnv)};`;\n\n // The CJS init bundles use `exports.X = ...` at the end, so we must provide\n // a dummy `exports` object when wrapping in an IIFE to avoid ReferenceError.\n const iifeWrap = (src: string) => `(function(exports,module){${src}})({},{exports:{}});`;\n\n // Inject init-server into [turbopack]_runtime.js files (node.js SSR + build)\n for (const runtimeFile of serverRuntimeFiles) {\n const origSource = fs.readFileSync(runtimeFile, 'utf8');\n const updatedSource = [\n envInline,\n iifeWrap(initServerSrc),\n origSource,\n ].join('\\n');\n fs.writeFileSync(runtimeFile, updatedSource);\n debug(`injected init-server into turbopack runtime: ${runtimeFile}`);\n }\n\n // Inject init-edge into edge-wrapper files (edge runtime — no node builtins)\n for (const wrapperFile of edgeWrapperFiles) {\n const origSource = fs.readFileSync(wrapperFile, 'utf8');\n const updatedSource = [\n envInline,\n iifeWrap(initEdgeSrc),\n origSource,\n ].join('\\n');\n fs.writeFileSync(wrapperFile, updatedSource);\n debug(`injected init-edge into edge wrapper: ${wrapperFile}`);\n }\n}\n\nexport function isInjectedTurbopackRuntime() {\n return injectedTurbopackRuntime;\n}\n","/* eslint-disable no-console */\n\nimport fs from 'node:fs';\nimport path from 'node:path';\nimport type { NextConfig } from 'next';\n\nimport {\n getRedactionMapInfo, initVarlockEnv, redactSensitiveConfig, scanForLeaks, varlockSettings,\n} from 'varlock/env';\nimport { patchGlobalConsole } from 'varlock/patch-console';\nimport { patchGlobalServerResponse } from 'varlock/patch-server-response';\n\nimport { type SerializedEnvGraph } from 'varlock';\nimport { createWebpackConfigFn } from './webpack-plugin';\nimport { injectVarlockInitIntoTurbopackRuntime, isInjectedTurbopackRuntime } from './turbopack-runtime-inject';\n\n// make sure varlock has actually loaded the env files\n// NOTE - we don't need to call `initVarlockEnv` because the next-env-compat has already been loaded and called it\nif (!process.env.__VARLOCK_ENV) {\n console.error([\n '🚨 process.env.__VARLOCK_ENV is not set 🚨',\n '',\n 'To use this plugin, you must override @next/env with @varlock/next-integration',\n 'See https://varlock.dev/integrations/nextjs for more information',\n '',\n ].join('\\n'));\n throw new Error('VarlockNextWebpackPlugin: __VARLOCK_ENV is not set');\n}\n\npatchGlobalConsole();\n\n// Turbopack detection at module level — needed to apply patches in worker processes\n// (the config function only runs in the main process, but workers also load this module)\nconst IS_TURBOPACK = !!(\n process.env.TURBOPACK\n || process.env.TURBOPACK_DEV\n || process.env.TURBOPACK_BUILD\n || process.env.npm_config_turbopack\n);\n\n// For turbopack, apply server response patching at module level so it takes effect\n// in worker processes (which serve actual responses). The config function's turbopack\n// branch only runs in the main process, which doesn't handle HTTP responses.\nif (IS_TURBOPACK && varlockSettings.preventLeaks) {\n patchGlobalServerResponse({\n ignoreUrlPatterns: [\n /^\\/__nextjs_source-map\\?.*/, // sourcemaps\n /[?&]_rsc=/, // RSC payloads are server-side and expected to contain sensitive data\n ],\n // always redact in dev to avoid crashing the dev server; prod builds override via init bundles\n redactInsteadOfThrow: true,\n });\n}\n\nconst IS_WORKER = !!process.env.NEXT_PRIVATE_WORKER;\nfunction debug(...args: Array<any>) {\n if (!process.env.DEBUG_VARLOCK_NEXT_INTEGRATION) return;\n console.log(\n 'plugin',\n IS_WORKER ? '[worker] ' : '[server]',\n '--',\n ...args,\n );\n}\ndebug('✨ LOADED @varlock/next-integration/plugin module!');\n\ntype VarlockPluginOptions = {\n // injectResolvedConfigAtBuildTime: boolean,\n};\n\nlet scannedStaticFiles = false;\nasync function scanStaticFiles(nextDirPath: string) {\n scannedStaticFiles = true;\n for await (const file of fs.promises.glob(`${nextDirPath}/**/*.html`)) {\n const fileContents = await fs.promises.readFile(file, 'utf8');\n scanForLeaks(fileContents, { method: 'nextjs scan static html files', file });\n }\n}\n\nlet scrubbedSourcemaps = false;\nasync function scrubSourcemaps(nextDirPath: string) {\n if (scrubbedSourcemaps) return;\n scrubbedSourcemaps = true;\n\n // build a list of sensitive values and their same-length replacements\n const envGraph: SerializedEnvGraph = JSON.parse(process.env.__VARLOCK_ENV || '{}');\n const sensitiveValues: Array<{ value: string, replacement: string }> = [];\n for (const itemKey in envGraph.config) {\n const item = envGraph.config[itemKey];\n if (item.isSensitive && item.value && typeof item.value === 'string' && item.value.length > 0) {\n // same-length replacement to preserve sourcemap column offsets\n sensitiveValues.push({\n value: item.value,\n replacement: '*'.repeat(item.value.length),\n });\n }\n }\n if (!sensitiveValues.length) {\n debug('no sensitive values to scrub from sourcemaps');\n return;\n }\n // sort longest first for maximal munch\n sensitiveValues.sort((a, b) => b.value.length - a.value.length);\n\n let scrubCount = 0;\n for await (const mapFile of fs.promises.glob(`${nextDirPath}/**/*.map`)) {\n const contents = await fs.promises.readFile(mapFile, 'utf8');\n let scrubbed = contents;\n for (const { value, replacement } of sensitiveValues) {\n scrubbed = scrubbed.replaceAll(value, replacement);\n }\n if (scrubbed !== contents) {\n await fs.promises.writeFile(mapFile, scrubbed);\n scrubCount++;\n }\n }\n debug(`scrubbed sensitive values from ${scrubCount} sourcemap files`);\n}\n\nlet scannedBuildOutput = false;\nasync function scanBuildOutputForLeaks(nextDirPath: string, opts?: { failBuild?: boolean }) {\n if (scannedBuildOutput) return;\n scannedBuildOutput = true;\n\n // varlockSettings may not be populated if initVarlockEnv hasn't run in this process,\n // so fall back to reading the setting directly from the env data\n let preventLeaks = varlockSettings.preventLeaks;\n if (preventLeaks === undefined && process.env.__VARLOCK_ENV) {\n try {\n const envGraph: SerializedEnvGraph = JSON.parse(process.env.__VARLOCK_ENV);\n preventLeaks = envGraph.settings?.preventLeaks;\n } catch { /* ignore */ }\n }\n // Ensure the redaction map is populated so scanForLeaks knows what to look for.\n // initVarlockEnv may not have run in this process (the plugin's main process).\n if (process.env.__VARLOCK_ENV) {\n // eslint-disable-next-line @stylistic/max-statements-per-line\n try { initVarlockEnv(); } catch { /* ignore if already initialized or fails */ }\n }\n const redactionInfo = getRedactionMapInfo();\n debug(`scanBuildOutputForLeaks: preventLeaks=${preventLeaks}, redactionInfo=${JSON.stringify(redactionInfo)}`);\n if (!preventLeaks) return;\n\n const leakedFiles: Array<string> = [];\n let scannedCount = 0;\n\n // scan JS chunks in .next/static/chunks/ — these are client-facing bundles\n // that should never contain sensitive values\n for await (const file of fs.promises.glob(`${nextDirPath}/static/chunks/**/*.js`)) {\n scannedCount++;\n const fileContents = await fs.promises.readFile(file, 'utf8');\n try {\n scanForLeaks(fileContents, {\n method: 'nextjs post-build scan (static chunks)',\n file,\n });\n } catch (err) {\n leakedFiles.push(file);\n // redact the file so the leak doesn't ship\n await fs.promises.writeFile(file, redactSensitiveConfig(fileContents));\n }\n }\n\n debug(`scanned ${scannedCount} static chunk files in ${nextDirPath}/static/chunks/`);\n\n // scan prerendered HTML files (client-facing static output)\n // NOTE: .rsc and .body files are server-side (RSC payloads) and are expected\n // to access sensitive data, so we don't scan those\n for (const ext of ['html']) {\n for await (const file of fs.promises.glob(`${nextDirPath}/**/*.${ext}`)) {\n scannedCount++;\n const fileContents = await fs.promises.readFile(file, 'utf8');\n try {\n scanForLeaks(fileContents, {\n method: `nextjs post-build scan (.${ext})`,\n file,\n });\n } catch (err) {\n leakedFiles.push(file);\n await fs.promises.writeFile(file, redactSensitiveConfig(fileContents));\n }\n }\n }\n\n debug(`scanned ${scannedCount} total build output files`);\n\n if (leakedFiles.length > 0) {\n const msg = `[varlock] ⚠️ found and redacted leaked secrets in ${leakedFiles.length} build output file(s):\\n${leakedFiles.map((f) => ` - ${f}`).join('\\n')}`;\n if (opts?.failBuild) {\n throw new Error(msg);\n }\n console.error(msg);\n } else {\n debug('✅ no leaks found in build output');\n }\n}\n\n// not all file writes go through this, at least in Next 15\n// (likely because webpack and prerendering are happening in workers)\n// but we can use this to monitor writing of certain files and give ourselves a \"hook\"\n// which we can then scan existing files\nfunction patchGlobalFsMethods() {\n debug('patching global fs methods');\n // patch fs.promises.writeFile\n const origWriteFileFn = fs.promises.writeFile;\n fs.promises.writeFile = async function dmnoPatchedWriteFile(...args) {\n const filePath = args[0].toString();\n debug('fs.promises.writeFile:', filePath);\n\n // BUILD_ID is written after turbopack compilation completes but before pre-rendering.\n // This is our hook to inject the init bundle into turbopack runtime files.\n if (!isInjectedTurbopackRuntime() && filePath.endsWith('/.next/export-detail.json')) {\n const nextDirPath = filePath.substring(0, filePath.lastIndexOf('/'));\n injectVarlockInitIntoTurbopackRuntime(nextDirPath);\n }\n\n if (filePath.endsWith('/.next/next-server.js.nft.json') && !scannedStaticFiles) {\n const nextDirPath = filePath.substring(0, filePath.lastIndexOf('/'));\n await scanStaticFiles(nextDirPath);\n }\n // next-server.js.nft.json is written near the end of the build, after prerendering (webpack)\n // prerender-manifest.json is written after \"Generating static pages\" completes (turbopack + webpack)\n if (\n filePath.endsWith('/.next/next-server.js.nft.json')\n || filePath.endsWith('/.next/prerender-manifest.json')\n ) {\n const nextDirPath = filePath.substring(0, filePath.lastIndexOf('/'));\n if (!scrubbedSourcemaps) await scrubSourcemaps(nextDirPath);\n if (!scannedBuildOutput) await scanBuildOutputForLeaks(nextDirPath, { failBuild: true });\n }\n\n return origWriteFileFn.call(this, ...args);\n };\n\n // also patch sync version in case turbopack uses it\n const origWriteFileSyncFn = fs.writeFileSync;\n fs.writeFileSync = function dmnoPatchedWriteFileSync(...args: Parameters<typeof fs.writeFileSync>) {\n const filePath = args[0].toString();\n debug('fs.writeFileSync:', filePath);\n\n if (!isInjectedTurbopackRuntime() && filePath.endsWith('/.next/diagnostics/build-diagnostics.json')) {\n const nextDirPath = filePath.substring(0, filePath.lastIndexOf('/'));\n injectVarlockInitIntoTurbopackRuntime(nextDirPath);\n }\n\n return origWriteFileSyncFn.call(this, ...args);\n };\n}\n\n\nexport type NextConfigFunction = (\n phase: string,\n defaults: { defaultConfig: NextConfig },\n) => NextConfig | PromiseLike<NextConfig>;\n\n\n// we make this a plugin a function because we'll likely end up adding some options\nexport function varlockNextConfigPlugin(_pluginOptions?: VarlockPluginOptions) {\n // nextjs doesnt have a proper plugin system :(\n // so we use a function which takes in a config object and returns an augmented one\n return (nextConfig: any | NextConfig | NextConfigFunction): NextConfigFunction => {\n debug('varlockNextConfigPlugin init fn');\n\n return async (phase: string, defaults: { defaultConfig: NextConfig }) => {\n let resolvedNextConfig: NextConfig;\n if (typeof nextConfig === 'function') {\n const nextConfigFnResult = nextConfig(phase, defaults);\n resolvedNextConfig = await nextConfigFnResult;\n } else {\n resolvedNextConfig = nextConfig;\n }\n\n // Next 16+ uses Turbopack by default for dev, but may not set TURBOPACK env var\n const isTurbopack = !!(\n process.env.TURBOPACK\n || process.env.TURBOPACK_DEV\n || process.env.TURBOPACK_BUILD\n || process.env.npm_config_turbopack\n );\n const isBuild = phase === 'phase-production-build';\n debug(`turbopack detection: TURBOPACK=${process.env.TURBOPACK}, TURBOPACK_DEV=${process.env.TURBOPACK_DEV}, TURBOPACK_BUILD=${process.env.TURBOPACK_BUILD}, phase=${phase}, isTurbopack=${isTurbopack}, isBuild=${isBuild}`);\n\n // For production builds, schedule a post-build scan as a safety net.\n // The fs.writeFile patches may not intercept all writes (workers), and\n // BUILD_ID is written before prerendering completes. beforeExit fires\n // after the build finishes, ensuring all output files exist.\n if (isBuild) {\n process.once('beforeExit', () => {\n const nextDirPath = path.resolve(process.cwd(), '.next');\n const scanPromises: Array<Promise<void>> = [];\n if (!scrubbedSourcemaps) scanPromises.push(scrubSourcemaps(nextDirPath));\n if (!scannedBuildOutput) scanPromises.push(scanBuildOutputForLeaks(nextDirPath, { failBuild: true }));\n if (scanPromises.length > 0) {\n // The async work keeps the event loop alive, and beforeExit\n // will fire again once it completes (but the guards prevent re-runs)\n Promise.all(scanPromises).catch((err) => {\n console.error('[varlock] post-build scan failed:', err);\n process.exitCode = 1;\n });\n }\n });\n }\n\n if (isTurbopack) {\n debug('turbopack detected, injecting loader rules');\n // only patch fs methods during builds — they create \"hooks\" for post-build\n // scanning/scrubbing and are unnecessary (and noisy) during dev\n if (isBuild) patchGlobalFsMethods();\n\n // turbopack config can be under `turbopack` (Next 15+) or `experimental.turbo` (older)\n let turbopackConfig = (resolvedNextConfig as any).turbopack\n ?? (resolvedNextConfig as any).experimental?.turbo;\n\n if (!turbopackConfig) {\n turbopackConfig = {};\n (resolvedNextConfig as any).turbopack = turbopackConfig;\n }\n\n // inject loader rules\n const loaderRule = {\n loaders: [require.resolve('./loader')],\n };\n turbopackConfig.rules ||= {};\n turbopackConfig.rules['*.{js,jsx,ts,tsx,mjs,mts}'] = loaderRule;\n\n // Turbopack can't resolve symlinked packages (e.g. link: or workspace: installs).\n // If varlock is symlinked, we copy dist files into node_modules/.varlock/ as real\n // files and set up resolve aliases so turbopack can find them.\n const varlockNodeModulesPath = path.resolve(process.cwd(), 'node_modules/varlock');\n let isSymlinked = false;\n try {\n isSymlinked = fs.lstatSync(varlockNodeModulesPath).isSymbolicLink();\n } catch { /* not found — might be hoisted or nested, skip */ }\n\n if (isSymlinked) {\n debug('varlock is symlinked, copying dist files for turbopack');\n const varlockDistDir = path.resolve(path.dirname(require.resolve('varlock/env')), '..');\n const varlockRoot = path.resolve(varlockDistDir, '..');\n const cacheDir = path.resolve(process.cwd(), 'node_modules/.varlock');\n const cacheDistDir = path.join(cacheDir, 'dist');\n try {\n fs.mkdirSync(cacheDir, { recursive: true });\n // copy dist/ and package.json so turbopack can resolve subpath exports\n fs.cpSync(varlockDistDir, cacheDistDir, { recursive: true });\n fs.copyFileSync(path.join(varlockRoot, 'package.json'), path.join(cacheDir, 'package.json'));\n debug('copied varlock package files to', cacheDir);\n } catch (err) {\n console.warn('[varlock] failed to copy varlock package files:', err);\n }\n\n turbopackConfig.resolveAlias ||= {};\n turbopackConfig.resolveAlias['varlock/env'] = './node_modules/.varlock/dist/runtime/env.js';\n turbopackConfig.resolveAlias['varlock/patch-console'] = './node_modules/.varlock/dist/runtime/patch-console.js';\n turbopackConfig.resolveAlias['varlock/patch-server-response'] = './node_modules/.varlock/dist/runtime/patch-server-response.js';\n turbopackConfig.resolveAlias['varlock/patch-response'] = './node_modules/.varlock/dist/runtime/patch-response.js';\n turbopackConfig.resolveAlias['varlock/init-server'] = './node_modules/.varlock/dist/runtime/init-server.cjs';\n turbopackConfig.resolveAlias['varlock/init-edge'] = './node_modules/.varlock/dist/runtime/init-edge.cjs';\n debug('set resolveAlias for varlock subpaths -> ./node_modules/.varlock/dist/...');\n } else {\n debug('varlock is not symlinked, turbopack can resolve it natively');\n }\n }\n\n return {\n ...resolvedNextConfig,\n ...isTurbopack && {\n turbopack: (resolvedNextConfig as any).turbopack,\n },\n ...!IS_TURBOPACK && {\n webpack: createWebpackConfigFn(resolvedNextConfig, patchGlobalFsMethods, debug, isBuild),\n },\n };\n };\n };\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@varlock/nextjs-integration",
|
|
3
3
|
"description": "drop-in replacement for @next/env that uses varlock to load .env files with validation and extra security features",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.1",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
7
7
|
"url": "https://github.com/dmno-dev/varlock.git",
|
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
"types": "dist/next-env-compat.d.ts",
|
|
12
12
|
"exports": {
|
|
13
13
|
".": "./dist/next-env-compat.js",
|
|
14
|
-
"./plugin": "./dist/plugin.js"
|
|
14
|
+
"./plugin": "./dist/plugin.js",
|
|
15
|
+
"./loader": "./dist/loader.js"
|
|
16
|
+
},
|
|
17
|
+
"files": ["dist"],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"dev": "tsup --watch",
|
|
20
|
+
"build": "rm -rf dist && tsup",
|
|
21
|
+
"typecheck": "tsc --noEmit"
|
|
15
22
|
},
|
|
16
|
-
"files": [
|
|
17
|
-
"dist"
|
|
18
|
-
],
|
|
19
23
|
"keywords": [
|
|
20
24
|
"varlock",
|
|
21
25
|
"nextjs",
|
|
@@ -36,17 +40,13 @@
|
|
|
36
40
|
"node": ">=22"
|
|
37
41
|
},
|
|
38
42
|
"peerDependencies": {
|
|
39
|
-
"
|
|
40
|
-
"
|
|
43
|
+
"varlock": "^1.0.0",
|
|
44
|
+
"next": ">=14"
|
|
41
45
|
},
|
|
42
46
|
"devDependencies": {
|
|
43
|
-
"@types/node": "
|
|
44
|
-
"tsup": "^8.5.
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
},
|
|
48
|
-
"scripts": {
|
|
49
|
-
"dev": "tsup --watch",
|
|
50
|
-
"build": "tsup"
|
|
47
|
+
"@types/node": "25.3.2",
|
|
48
|
+
"tsup": "^8.5.1",
|
|
49
|
+
"varlock": "^1.0.0",
|
|
50
|
+
"vitest": "^4.0.18"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 DMNO Inc.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var env = require('varlock/env');
|
|
4
|
-
var patchConsole = require('varlock/patch-console');
|
|
5
|
-
var patchServerResponse = require('varlock/patch-server-response');
|
|
6
|
-
var patchResponse = require('varlock/patch-response');
|
|
7
|
-
|
|
8
|
-
// src/patch-next-runtime.ts
|
|
9
|
-
env.initVarlockEnv();
|
|
10
|
-
patchConsole.patchGlobalConsole();
|
|
11
|
-
patchServerResponse.patchGlobalServerResponse();
|
|
12
|
-
patchResponse.patchGlobalResponse();
|
|
13
|
-
//# sourceMappingURL=patch-next-runtime.js.map
|
|
14
|
-
//# sourceMappingURL=patch-next-runtime.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/patch-next-runtime.ts"],"names":["initVarlockEnv","patchGlobalConsole","patchGlobalServerResponse","patchGlobalResponse"],"mappings":";;;;;;;;AAOAA,kBAAA,EAAe;AACfC,+BAAA,EAAmB;AACnBC,6CAAA,EAA0B;AAC1BC,iCAAA,EAAoB","file":"patch-next-runtime.js","sourcesContent":["import { initVarlockEnv } from 'varlock/env';\nimport { patchGlobalConsole } from 'varlock/patch-console';\nimport { patchGlobalServerResponse } from 'varlock/patch-server-response';\nimport { patchGlobalResponse } from 'varlock/patch-response';\n\n// process.env.__VARLOCK_ENV is already set by either our next-env-compat\n// or by the platform, because we generated a temp .env file which included it\ninitVarlockEnv();\npatchGlobalConsole();\npatchGlobalServerResponse();\npatchGlobalResponse();\n"]}
|
|
File without changes
|