wxt-turbo 0.1.0 → 0.2.0
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 +4 -1
- package/dist/index.cjs +7 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.mjs +1 -2
- package/dist/index.mjs.map +1 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -21,7 +21,10 @@ export default defineConfig({
|
|
|
21
21
|
modules: ['wxt-turbo'],
|
|
22
22
|
turbo: {
|
|
23
23
|
packageName: 'your-extension-package-name',
|
|
24
|
-
copyFiles: [
|
|
24
|
+
copyFiles: [
|
|
25
|
+
{ from: 'SOURCE_CODE_REVIEW.md', to: 'SOURCE_CODE_REVIEW.md' },
|
|
26
|
+
'SOURCE_CODE_REVIEW.md',
|
|
27
|
+
],
|
|
25
28
|
cleanup: true, // default: true
|
|
26
29
|
},
|
|
27
30
|
});
|
package/dist/index.cjs
CHANGED
|
@@ -6,16 +6,12 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
|
6
6
|
var __getProtoOf = Object.getPrototypeOf;
|
|
7
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
8
|
var __copyProps = (to, from, except, desc) => {
|
|
9
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
}
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
19
15
|
}
|
|
20
16
|
return to;
|
|
21
17
|
};
|
|
@@ -23,7 +19,6 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
23
19
|
value: mod,
|
|
24
20
|
enumerable: true
|
|
25
21
|
}) : target, mod));
|
|
26
|
-
|
|
27
22
|
//#endregion
|
|
28
23
|
let node_fs_promises = require("node:fs/promises");
|
|
29
24
|
let node_path = require("node:path");
|
|
@@ -31,7 +26,6 @@ let is_path_inside = require("is-path-inside");
|
|
|
31
26
|
is_path_inside = __toESM(is_path_inside);
|
|
32
27
|
let tinyexec = require("tinyexec");
|
|
33
28
|
let wxt_modules = require("wxt/modules");
|
|
34
|
-
|
|
35
29
|
//#region src/index.ts
|
|
36
30
|
const LOGGER_PREFIX = "`[wxt-turbo]`";
|
|
37
31
|
var src_default = (0, wxt_modules.defineWxtModule)({
|
|
@@ -96,7 +90,7 @@ async function clearZipSourcesRoot(wxt) {
|
|
|
96
90
|
force: true
|
|
97
91
|
});
|
|
98
92
|
}
|
|
99
|
-
|
|
100
93
|
//#endregion
|
|
101
94
|
module.exports = src_default;
|
|
95
|
+
|
|
102
96
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.cjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAM,gBAAgB;AAEtB,IAAA,eAAA,GAAA,YAAA,iBAAmD;CACjD,MAAM;CACN,WAAW;CACX,MAAM,MAAM,KAAK,SAAS;EACxB,MAAM,cAAc,SAAS;AAC7B,MAAI,CAAC,YACH,OAAM,IAAI,MAAM,0BAA0B;AAI5C,MAAI;AACF,QAAK,OAAA,GAAA,SAAA,GAAQ,SAAS,CAAC,YAAY,CAAC,EAAE,aAAa,EACjD,OAAM,IAAI,MAAM,GAAG,cAAc,sCAAsC;AAEzE,OAAI,OAAO,KAAK,eAAe,sBAAsB;WAC9C,OAAO;AAEd,OACE,iBAAiB,SACjB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,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;AAC1C,OAAI,QAAQ,WAAW,KACrB,OAAM,oBAAoB,IAAI;IAEhC;;CAEL,CAAC;AAEF,eAAe,oBAAoB,KAAU;CAC3C,MAAM,EAAE,gBAAgB,IAAI,OAAO;CAGnC,MAAM,uBAAA,GAAA,UAAA,SAA8B,IAAI,OAAO,MAAM,YAAY;AACjE,KAAI,EAAA,GAAA,eAAA,SAAc,qBAAqB,IAAI,OAAO,WAAW,CAC3D,OAAM,IAAI,MACR,GAAG,cAAc,gEAAgE,sBAClF;AAGH,QAAA,GAAA,iBAAA,IAAS,qBAAqB;EAAE,WAAW;EAAM,OAAO;EAAM,CAAC"}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as wxt from "wxt";
|
|
1
|
+
import * as _$wxt from "wxt";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
interface CopyFileConfig {
|
|
@@ -37,7 +37,7 @@ declare module 'wxt' {
|
|
|
37
37
|
turbo: TurboModuleOptions;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
declare const _default: wxt.WxtModule<TurboModuleOptions>;
|
|
40
|
+
declare const _default: _$wxt.WxtModule<TurboModuleOptions>;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { CopyFileConfig, TurboModuleOptions, _default as default };
|
|
43
43
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import * as wxt from "wxt";
|
|
1
|
+
import * as _$wxt from "wxt";
|
|
2
2
|
|
|
3
3
|
//#region src/index.d.ts
|
|
4
4
|
interface CopyFileConfig {
|
|
@@ -37,7 +37,7 @@ declare module 'wxt' {
|
|
|
37
37
|
turbo: TurboModuleOptions;
|
|
38
38
|
}
|
|
39
39
|
}
|
|
40
|
-
declare const _default: wxt.WxtModule<TurboModuleOptions>;
|
|
40
|
+
declare const _default: _$wxt.WxtModule<TurboModuleOptions>;
|
|
41
41
|
//#endregion
|
|
42
42
|
export { CopyFileConfig, TurboModuleOptions, _default as default };
|
|
43
43
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.mjs
CHANGED
|
@@ -3,7 +3,6 @@ import { basename, join, resolve } from "node:path";
|
|
|
3
3
|
import isPathInside from "is-path-inside";
|
|
4
4
|
import { x } from "tinyexec";
|
|
5
5
|
import { defineWxtModule } from "wxt/modules";
|
|
6
|
-
|
|
7
6
|
//#region src/index.ts
|
|
8
7
|
const LOGGER_PREFIX = "`[wxt-turbo]`";
|
|
9
8
|
var src_default = defineWxtModule({
|
|
@@ -68,7 +67,7 @@ async function clearZipSourcesRoot(wxt) {
|
|
|
68
67
|
force: true
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
|
-
|
|
72
70
|
//#endregion
|
|
73
71
|
export { src_default as default };
|
|
72
|
+
|
|
74
73
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","names":["fsConstants"],"sources":["../src/index.ts"],"sourcesContent":["import { constants as fsConstants, copyFile, rm } from 'node:fs/promises';\nimport { basename, join, resolve } from 'node:path';\n\nimport isPathInside from 'is-path-inside';\nimport { x } from 'tinyexec';\nimport type { Wxt } from 'wxt';\nimport { defineWxtModule } from 'wxt/modules';\n\nexport interface CopyFileConfig {\n /**\n * Source path relative to the project root or absolute path.\n */\n from: string;\n /**\n * Destination path relative to the sources zip root or absolute path.\n */\n to: string;\n}\n\nexport interface TurboModuleOptions {\n /**\n * The package name of the project to generate sources for. This needs to match the package name in the `package.json` of the project.\n */\n packageName: string;\n /**\n * Optional list of files to copy into the sources zip.\n *\n * If a string is provided, it will be copied to the zip sources at the root path.\n *\n * @example\n * [{ from: 'README.md', to: 'README.md' }, 'README.md']\n */\n copyFiles?: (CopyFileConfig | string)[];\n /**\n * Whether to clear the zip sources root directory after the zip file is created.\n *\n * @default true\n */\n cleanup?: boolean;\n}\n\ndeclare module 'wxt' {\n export interface InlineConfig {\n turbo: TurboModuleOptions;\n }\n}\n\nconst LOGGER_PREFIX = '`[wxt-turbo]`';\n\nexport default defineWxtModule<TurboModuleOptions>({\n name: 'wxt-turbo',\n configKey: 'turbo',\n async setup(wxt, options) {\n const packageName = options?.packageName;\n if (!packageName) {\n throw new Error('packageName is required');\n }\n\n // check whether turborepo is installed\n try {\n if ((await x('turbo', ['--version'])).exitCode !== 0) {\n throw new Error(`${LOGGER_PREFIX} Command failed: \\`turbo --version\\``);\n }\n wxt.logger.info(LOGGER_PREFIX, 'Turborepo detected.');\n } catch (error) {\n // https://github.com/nodejs/node/issues/46869\n if (\n error instanceof Error &&\n 'code' in error &&\n typeof error.code === 'string' &&\n error.code === 'ENOENT'\n ) {\n wxt.logger.warn(LOGGER_PREFIX, 'Turborepo is not installed');\n return;\n }\n throw error;\n }\n\n wxt.hook('config:resolved', (wxt) => {\n if (wxt.config.zip.sourcesRoot === wxt.config.root) {\n wxt.config.zip.sourcesRoot = join(\n wxt.config.outBaseDir,\n `${basename(wxt.config.outDir)}-sources`,\n );\n }\n });\n\n wxt.hook('zip:sources:start', async (wxt) => {\n await clearZipSourcesRoot(wxt);\n\n const { sourcesRoot } = wxt.config.zip;\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n const proc = x('turbo', [\n 'prune',\n packageName,\n '--out-dir',\n absoluteSourcesRoot,\n ]);\n proc.process?.stdout?.on('data', (data: Buffer) => {\n wxt.logger.debug(LOGGER_PREFIX, data.toString().trimEnd());\n });\n const res = await proc;\n if (res.exitCode !== 0) {\n throw new Error(res.stderr);\n }\n\n if (options.copyFiles) {\n for (const fileInfo of options.copyFiles) {\n const { absoluteFromPath, absoluteToPath } = ((\n fileInfo: CopyFileConfig | string,\n ) => {\n if (typeof fileInfo === 'string') {\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo),\n absoluteToPath: resolve(\n absoluteSourcesRoot,\n basename(fileInfo),\n ),\n };\n }\n return {\n absoluteFromPath: resolve(wxt.config.root, fileInfo.from),\n absoluteToPath: resolve(absoluteSourcesRoot, fileInfo.to),\n };\n })(fileInfo);\n await copyFile(\n absoluteFromPath,\n absoluteToPath,\n // fail if destination file already exists\n fsConstants.COPYFILE_EXCL,\n );\n }\n }\n });\n\n wxt.hook('zip:sources:done', async (wxt) => {\n if (options.cleanup ?? true) {\n await clearZipSourcesRoot(wxt);\n }\n });\n },\n});\n\nasync function clearZipSourcesRoot(wxt: Wxt) {\n const { sourcesRoot } = wxt.config.zip;\n\n // Safety check: ensure sources root is under .output/\n const absoluteSourcesRoot = resolve(wxt.config.root, sourcesRoot);\n if (!isPathInside(absoluteSourcesRoot, wxt.config.outBaseDir)) {\n throw new Error(\n `${LOGGER_PREFIX} Sources root config must be in .output/ directory. Received: ${absoluteSourcesRoot}`,\n );\n }\n\n await rm(absoluteSourcesRoot, { recursive: true, force: true });\n}\n"],"mappings":";;;;;;AA+CA,MAAM,gBAAgB;AAEtB,IAAA,cAAe,gBAAoC;CACjD,MAAM;CACN,WAAW;CACX,MAAM,MAAM,KAAK,SAAS;EACxB,MAAM,cAAc,SAAS;AAC7B,MAAI,CAAC,YACH,OAAM,IAAI,MAAM,0BAA0B;AAI5C,MAAI;AACF,QAAK,MAAM,EAAE,SAAS,CAAC,YAAY,CAAC,EAAE,aAAa,EACjD,OAAM,IAAI,MAAM,GAAG,cAAc,sCAAsC;AAEzE,OAAI,OAAO,KAAK,eAAe,sBAAsB;WAC9C,OAAO;AAEd,OACE,iBAAiB,SACjB,UAAU,SACV,OAAO,MAAM,SAAS,YACtB,MAAM,SAAS,UACf;AACA,QAAI,OAAO,KAAK,eAAe,6BAA6B;AAC5D;;AAEF,SAAM;;AAGR,MAAI,KAAK,oBAAoB,QAAQ;AACnC,OAAI,IAAI,OAAO,IAAI,gBAAgB,IAAI,OAAO,KAC5C,KAAI,OAAO,IAAI,cAAc,KAC3B,IAAI,OAAO,YACX,GAAG,SAAS,IAAI,OAAO,OAAO,CAAC,UAChC;IAEH;AAEF,MAAI,KAAK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
|
|
1
1
|
{
|
|
2
2
|
"name": "wxt-turbo",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "WXT module for Turborepo integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"wxt",
|
|
@@ -36,23 +36,23 @@
|
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"is-path-inside": "^4.0.0",
|
|
39
|
-
"tinyexec": "^1.0.
|
|
39
|
+
"tinyexec": "^1.0.4"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
|
-
"@stzhu/eslint-config": "^0.
|
|
43
|
-
"@stzhu/tsconfig": "^0.
|
|
44
|
-
"@types/node": "^25.
|
|
42
|
+
"@stzhu/eslint-config": "^0.11.0",
|
|
43
|
+
"@stzhu/tsconfig": "^0.5.0",
|
|
44
|
+
"@types/node": "^25.5.2",
|
|
45
45
|
"eslint": "^9.39.2",
|
|
46
46
|
"prettier": "^3.8.1",
|
|
47
|
-
"prettier-plugin-packagejson": "^3.0.
|
|
48
|
-
"tsdown": "^0.
|
|
49
|
-
"typescript": "^
|
|
47
|
+
"prettier-plugin-packagejson": "^3.0.2",
|
|
48
|
+
"tsdown": "^0.21.7",
|
|
49
|
+
"typescript": "^6.0.2"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
|
52
52
|
"wxt": "^0.20.0"
|
|
53
53
|
},
|
|
54
|
-
"packageManager": "pnpm@10.
|
|
54
|
+
"packageManager": "pnpm@10.33.0",
|
|
55
55
|
"engines": {
|
|
56
|
-
"node": ">=
|
|
56
|
+
"node": ">=24"
|
|
57
57
|
}
|
|
58
58
|
}
|