From a1a413139d0bfdc8ac9513a5a42b8e0f2adcc8fc Mon Sep 17 00:00:00 2001 From: shulan Date: Tue, 24 Sep 2024 18:11:55 +0800 Subject: [PATCH] fix: support script for cjs (#40) * fix: support script for cjs * fix: socket can not fully transfer data when the flow is too large * fix: build release --- .changeset/fuzzy-crabs-warn.md | 9 + .editorconfig | 2 +- README.md | 94 ++------ docs/flags.md | 73 ++++++ package.json | 6 +- packages/core/farm.config.cjs.ts | 21 ++ packages/core/package.json | 8 +- .../core/src/config/normalize/find-entry.ts | 10 +- packages/core/src/config/normalize/index.ts | 12 +- packages/core/src/core/ipc/client.ts | 23 +- packages/core/src/core/ipc/server.ts | 3 + packages/core/src/core/ipc/service.ts | 13 +- packages/core/src/index.ts | 12 +- packages/core/src/node/cjs/vm.ts | 224 ++++++++++++++++++ packages/core/src/node/esm/register.ts | 1 + packages/core/src/plugins/auto-execute.ts | 32 ++- packages/core/src/types/options.ts | 2 +- playground/package.json | 4 +- pnpm-lock.yaml | 170 +++++++++---- pnpm-workspace.yaml | 4 + 20 files changed, 555 insertions(+), 168 deletions(-) create mode 100644 .changeset/fuzzy-crabs-warn.md create mode 100644 docs/flags.md create mode 100644 packages/core/farm.config.cjs.ts create mode 100644 packages/core/src/node/cjs/vm.ts diff --git a/.changeset/fuzzy-crabs-warn.md b/.changeset/fuzzy-crabs-warn.md new file mode 100644 index 0000000..5470506 --- /dev/null +++ b/.changeset/fuzzy-crabs-warn.md @@ -0,0 +1,9 @@ +--- +'farmup': patch +--- + +- support script for cjs +- support shebang for file +- fix entry clear failed +- fix can't print address when start html +- bump core version diff --git a/.editorconfig b/.editorconfig index 60f0f72..7308afa 100644 --- a/.editorconfig +++ b/.editorconfig @@ -2,5 +2,5 @@ indent_size = 4 indent_style = space -[*.{md,json}] +[*.{md,json,yaml}] indent_size = 2 diff --git a/README.md b/README.md index 366ea30..b24f01b 100644 --- a/README.md +++ b/README.md @@ -51,82 +51,18 @@ farmup build index.ts --no-exec ## roadmap -- support more entry file -- more cli options - - sourcemap - - ignore some watch file -- execute without output file - -## options - -### exec - -- `alias`: e - -can custom exec, select the exec method by default through the suffix of the file - -- html use server star -- ts\js use node - -```shell -farmup index.ts -e node - -farmup index.ts -e cat -``` - -### format - -- option: `cjs` | `esm` - -```shell -farmup --format cjs index.ts -``` - -### minify - -```shell -farmup --minify index.ts -``` - -### config - -custom specify farm config, for more, see [farm config](https://www.farmfe.org/docs/config/configuring-farm) - -by default, it automatically finds the configuration - -if you not use local config, use `--no-config` option - -### target - -- `option`: `node`、`browser`, more see [targetEnv](https://www.farmfe.org/docs/config/compilation-options#outputtargetenv) - -define your production environment - -### watch - -- `alias`: `w` - -add extra watch files, support [glob](https://www.npmjs.com/package/glob) pattern - -### external - -set external package or path - -### autoExternal - -- `default`: `true` - -in your code, if not find `package` or `source`, set external - -### sourcemap - -- `default`: `undefined` -- option: `boolean` | `'inline'` | `'all'` | `'all-inline'` - -generate sourcemap - -### no-experience-esm - -- option: `boolean` - -disable exec esm without output to filesystem +- [ ] support more entry file (without execute) +- [ ] define multiple configurations within a single configuration file. +- [ ] provide more convenient configuration for package library. +- [ ] Integration of some built-in plugins (e.g: `dts`) +- [ ] more cli options + - [ ] sourcemap + - [ ] ignore some watch file +- [ ] support monorepo? +- [x] execute without output file + - [x] cjs + - [x] esm + +## option + +see [here](./docs/flags.md) diff --git a/docs/flags.md b/docs/flags.md new file mode 100644 index 0000000..e47e407 --- /dev/null +++ b/docs/flags.md @@ -0,0 +1,73 @@ +## options + +### exec + +- `alias`: e + +can custom exec, select the exec method by default through the suffix of the file + +- html use server star +- ts\js use node + +```shell +farmup index.ts -e node + +farmup index.ts -e cat +``` + +### format + +- option: `cjs` | `esm` + +```shell +farmup --format cjs index.ts +``` + +### minify + +```shell +farmup --minify index.ts +``` + +### config + +custom specify farm config, for more, see [farm config](https://www.farmfe.org/docs/config/configuring-farm) + +by default, it automatically finds the configuration + +if you not use local config, use `--no-config` option + +### target + +- `option`: `node`、`browser`, more see [targetEnv](https://www.farmfe.org/docs/config/compilation-options#outputtargetenv) + +define your production environment + +### watch + +- `alias`: `w` + +add extra watch files, support [glob](https://www.npmjs.com/package/glob) pattern + +### external + +set external package or path + +### autoExternal + +- `default`: `true` + +in your code, if not find `package` or `source`, set external + +### sourcemap + +- `default`: `undefined` +- option: `boolean` | `'inline'` | `'all'` | `'all-inline'` + +generate sourcemap + +### no-experience-script + +- option: `boolean` + +disable exec esm without output to filesystem diff --git a/package.json b/package.json index 943bba0..55eae2f 100644 --- a/package.json +++ b/package.json @@ -5,6 +5,7 @@ "private": true, "type": "module", "scripts": { + "initial": "pnpm --filter './packages/core' run build", "dev": "pnpm --filter './packages/core' run dev", "release": "pnpm --filter './packages/*' run build && changeset publish", "ready": "farmup ./scripts/ready.ts -o ./dist/ready --no-config" @@ -20,8 +21,9 @@ }, "devDependencies": { "@biomejs/biome": "^1.7.3", + "@changesets/cli": "^2.27.3", "cspell": "^8.8.3", "execa": "^8.0.1", - "@changesets/cli": "^2.27.3" + "rimraf": "^6.0.1" } -} +} \ No newline at end of file diff --git a/packages/core/farm.config.cjs.ts b/packages/core/farm.config.cjs.ts new file mode 100644 index 0000000..8ca2c64 --- /dev/null +++ b/packages/core/farm.config.cjs.ts @@ -0,0 +1,21 @@ +import { defineConfig } from '@farmfe/core'; + +export default defineConfig({ + compilation: { + presetEnv: false, + input: { + vm: './src/node/cjs/vm.ts', + }, + output: { + targetEnv: 'node', + format: 'cjs', + entryFilename: '[entryName].cjs', + clean: false, + }, + lazyCompilation: false, + persistentCache: false, + external: ['^@farmfe/core$'], + minify: false, + treeShaking: true, + }, +}); diff --git a/packages/core/package.json b/packages/core/package.json index f286cec..17689de 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -9,8 +9,8 @@ "access": "public" }, "scripts": { - "dev": "farm watch", - "build": "farm build", + "dev": "farm watch & farm watch --config farm.config.cjs.ts", + "build": "rimraf ./dist && farm build && farm build --config farm.config.cjs.ts", "preview": "farm preview", "clean": "farm clean", "farmup": "node ./bin/farmup.js --no-exec -w", @@ -18,7 +18,7 @@ }, "bin": "./bin/farmup.js", "devDependencies": { - "@farmfe/cli": "^1.0.4", + "@farmfe/cli": "catalog:", "@types/fs-extra": "^11.0.4", "@types/lodash-es": "^4.17.12", "@types/node": "^20.12.7", @@ -64,7 +64,7 @@ "email": "sshuang141@163.com" }, "dependencies": { - "@farmfe/core": "^1.3.16", + "@farmfe/core": "catalog:", "tmp": "^0.2.3" } } \ No newline at end of file diff --git a/packages/core/src/config/normalize/find-entry.ts b/packages/core/src/config/normalize/find-entry.ts index bd84961..f8cba1e 100644 --- a/packages/core/src/config/normalize/find-entry.ts +++ b/packages/core/src/config/normalize/find-entry.ts @@ -161,7 +161,7 @@ const formatMapExt: Record, string> = { esm: 'mjs', }; -export function pinOutputEntryFilename(options: ResolvedCommonOptions) { +export function pinOutputEntryFilename(options: ResolvedCommonOptions, config: UserConfig) { if (options.noExecute) return; const executeMode = options.execute.type; @@ -171,12 +171,16 @@ export function pinOutputEntryFilename(options: ResolvedCommonOptions) { } if (executeMode === ExecuteMode.Node && !options.noExecute) { + const originInput = config.compilation?.input ?? {}; options.entry = Object.entries(options.entry).reduce( (res, [key, val]) => { - if (val) res[`${key}.${formatMapExt[options.format ?? 'cjs']}`] = val; + if (val) { + if (originInput[key]) res[key] = undefined; + res[`${key}.${formatMapExt[options.format ?? 'cjs']}`] = val; + } return res; }, - {} as Record, + {} as Record, ); options.outputEntry = { diff --git a/packages/core/src/config/normalize/index.ts b/packages/core/src/config/normalize/index.ts index 6421318..369cb6d 100644 --- a/packages/core/src/config/normalize/index.ts +++ b/packages/core/src/config/normalize/index.ts @@ -77,9 +77,12 @@ function normalizedExecuted(commonOption: CommonOptions, options: ResolvedCommon const execute = options.execute; - if (execute.type === ExecuteMode.Node && commonOption.experienceEsm) { + if (execute.type === ExecuteMode.Node && commonOption.experienceScript) { if (options.format === 'esm' && !execute.args.includes('--import')) { execute.args.push('--import', path.join(import.meta.dirname, './import_register.js')); + } else if (options.format === 'cjs' && !execute.args.includes('--experimental-vm-modules')) { + // support dynamic import in vm + execute.args.push('--experimental-vm-modules'); } } } @@ -125,7 +128,6 @@ export function normalizedTargetEnv( options: ResolvedCommonOptions, logger: Logger, ) { - config.compilation?.output?.targetEnv; if (commonOptions.target) { if (!invalidTargetEnv.includes(commonOptions.target)) { logger.error(`target ${commonOptions.target} is invalid`); @@ -176,7 +178,6 @@ async function normalizedSimpleConfig( logger: Logger, ) { const inputs = await tryFindEntryFromUserConfig(logger, config, commonOptions); - options.entry = inputs; config.compilation ??= {}; @@ -207,7 +208,7 @@ async function normalizedSimpleConfig( normalizedExecuted(commonOptions, options); - pinOutputEntryFilename(options); + pinOutputEntryFilename(options, config); } function withServerOrWatch(userConfig: UserConfig, resolvedOption: ResolvedCommonOptions): UserConfig { @@ -266,6 +267,9 @@ export class NormalizeOption { ...(this.options.outputEntry ? { entryFilename: this.options.outputEntry.name } : {}), path: this.options.outputDir, }, + // TODO: fix in script mode, resources are now only synchronized once at startup + // and lazyCompilation cannot obtain the latest resources in a timely manner. + ...(this.options.execute.type === ExecuteMode.Node ? { lazyCompilation: true } : {}), ...pick(this.options, 'minify', 'sourcemap', 'external'), }, }, diff --git a/packages/core/src/core/ipc/client.ts b/packages/core/src/core/ipc/client.ts index c188a9b..081cc64 100644 --- a/packages/core/src/core/ipc/client.ts +++ b/packages/core/src/core/ipc/client.ts @@ -9,15 +9,26 @@ export class IpcClient { start(socketPath: string) { const client = net.createConnection(socketPath); - client.on('data', (data) => { - this.events.emit('data', data); + let data = Buffer.alloc(0); + + client.on('end', () => { + this.events.emit('data', data.toString('utf-8')); + data = Buffer.alloc(0); + }); + + client.on('data', (buffer) => { + data = Buffer.concat([new Uint8Array(data), new Uint8Array(buffer)], data.byteLength + buffer.byteLength); }); this.client = client; } - send(data: S) { - this.client.write(JSON.stringify(data)); + async send(data: S) { + return new Promise((resolve) => { + this.client.end(JSON.stringify(data), () => { + resolve(); + }); + }); } onMessage(callback: (data: R) => void) { @@ -25,4 +36,8 @@ export class IpcClient { callback(JSON.parse(data.toString())); }); } + + close() { + this.client.end(); + } } diff --git a/packages/core/src/core/ipc/server.ts b/packages/core/src/core/ipc/server.ts index c1748ca..d3aec89 100644 --- a/packages/core/src/core/ipc/server.ts +++ b/packages/core/src/core/ipc/server.ts @@ -57,6 +57,9 @@ export class IpcServer { close() { this._server.close(); + for (const socket of this.sockets) { + socket.close(); + } this.sockets.clear(); } diff --git a/packages/core/src/core/ipc/service.ts b/packages/core/src/core/ipc/service.ts index a8e5653..c624187 100644 --- a/packages/core/src/core/ipc/service.ts +++ b/packages/core/src/core/ipc/service.ts @@ -5,11 +5,18 @@ export class Service { constructor(private _socket: Socket) {} - send(data: S) { + send(data: S): Promise { if (this._socket.closed) { - return; + return Promise.resolve(); } - this._socket.write(JSON.stringify(data)); + + return new Promise((resolve) => { + this._socket.end(JSON.stringify(data), () => { + resolve(); + }); + + this._socket.on('end', () => resolve()); + }); } onMessage(callback: (data: R) => void) { diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 55457a3..e206d3f 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -34,18 +34,19 @@ function buildPluginsByCommonOption(options: CommonOptions): JsPlugin[] { type InlineConfig = FarmCLIOptions & UserConfig; -function createInlineConfig(options: CommonOptions): InlineConfig { +function createInlineConfig(options: CommonOptions, disableFarmLogger = true): InlineConfig { + const log = disableFarmLogger ? new NoopLogger() : logger; return { root: options.root, configPath: options.config, plugins: buildPluginsByCommonOption(options), - logger: new NoopLogger(), + logger: log, }; } async function autoStart(options: CommonOptions) { const preNormalizeOption = await NormalizeOption.fromCommonOption(options, new NoopLogger()); - const inlineConfig = createInlineConfig(options); + const inlineConfig = createInlineConfig(options, preNormalizeOption.options.execute.type !== ExecuteMode.Browser); switch (preNormalizeOption.options.execute.type) { case ExecuteMode.Browser: return farmStart(inlineConfig); @@ -88,7 +89,7 @@ cli.option('-w, --watch [...files]', 'watch files', { default: false }) .option('--external [...external]', 'external') .option('--no-auto-external', 'if not found module, auto as external', { default: true }) .option('--sourcemap [sourcemap]', 'generate sourcemap or not') - .option('--no-experience-esm', 'disable using experience esm execute', { default: true }) + .option('--no-experience-script', 'disable using experience esm execute', { default: true }) .option( '--target [target]', "target for output, default is node, support 'browser'、'node'、'node16'、'node-legacy'、'node-next'、'browser-legacy'、'browser-es2015'、'browser-es2017'、'browser-esnext'", @@ -126,7 +127,7 @@ async function commonOptionsFromArgs(args: Record): Promise { start({ entry: Array.isArray(entry) ? entry : [entry].filter(Boolean), diff --git a/packages/core/src/node/cjs/vm.ts b/packages/core/src/node/cjs/vm.ts new file mode 100644 index 0000000..4214229 --- /dev/null +++ b/packages/core/src/node/cjs/vm.ts @@ -0,0 +1,224 @@ +import vm, { SyntheticModule } from 'node:vm'; +import m from 'node:module'; +import path from 'node:path'; +import type { ResourceData } from '../esm/interface'; +import type Module from 'node:module'; +import { IpcClient } from '../../core/ipc/client'; + +const ipc = new IpcClient(); + +const FARM_ESM_RESOURCE_MOCK_PORT = process.env.FARM_ESM_RESOURCE_MOCK_PORT; +let resourcesData: ResourceData; + +ipc.onMessage((data) => { + resourcesData = data; + + for (const key in resourcesData.resources) { + if (path.isAbsolute(key)) continue; + const v = resourcesData.resources[key]; + delete resourcesData.resources[key]; + const filename = path.join(process.cwd(), resourcesData.outputDir, key); + if (key === resourcesData.entry) { + resourcesData.entry = filename; + } + resourcesData.resources[filename] = v; + } + + start(); + + ipc.close(); +}); + +ipc.start(FARM_ESM_RESOURCE_MOCK_PORT!); + +function createVmContextByModule(newM: Module) { + return vm.createContext( + { + __farm__filename: newM.filename, + __farm__dirname: path.dirname(newM.filename), + __farm_m: newM, + }, + {}, + ); +} + +function tryExt(filename: string, obj: Record) { + for (const ext of ['', '.js', '.cjs']) { + if (obj[filename + ext]) return filename + ext; + } +} + +const nativeRequire = require; + +const createRequire = (importerModule: Module | undefined) => { + function tryRequireModule(id: string): { module: Module } | undefined { + const filename = getSourceByImport(id, importerModule?.filename); + + const tryExtFromCacheFilename = tryExt(filename, nativeRequire.cache); + + if (tryExtFromCacheFilename) { + return { module: nativeRequire.cache[tryExtFromCacheFilename]! }; + } + + const tryExtFromResourceFilename = tryExt(filename, resourcesData.resources); + + if (tryExtFromResourceFilename) { + const importer = importerModule?.filename; + + const { module: m } = runModuleByFilename(tryExtFromResourceFilename, importer); + + return { module: m }; + } + } + const __require = function require(id: string) { + const v = tryRequireModule(id); + if (v) { + return v.module.exports; + } + return nativeRequire(id); + } as NodeRequire; + + for (const key of ['cache', 'resolve', 'extensions'] as (keyof NodeRequire)[]) { + // @ts-ignore + __require[key] = nativeRequire[key]; + } + + return { __require, tryRequireModule }; +}; + +function createContext(_ctx: vm.Context, require: NodeRequire) { + return new Proxy(_ctx, { + get(target, prop) { + if (prop in target) { + // @ts-ignore + return target[prop]; + } + if (prop === 'require') { + return require; + } + if (globalThis && prop in globalThis) { + // @ts-ignore + return globalThis[prop]; + } + }, + }); +} + +function executeCode(code: string, ctx: ModuleContext) { + vm.runInNewContext( + ` + (function(exports, require, module, __filename, __dirname) { + ${code} +})(__farm_m.exports, require, __farm_m, __farm__filename, __farm__dirname);`.trim(), + ctx.context, + { + // @ts-ignore + async importModuleDynamically(specifier, script, importAttributes) { + let exports: Record | undefined; + if ( + m.builtinModules.includes(specifier) || + (specifier.startsWith('node:') && m.builtinModules.includes(specifier.slice(5))) + ) { + exports = require(specifier); + } + const filename = getSourceByImport(specifier, ctx.filename); + if (resourcesData.resources[filename]) { + const res = runModuleByFilename(filename, ctx.filename); + exports = res.module.exports; + } + + if (exports) { + const m = new SyntheticModule(Object.keys(exports), () => {}); + + // @ts-ignore + await m.link(() => {}); + + for (const key of Object.keys(exports)) { + const val = exports[key]; + m.setExport(key, val); + } + + await m.evaluate(); + + return m; + } + }, + }, + ); +} + +function nativeModuleCache(m: Module, r: NodeRequire, importer?: string) { + if (importer) { + r.cache[importer]?.children.push(m); + } +} + +function createModule(source: string, importer?: string) { + const filename = getSourceByImport(source, importer); + + const newM = new m.Module(filename, tryGetModuleByFilename(importer)); + newM.filename = filename; + + return newM; +} + +function getSourceByImport(filename: string, importer?: string) { + return path.isAbsolute(filename) + ? filename + : importer + ? path.join(path.dirname(importer), filename) + : path.join(process.cwd(), resourcesData.outputDir, filename); +} + +function tryGetModuleByFilename(filename?: string): Module | undefined { + if (filename && nativeRequire.cache[filename]) { + return nativeRequire.cache[filename]; + } +} + +interface ModuleContext { + filename: string; + module: Module; + require: NodeRequire; + context: vm.Context; + tryRequireModule: (id: string) => { module: Module } | undefined; +} + +function runModuleByFilename(_filename: string, importer?: string): ModuleContext { + const filename = getSourceByImport(_filename, importer); + + const m = createModule(filename, importer); + + const r = createRequire(tryGetModuleByFilename(importer)); + + const ctx = createContext(createVmContextByModule(m), r.__require); + + const tryExtFilenameFromResource = tryExt(filename, resourcesData.resources); + + if (!tryExtFilenameFromResource) { + throw new Error(`cannot found module: ${_filename} in ${importer}`); + } + + const moduleContext = { + filename: tryExtFilenameFromResource, + module: m, + require: r.__require, + context: ctx, + tryRequireModule: r.tryRequireModule, + }; + const code = resourcesData.resources[tryExtFilenameFromResource]; + + r.__require.cache[tryExtFilenameFromResource] = m; + + executeCode(code, moduleContext); + + m.loaded = true; + + nativeModuleCache(m, r.__require, importer); + + return moduleContext; +} + +function start() { + runModuleByFilename(resourcesData.entry); +} diff --git a/packages/core/src/node/esm/register.ts b/packages/core/src/node/esm/register.ts index 911d5ab..dff8887 100644 --- a/packages/core/src/node/esm/register.ts +++ b/packages/core/src/node/esm/register.ts @@ -19,6 +19,7 @@ async function run() { ipc.onMessage((data) => { lastMessage = data; resolve(undefined); + ipc.close(); }); }); } diff --git a/packages/core/src/plugins/auto-execute.ts b/packages/core/src/plugins/auto-execute.ts index 1af9575..f2b0661 100644 --- a/packages/core/src/plugins/auto-execute.ts +++ b/packages/core/src/plugins/auto-execute.ts @@ -7,6 +7,7 @@ import { Executer } from '../core/executer'; import { ProxyCompiler } from '../core/proxyCompiler'; import { IpcServer } from '../core/ipc/server'; import type { ResourceData } from '../node/esm/interface'; +import { fileURLToPath } from 'node:url'; export { NormalizeOption, Executer }; @@ -49,19 +50,20 @@ export default function autoExecute(options: CommonOptions = {}, logger = defaul const nameWithoutExt = path.parse(resourceOutputEntry).name; - if ( - normalizeOption.options.execute.type === ExecuteMode.Node && - normalizeOption.options.format === 'esm' && - options.experienceEsm - ) { + if (normalizeOption.options.execute.type === ExecuteMode.Node && options.experienceScript) { if (!ipcServer) { ipcServer = new IpcServer(); await ipcServer.start(); } if (ipcServer) { - ipcServer.onConnection((service) => { - service.send({ + ipcServer.onConnection(async (service) => { + service.onClose(() => { + ipcServer?.close(); + ipcServer = null; + }); + + await service.send({ entry: resourceOutputEntry, name: '', outputDir: outputDir ?? './dist', @@ -77,9 +79,17 @@ export default function autoExecute(options: CommonOptions = {}, logger = defaul }); } - executer.execute( + const getExecutePath = (): string => { + if (normalizeOption.options.format === 'cjs') { + return path.join(fileURLToPath(path.dirname(import.meta.url)), './vm.cjs'); + } + // mock path, after replace as entry - path.join(options.root!, options.outputDir ?? './dist', resourceOutputEntry), + return path.join(options.root!, options.outputDir ?? './dist', resourceOutputEntry); + }; + + executer.execute( + getExecutePath(), nameWithoutExt, new Logger({ name: `${name}:${nameWithoutExt}`, @@ -90,6 +100,7 @@ export default function autoExecute(options: CommonOptions = {}, logger = defaul }, }, ); + return; } @@ -123,8 +134,7 @@ export default function autoExecute(options: CommonOptions = {}, logger = defaul if ( !normalizeOption.options.noExecute && normalizeOption.options.execute.type === ExecuteMode.Node && - normalizeOption.options.format === 'esm' && - options.experienceEsm + options.experienceScript ) { proxyCompiler.disableEmit(); } diff --git a/packages/core/src/types/options.ts b/packages/core/src/types/options.ts index a9a2fc7..2978d13 100644 --- a/packages/core/src/types/options.ts +++ b/packages/core/src/types/options.ts @@ -71,7 +71,7 @@ export interface CommonOptions { sourcemap?: SourceMap; /** disable using experience esm execute */ - experienceEsm?: boolean + experienceScript?: boolean } export interface ResolvedCommonOptions { diff --git a/playground/package.json b/playground/package.json index 0cd67c9..2bab165 100644 --- a/playground/package.json +++ b/playground/package.json @@ -15,7 +15,7 @@ "author": "", "license": "ISC", "dependencies": { - "@farmfe/cli": "^1.0.4", - "@farmfe/core": "^1.3.16" + "@farmfe/cli": "catalog:", + "@farmfe/core": "catalog:" } } \ No newline at end of file diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4336baf..44a6469 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -4,6 +4,15 @@ settings: autoInstallPeers: true excludeLinksFromLockfile: false +catalogs: + default: + '@farmfe/cli': + specifier: ^1.0.4 + version: 1.0.4 + '@farmfe/core': + specifier: ^1.3.22 + version: 1.3.22 + importers: .: @@ -24,18 +33,21 @@ importers: execa: specifier: ^8.0.1 version: 8.0.1 + rimraf: + specifier: ^6.0.1 + version: 6.0.1 packages/core: dependencies: '@farmfe/core': - specifier: ^1.3.16 - version: 1.3.16 + specifier: 'catalog:' + version: 1.3.22 tmp: specifier: ^0.2.3 version: 0.2.3 devDependencies: '@farmfe/cli': - specifier: ^1.0.4 + specifier: 'catalog:' version: 1.0.4 '@types/fs-extra': specifier: ^11.0.4 @@ -71,11 +83,11 @@ importers: playground: dependencies: '@farmfe/cli': - specifier: ^1.0.4 + specifier: 'catalog:' version: 1.0.4 '@farmfe/core': - specifier: ^1.3.16 - version: 1.3.16 + specifier: 'catalog:' + version: 1.3.22 devDependencies: farmup: specifier: workspace:* @@ -403,62 +415,62 @@ packages: engines: {node: '>= 16'} hasBin: true - '@farmfe/core-darwin-arm64@1.3.16': - resolution: {integrity: sha512-Q0xpDBphj5/lmKfe/9uQaUloCvCemY8HLaAjs/y2y9GSO+4xin1+hW8snHlWyFADbpOxH492G6jSc2SJNeVe2Q==} + '@farmfe/core-darwin-arm64@1.3.22': + resolution: {integrity: sha512-g31Iu/n1s2aPK33gIGwJ8R0u/U7oK6roPD5A3/osEelqRIwRD+Rkxja7dHvfoloI6W8m1hajoUAH7KNLCj83RQ==} engines: {node: '>= 10'} cpu: [arm64] os: [darwin] - '@farmfe/core-darwin-x64@1.3.16': - resolution: {integrity: sha512-VdPbDCjdTXIkNbi1xHNYBALFddqqO3qZQM5WXc775Zw6h2h/mSovsdsWrnyIxnA/Kh/uSJiade78Blng2Dr9og==} + '@farmfe/core-darwin-x64@1.3.22': + resolution: {integrity: sha512-KoVptpd16qH9k2b5w9RZdWg7kD1wvmXPqS6dQfl3s8ysfGMkVROhwBbVOqefsTbcCRX9XJ57jNq7J3z/cS5GdQ==} engines: {node: '>= 10'} cpu: [x64] os: [darwin] - '@farmfe/core-linux-arm64-gnu@1.3.16': - resolution: {integrity: sha512-9Cs7oE3YJcnpe0fbFX/PKXHtgTW7W04tkj1D0j3e2aM5JNOQkHeBVXy81ccA6I2EDD0+66TmViIDJIHQscEbMQ==} + '@farmfe/core-linux-arm64-gnu@1.3.22': + resolution: {integrity: sha512-IZuwqdbiEgO+yjK15u3bp3CNOi5cvxCsYqO1cRokrwJXFfGrEVK5YG4IbM2S9cVpyoNUIT4sPy/M7uF5CAeDLQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@farmfe/core-linux-arm64-musl@1.3.16': - resolution: {integrity: sha512-6jzKIMo1x3ZdVMw2nWlnkoKBAdxwrL+tqPgCJc1vAhlWSxY0q6NZHCKetXbxMWm9DXjPxuocAPVYjm8UZlX00Q==} + '@farmfe/core-linux-arm64-musl@1.3.22': + resolution: {integrity: sha512-PPiUgXirqy/vksJqhgBhiNoSmpgnpxNHfsS4C+NX4Ni+cgTMtF+6KTmyDiYOmQK4BdyqTxDOrJvkMSevb4ZOvQ==} engines: {node: '>= 10'} cpu: [arm64] os: [linux] - '@farmfe/core-linux-x64-gnu@1.3.16': - resolution: {integrity: sha512-gtQz7wlCE5HFi3BfF7EiJeXRHAD8BDx27sHt+Txg/27esDhaAjsPKUltI+bsAqwPwYFIYtyT9kr33p1OYemDfg==} + '@farmfe/core-linux-x64-gnu@1.3.22': + resolution: {integrity: sha512-wfTqmaZymRCU4EutxxjCeH1GhYtBoqpwVeDoZ6KZvOhFtIaGEawav3QASQz1fUCOopuQQBPrPjoabNDwH5eXVQ==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@farmfe/core-linux-x64-musl@1.3.16': - resolution: {integrity: sha512-EUKUdeslQ759dOGS7nJflzfUIoKZCWb1vuOpwRrGHvrVCI0wjwVsi8FKnqEFqoiEZpX6CV86Kxccr3Up8cnElw==} + '@farmfe/core-linux-x64-musl@1.3.22': + resolution: {integrity: sha512-+iaP1N4WxkiJNAeRhCYrQwS6Vz7R47SmYuiVYRFhkke+VNUjSLakx7Z3jpntLFo5WKL4K8i7H0g3z8uyn5sLDw==} engines: {node: '>= 10'} cpu: [x64] os: [linux] - '@farmfe/core-win32-arm64-msvc@1.3.16': - resolution: {integrity: sha512-P6QTB/fCbmpP8QuOJRVKwmNKdopEg1dCcU6BRJD1X9qBoDeyOU1hLUv6a7WVj++qy79PeO4dm1J0qMIEJjcOUw==} + '@farmfe/core-win32-arm64-msvc@1.3.22': + resolution: {integrity: sha512-fy4nhej7hVLkbhL14s0tuVazeS/M2YvqpfaJNyxt6aCxsEL35o+3aeFi+qguWDtLeKApi/zcazoFWMDH/Tj+7w==} engines: {node: '>= 10'} cpu: [arm64] os: [win32] - '@farmfe/core-win32-ia32-msvc@1.3.16': - resolution: {integrity: sha512-KAGuklsZYoKStwB7AuPPM707TNmewLtYwBRvPslEzTMVqI7Z12m3BU59+a+T/hzBmOvqMysBYEoSAbH/r3/8PA==} + '@farmfe/core-win32-ia32-msvc@1.3.22': + resolution: {integrity: sha512-eOg9McdHmrCTqh3UcwOC/rwZna5hZazmTvhcUSci5Yvwj+yBeATB/QRGVLvKOKlnncSgvVqrJcxvTNgOKBvGRg==} engines: {node: '>= 10'} cpu: [ia32] os: [win32] - '@farmfe/core-win32-x64-msvc@1.3.16': - resolution: {integrity: sha512-qggAzgOKx/zU8/KtHrJy4kFyRAftLIMwu/c3xnKsnn/PoEylm3VHWDgl8Elc89Q7blJ2l49xUmQ22CucaMqj5w==} + '@farmfe/core-win32-x64-msvc@1.3.22': + resolution: {integrity: sha512-H8RQsrHP00Rudvo1zYvyoCz/XywGdHdkWPNzVNplID0mBw6eknGsYmwW3YzifWOAMBf50ymhwyvpkCrN1r7wYA==} engines: {node: '>= 10'} cpu: [x64] os: [win32] - '@farmfe/core@1.3.16': - resolution: {integrity: sha512-F0sf8AzqZLQU06q6msgR9Aa49g3YxTm5m8NZlYSm5gOQ6IfVtrQE7L748gTnnDtk6SCKvzk38OyIVxldrUnZ3A==} + '@farmfe/core@1.3.22': + resolution: {integrity: sha512-AI937IKbXEdDxRtJDCc96EgqrKg7O9u7DsCLM+YQoB9a3SbYG+dyidkAQGIYoAEnxmujQUKKhsayn40LU3ePWg==} engines: {node: '>=16.15.1'} '@farmfe/runtime-plugin-hmr@3.5.6': @@ -467,8 +479,8 @@ packages: '@farmfe/runtime-plugin-import-meta@0.2.2': resolution: {integrity: sha512-xrWJOHbmhVJX+a6LtRpv5wvj/uqpPQFZIKeHfT+mqybKRSC9+JxDgOySLzYUbT8beSTtXgcxGXf55EN3Byd0ng==} - '@farmfe/runtime@0.12.3': - resolution: {integrity: sha512-4gpTOWbQ6IpDODCUbm3N7Ulqv6awcE5aQ+kAlxhErz/q5iRFVCT/HyOoUQH3ZhZgPUQ8UYxgABGmjhYFY/ILSA==} + '@farmfe/runtime@0.12.4': + resolution: {integrity: sha512-ePgezICUXffXlf5YBTAcbLK/uG7HypTi5d6Ke78dWV4hlJ7fRU54yJDiOhNN1lonw0SIqhlWAJYE5Jrnc1HS9g==} '@farmfe/utils@0.0.1': resolution: {integrity: sha512-QLbgNrojcvxfumXA/H329XAXhoCahmeSH3JmaiwwJEGS2QAmWfgAJMegjwlt6OmArGVO4gSbJ7Xbmm1idZZs+g==} @@ -1249,6 +1261,11 @@ packages: engines: {node: '>=16 || 14 >=14.18'} hasBin: true + glob@11.0.0: + resolution: {integrity: sha512-9UiX/Bl6J2yaBbxKoEBRm4Cipxgok8kQYcOPEhScPwebu2I0HoQOuYdIO6S3hLuWoZgpDpwQZMzTFxgpkyT76g==} + engines: {node: 20 || >=22} + hasBin: true + global-directory@4.0.1: resolution: {integrity: sha512-wHTUcDUoZ1H5/0iVqEudYW4/kAlN5cZ3j/bXn0Dpbizl9iaUVeWSHqiOjsgk6OW2bkLclbBjzewBz6weQ1zA2Q==} engines: {node: '>=18'} @@ -1543,6 +1560,10 @@ packages: resolution: {integrity: sha512-kWmLKn2tRtfYMF/BakihVVRzBKOxz4gJMiL2Rj91WnAB5TPZumSH99R/Yf1qE1u4uRimvCSJfm6hnxohXeEXjQ==} engines: {node: '>=14'} + jackspeak@4.0.2: + resolution: {integrity: sha512-bZsjR/iRjl1Nk1UkjGpAzLNfQtzuijhn2g+pbZb98HQ1Gk8vM9hfbxeMBP+M2/UUdwj0RqGG3mlvk2MsAqwvEw==} + engines: {node: 20 || >=22} + js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} @@ -1645,6 +1666,10 @@ packages: resolution: {integrity: sha512-9hp3Vp2/hFQUiIwKo8XCeFVnrg8Pk3TYNPIR7tJADKi5YfcF7vEaK7avFHTlSy3kOKYaJQaalfEo6YuXdceBOQ==} engines: {node: 14 || >=16.14} + lru-cache@11.0.1: + resolution: {integrity: sha512-CgeuL5uom6j/ZVrg7G/+1IXqRY8JXX4Hghfy5YE0EhoYQWvndP1kufu58cmZLNIDKnRhZrXfdS9urVWx98AipQ==} + engines: {node: 20 || >=22} + lru-cache@4.1.5: resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} @@ -1695,6 +1720,10 @@ packages: resolution: {integrity: sha512-I9jwMn07Sy/IwOj3zVkVik2JTvgpaykDZEigL6Rx6N9LbMywwUSMtxET+7lVoDLLd3O3IXwJwvuuns8UB/HeAg==} engines: {node: '>=4'} + minimatch@10.0.1: + resolution: {integrity: sha512-ethXTt3SGGR+95gudmqJ1eNhRO7eGEGIgYA9vnPatK4/etz2MEVDno5GMCibdMTuBMyElzIlgxMna3K94XDIDQ==} + engines: {node: 20 || >=22} + minimatch@9.0.4: resolution: {integrity: sha512-KqWh+VchfxcMNRAJjj2tnsSJdNbHsVgnkBhTNrW7AjVo6OvLtxw8zfT9oLw1JSohlFzJ8jCoTgaoXvJ+kHt6fw==} engines: {node: '>=16 || 14 >=14.17'} @@ -1816,6 +1845,9 @@ packages: resolution: {integrity: sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==} engines: {node: '>=6'} + package-json-from-dist@1.0.0: + resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} + parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -1855,6 +1887,10 @@ packages: resolution: {integrity: sha512-Xa4Nw17FS9ApQFJ9umLiJS4orGjm7ZzwUrwamcGQuHSzDyth9boKDaycYdDcZDuqYATXw4HFXgaqWTctW/v1HA==} engines: {node: '>=16 || 14 >=14.18'} + path-scurry@2.0.0: + resolution: {integrity: sha512-ypGJsmGtdXUOeM5u93TyeIEfEhM6s+ljAhrk5vAvSx8uyY/02OvrZnA0YNGUrPXfpJMgI1ODd3nwz8Npx4O4cg==} + engines: {node: 20 || >=22} + path-type@4.0.0: resolution: {integrity: sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw==} engines: {node: '>=8'} @@ -1966,6 +2002,11 @@ packages: resolution: {integrity: sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw==} engines: {iojs: '>=1.0.0', node: '>=0.10.0'} + rimraf@6.0.1: + resolution: {integrity: sha512-9dkvaxAsk/xNXSJzMgFqqMCuFgt2+KsOFek3TMLfo8NCPfWpBmqwyNn5Y+NX56QUYfCtsyhF3ayiboEoUmJk/A==} + engines: {node: 20 || >=22} + hasBin: true + run-applescript@5.0.0: resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==} engines: {node: '>=12'} @@ -2771,36 +2812,36 @@ snapshots: inquirer: 9.2.12 walkdir: 0.4.1 - '@farmfe/core-darwin-arm64@1.3.16': + '@farmfe/core-darwin-arm64@1.3.22': optional: true - '@farmfe/core-darwin-x64@1.3.16': + '@farmfe/core-darwin-x64@1.3.22': optional: true - '@farmfe/core-linux-arm64-gnu@1.3.16': + '@farmfe/core-linux-arm64-gnu@1.3.22': optional: true - '@farmfe/core-linux-arm64-musl@1.3.16': + '@farmfe/core-linux-arm64-musl@1.3.22': optional: true - '@farmfe/core-linux-x64-gnu@1.3.16': + '@farmfe/core-linux-x64-gnu@1.3.22': optional: true - '@farmfe/core-linux-x64-musl@1.3.16': + '@farmfe/core-linux-x64-musl@1.3.22': optional: true - '@farmfe/core-win32-arm64-msvc@1.3.16': + '@farmfe/core-win32-arm64-msvc@1.3.22': optional: true - '@farmfe/core-win32-ia32-msvc@1.3.16': + '@farmfe/core-win32-ia32-msvc@1.3.22': optional: true - '@farmfe/core-win32-x64-msvc@1.3.16': + '@farmfe/core-win32-x64-msvc@1.3.22': optional: true - '@farmfe/core@1.3.16': + '@farmfe/core@1.3.22': dependencies: - '@farmfe/runtime': 0.12.3 + '@farmfe/runtime': 0.12.4 '@farmfe/runtime-plugin-hmr': 3.5.6 '@farmfe/runtime-plugin-import-meta': 0.2.2 '@farmfe/utils': 0.1.0 @@ -2828,15 +2869,15 @@ snapshots: zod: 3.23.8 zod-validation-error: 1.5.0(zod@3.23.8) optionalDependencies: - '@farmfe/core-darwin-arm64': 1.3.16 - '@farmfe/core-darwin-x64': 1.3.16 - '@farmfe/core-linux-arm64-gnu': 1.3.16 - '@farmfe/core-linux-arm64-musl': 1.3.16 - '@farmfe/core-linux-x64-gnu': 1.3.16 - '@farmfe/core-linux-x64-musl': 1.3.16 - '@farmfe/core-win32-arm64-msvc': 1.3.16 - '@farmfe/core-win32-ia32-msvc': 1.3.16 - '@farmfe/core-win32-x64-msvc': 1.3.16 + '@farmfe/core-darwin-arm64': 1.3.22 + '@farmfe/core-darwin-x64': 1.3.22 + '@farmfe/core-linux-arm64-gnu': 1.3.22 + '@farmfe/core-linux-arm64-musl': 1.3.22 + '@farmfe/core-linux-x64-gnu': 1.3.22 + '@farmfe/core-linux-x64-musl': 1.3.22 + '@farmfe/core-win32-arm64-msvc': 1.3.22 + '@farmfe/core-win32-ia32-msvc': 1.3.22 + '@farmfe/core-win32-x64-msvc': 1.3.22 transitivePeerDependencies: - bufferutil - supports-color @@ -2850,7 +2891,7 @@ snapshots: dependencies: core-js: 3.37.1 - '@farmfe/runtime@0.12.3': + '@farmfe/runtime@0.12.4': dependencies: core-js: 3.37.1 @@ -3740,6 +3781,15 @@ snapshots: minipass: 7.1.2 path-scurry: 1.11.1 + glob@11.0.0: + dependencies: + foreground-child: 3.1.1 + jackspeak: 4.0.2 + minimatch: 10.0.1 + minipass: 7.1.2 + package-json-from-dist: 1.0.0 + path-scurry: 2.0.0 + global-directory@4.0.1: dependencies: ini: 4.1.1 @@ -4013,6 +4063,10 @@ snapshots: optionalDependencies: '@pkgjs/parseargs': 0.11.0 + jackspeak@4.0.2: + dependencies: + '@isaacs/cliui': 8.0.2 + js-tokens@4.0.0: {} js-yaml@3.14.1: @@ -4141,6 +4195,8 @@ snapshots: lru-cache@10.2.2: {} + lru-cache@11.0.1: {} + lru-cache@4.1.5: dependencies: pseudomap: 1.0.2 @@ -4187,6 +4243,10 @@ snapshots: min-indent@1.0.1: {} + minimatch@10.0.1: + dependencies: + brace-expansion: 2.0.1 + minimatch@9.0.4: dependencies: brace-expansion: 2.0.1 @@ -4302,6 +4362,8 @@ snapshots: p-try@2.2.0: {} + package-json-from-dist@1.0.0: {} + parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -4334,6 +4396,11 @@ snapshots: lru-cache: 10.2.2 minipass: 7.1.2 + path-scurry@2.0.0: + dependencies: + lru-cache: 11.0.1 + minipass: 7.1.2 + path-type@4.0.0: {} picocolors@1.0.1: {} @@ -4437,6 +4504,11 @@ snapshots: reusify@1.0.4: {} + rimraf@6.0.1: + dependencies: + glob: 11.0.0 + package-json-from-dist: 1.0.0 + run-applescript@5.0.0: dependencies: execa: 5.1.1 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index ae517d8..0a94cd3 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -1,3 +1,7 @@ packages: - playground - packages/* + +catalog: + '@farmfe/cli': '^1.0.4' + '@farmfe/core': '^1.3.22'