From 4b4400068d5711cc1fc95cd860d702b08b4024cd Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 19 Jul 2024 16:35:38 +0800 Subject: [PATCH 1/9] chore: update newServer --- biome.json | 21 +- package.json | 2 + packages/core/package.json | 18 +- packages/core/src/newServer/hmr.ts | 46 ++ packages/core/src/newServer/http.ts | 139 ++++++ packages/core/src/newServer/index.ts | 133 ++++++ .../core/src/newServer/middlewares/cors.ts | 0 .../core/src/newServer/middlewares/error.ts | 0 .../core/src/newServer/middlewares/index.ts | 0 .../newServer/middlewares/lazy-compilation.ts | 0 .../src/newServer/middlewares/notFound.ts | 0 .../core/src/newServer/middlewares/proxy.ts | 15 + .../src/newServer/middlewares/resource.ts | 0 .../core/src/newServer/middlewares/static.ts | 0 packages/core/src/newServer/publicDir.ts | 35 ++ packages/core/src/newServer/type.ts | 100 +++++ packages/core/src/newServer/ws.ts | 196 +++++++++ packages/core/tsconfig.build.json | 5 +- pnpm-lock.yaml | 416 ++++++++++++------ 19 files changed, 976 insertions(+), 150 deletions(-) create mode 100644 packages/core/src/newServer/hmr.ts create mode 100644 packages/core/src/newServer/http.ts create mode 100644 packages/core/src/newServer/index.ts create mode 100644 packages/core/src/newServer/middlewares/cors.ts create mode 100644 packages/core/src/newServer/middlewares/error.ts create mode 100644 packages/core/src/newServer/middlewares/index.ts create mode 100644 packages/core/src/newServer/middlewares/lazy-compilation.ts create mode 100644 packages/core/src/newServer/middlewares/notFound.ts create mode 100644 packages/core/src/newServer/middlewares/proxy.ts create mode 100644 packages/core/src/newServer/middlewares/resource.ts create mode 100644 packages/core/src/newServer/middlewares/static.ts create mode 100644 packages/core/src/newServer/publicDir.ts create mode 100644 packages/core/src/newServer/type.ts create mode 100644 packages/core/src/newServer/ws.ts diff --git a/biome.json b/biome.json index a400607a47..158af3d1a4 100644 --- a/biome.json +++ b/biome.json @@ -30,28 +30,19 @@ "lineEnding": "lf", "lineWidth": 80, "attributePosition": "auto", - "include": [ - "**/*.ts" - ], - "ignore": [ - "node_modules", - "dist" - ] + "include": ["**/*.ts"], + "ignore": ["node_modules", "dist"] }, "organizeImports": { "enabled": true, - "include": [ - "./**/*.js", - "./**/*.ts", - "./**/*.mjs" - ] + "include": ["./**/*.js", "./**/*.ts", "./**/*.mjs"] }, "linter": { "enabled": true, "rules": { "recommended": false, "complexity": { - "noBannedTypes": "error", + "noBannedTypes": "off", "noExtraBooleanCast": "error", "noMultipleSpacesInRegularExpressionLiterals": "error", "noUselessCatch": "error", @@ -78,7 +69,7 @@ "noUnsafeFinally": "error", "noUnsafeOptionalChaining": "error", "noUnusedLabels": "error", - "noUnusedVariables": "warn", + "noUnusedVariables": "off", "useIsNan": "error", "useValidForDirection": "error", "useYield": "error" @@ -140,4 +131,4 @@ "attributePosition": "auto" } } -} \ No newline at end of file +} diff --git a/package.json b/package.json index 4b845d7bfd..4f609baf6e 100644 --- a/package.json +++ b/package.json @@ -23,6 +23,8 @@ "prepare": "husky" }, "devDependencies": { + "@farmfe/core": "workspace:*", + "@farmfe/cli": "workspace:*", "@biomejs/biome": "1.7.2", "@changesets/cli": "^2.26.0", "@commitlint/cli": "^17.0.3", diff --git a/packages/core/package.json b/packages/core/package.json index 156bce1faa..820e2c7370 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -69,16 +69,25 @@ }, "devDependencies": { "@napi-rs/cli": "^2.18.4", + "@types/connect": "^3.4.38", "@types/figlet": "^1.5.5", "@types/fs-extra": "^11.0.1", + "@types/http-proxy": "^1.17.14", "@types/koa": "^2.13.5", "@types/koa-compress": "^4.0.3", "@types/koa-static": "^4.0.2", "@types/koa__cors": "^5.0.0", "@types/lodash.debounce": "^4.0.7", "@types/mime-types": "^2.1.2", - "@types/ws": "^8.5.4", - "react-refresh": "^0.14.0" + "@types/ws": "^8.5.8", + "connect": "^3.7.0", + "cors": "^2.8.5", + "debug": "^4.3.5", + "etag": "^1.8.1", + "http-proxy": "^1.18.1", + "react-refresh": "^0.14.0", + "sirv": "^2.0.3", + "ws": "^8.14.2" }, "dependencies": { "@farmfe/runtime": "workspace:0.12.1", @@ -91,7 +100,7 @@ "deepmerge": "^4.3.1", "dotenv": "^16.4.5", "dotenv-expand": "^11.0.6", - "execa": "^7.1.1", + "execa": "9.3.0", "farm-browserslist-generator": "^1.0.0", "farm-plugin-replace-dirname": "0.2.1", "fast-glob": "^3.3.2", @@ -105,9 +114,8 @@ "lodash.debounce": "^4.0.8", "loglevel": "^1.8.1", "mime-types": "^2.1.35", - "open": "^9.1.0", + "open": "10.1.0", "slashes": "^3.0.12", - "ws": "^8.12.0", "zod": "^3.23.8", "zod-validation-error": "^3.3.0" }, diff --git a/packages/core/src/newServer/hmr.ts b/packages/core/src/newServer/hmr.ts new file mode 100644 index 0000000000..1a5eda65b3 --- /dev/null +++ b/packages/core/src/newServer/hmr.ts @@ -0,0 +1,46 @@ +import { + HMRBroadcasterClient, + HMRPayload, + InferCustomEventPayload +} from './type.js'; + +export interface HMRChannel { + /** + * Unique channel name + */ + name: string; + /** + * Broadcast events to all clients + */ + send(payload: HMRPayload): void; + /** + * Send custom event + */ + send(event: T, payload?: InferCustomEventPayload): void; + /** + * Handle custom event emitted by `import.meta.hot.send` + */ + on( + event: T, + listener: ( + data: InferCustomEventPayload, + client: HMRBroadcasterClient, + ...args: any[] + ) => void + ): void; + on(event: 'connection', listener: () => void): void; + /** + * Unregister event listener + */ + + // biome-ignore lint/complexity/noBannedTypes: + off(event: string, listener: Function): void; + /** + * Start listening for messages + */ + listen(): void; + /** + * Disconnect all clients, called when server is closed or restarted. + */ + close(): void; +} diff --git a/packages/core/src/newServer/http.ts b/packages/core/src/newServer/http.ts new file mode 100644 index 0000000000..a8f55ac02c --- /dev/null +++ b/packages/core/src/newServer/http.ts @@ -0,0 +1,139 @@ +/** + * The following is modified based on source found in + * https://github.com/vitejs/vite/blob/main/packages/vite/src/node/env.ts + * + * MIT License + * Copyright (c) 2019-present, Yuxi (Evan) + * https://github.com/vitejs/vite/blob/main/LICENSE + * + * Farm draws on the code of part of the vite server in order to better achieve the compatibility + * progress of the vite ecosystem and the integrity of vite's ecological development, + * which can reduce many unknown or known problems. + */ + +import type { OutgoingHttpHeaders as HttpServerHeaders } from 'node:http'; +import type { ServerOptions as HttpsServerOptions } from 'node:https'; +import path from 'node:path'; +import connect from 'connect'; +import fse from 'fs-extra'; +import { Logger } from '../utils/logger.js'; +import { HttpServer } from './index.js'; +import { ProxyOptions } from './middlewares/proxy.js'; + +export interface CommonServerOptions { + port?: number; + strictPort?: boolean; + host?: string | boolean; + https?: HttpsServerOptions; + open?: boolean | string; + proxy?: Record; + cors?: CorsOptions | boolean; + headers?: HttpServerHeaders; +} + +export type CorsOrigin = boolean | string | RegExp | (string | RegExp)[]; + +export interface CorsOptions { + origin?: + | CorsOrigin + | ((origin: string, cb: (err: Error, origins: CorsOrigin) => void) => void); + methods?: string | string[]; + allowedHeaders?: string | string[]; + exposedHeaders?: string | string[]; + credentials?: boolean; + maxAge?: number; + preflightContinue?: boolean; + optionsSuccessStatus?: number; +} + +// For the unencrypted tls protocol, we use http service. +// In other cases, https / http2 is used. +export async function resolveHttpServer( + { proxy }: CommonServerOptions, + app: connect.Server, + httpsOptions?: HttpsServerOptions +): Promise { + if (!httpsOptions) { + const { createServer } = await import('node:http'); + return createServer(app); + } + + // EXISTING PROBLEM: + // https://github.com/http-party/node-http-proxy/issues/1237 + + // MAYBE SOLUTION: + // https://github.com/nxtedition/node-http2-proxy + // https://github.com/fastify/fastify-http-proxy + if (proxy) { + const { createServer } = await import('node:https'); + return createServer(httpsOptions, app); + } else { + const { createSecureServer } = await import('node:http2'); + return createSecureServer( + { + maxSessionMemory: 1000, + ...httpsOptions, + allowHTTP1: true + }, + // @ts-ignore + app + ); + } +} + +export async function resolveHttpsConfig( + https: HttpsServerOptions | undefined +): Promise { + if (!https) return undefined; + + const [ca, cert, key, pfx] = await Promise.all([ + readFileIfExists(https.ca), + readFileIfExists(https.cert), + readFileIfExists(https.key), + readFileIfExists(https.pfx) + ]); + return { ...https, ca, cert, key, pfx }; +} + +async function readFileIfExists(value?: string | Buffer | any[]) { + if (typeof value === 'string') { + return fse.readFile(path.resolve(value)).catch(() => value); + } + return value; +} + +export async function httpServerStart( + httpServer: HttpServer, + serverOptions: { + port: number; + strictPort: boolean | undefined; + host: string | undefined; + logger: Logger; + } +): Promise { + let { port, strictPort, host, logger } = serverOptions; + + return new Promise((resolve, reject) => { + const onError = (e: Error & { code?: string }) => { + if (e.code === 'EADDRINUSE') { + if (strictPort) { + httpServer.removeListener('error', onError); + reject(new Error(`Port ${port} is already in use`)); + } else { + logger.info(`Port ${port} is in use, trying another one...`); + httpServer.listen(++port, host); + } + } else { + httpServer.removeListener('error', onError); + reject(e); + } + }; + + httpServer.on('error', onError); + + httpServer.listen(port, host, () => { + httpServer.removeListener('error', onError); + resolve(port); + }); + }); +} diff --git a/packages/core/src/newServer/index.ts b/packages/core/src/newServer/index.ts new file mode 100644 index 0000000000..82bf2e29e5 --- /dev/null +++ b/packages/core/src/newServer/index.ts @@ -0,0 +1,133 @@ +import type * as http from 'node:http'; +import type { Server } from 'node:http'; +import type { OutgoingHttpHeaders as HttpServerHeaders } from 'node:http'; +import { type Http2SecureServer } from 'node:http2'; +import type { ServerOptions as HttpsServerOptions } from 'node:https'; +import path from 'node:path'; +import { WatchOptions } from 'chokidar'; +import connect from 'connect'; +import fse from 'fs-extra'; +import { Compiler } from '../compiler/index.js'; +import { normalizePublicPath } from '../config/normalize-config/normalize-output.js'; +import { NormalizedServerConfig, ResolvedUserConfig } from '../config/types.js'; +import { logger } from '../utils/logger.js'; +import { initPublicFiles } from '../utils/publicDir.js'; +import { FileWatcher } from '../watcher/index.js'; +import { HMRChannel } from './hmr.js'; +import { + CommonServerOptions, + resolveHttpServer, + resolveHttpsConfig +} from './http.js'; +import { WsServer } from './ws.js'; +export type HttpServer = http.Server | Http2SecureServer; + +type CompilerType = Compiler | null; + +export interface HmrOptions { + protocol?: string; + host?: string; + port?: number; + clientPort?: number; + path?: string; + timeout?: number; + overlay?: boolean; + server?: Server; + /** @internal */ + channels?: HMRChannel[]; +} + +export interface ServerOptions extends CommonServerOptions { + /** + * Configure HMR-specific options (port, host, path & protocol) + */ + hmr?: HmrOptions | boolean; + /** + * Do not start the websocket connection. + * @experimental + */ + ws?: false; + /** + * chokidar watch options or null to disable FS watching + * https://github.com/paulmillr/chokidar#api + */ + watchOptions?: WatchOptions | null; + /** + * Create dev server to be used as a middleware in an existing server + * @default false + */ + middlewareMode?: + | boolean + | { + /** + * Parent server instance to attach to + * + * This is needed to proxy WebSocket connections to the parent server. + */ + server: http.Server; + }; + origin?: string; +} +export class newServer { + private compiler: CompilerType; + + ws: WsServer; + config: ResolvedUserConfig; + serverConfig: CommonServerOptions & NormalizedServerConfig; + httpsOptions: HttpsServerOptions; + publicDir?: string; + publicPath?: string; + server?: HttpServer; + watcher: FileWatcher; + + constructor(compiler: CompilerType, config: ResolvedUserConfig) { + this.compiler = compiler; + this.config = config; + + if (!this.compiler) return; + + this.publicPath = + normalizePublicPath( + compiler.config.config.output.targetEnv, + compiler.config.config.output.publicPath, + logger, + false + ) || '/'; + } + + getCompiler(): CompilerType { + return this.compiler; + } + + async createServer() { + const initPublicFilesPromise = initPublicFiles(this.config); + const { root, server: serverConfig } = this.config; + this.httpsOptions = await resolveHttpsConfig(serverConfig.https); + const { middlewareMode } = serverConfig; + const middlewares = connect() as connect.Server; + this.server = middlewareMode + ? null + : await resolveHttpServer( + serverConfig as CommonServerOptions, + middlewares, + this.httpsOptions + ); + + const publicFiles = await initPublicFilesPromise; + const { publicDir } = this.config.compilation.assets; + this.createWebSocketServer(); + } + + public async createWebSocketServer() { + if (!this.server) { + throw new Error('Websocket requires a server.'); + } + const wsServer = new WsServer( + this.server, + this.config, + this.httpsOptions, + this.publicPath, + null + ); + } +} diff --git a/packages/core/src/newServer/middlewares/cors.ts b/packages/core/src/newServer/middlewares/cors.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/error.ts b/packages/core/src/newServer/middlewares/error.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/index.ts b/packages/core/src/newServer/middlewares/index.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/lazy-compilation.ts b/packages/core/src/newServer/middlewares/lazy-compilation.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/notFound.ts b/packages/core/src/newServer/middlewares/notFound.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/proxy.ts b/packages/core/src/newServer/middlewares/proxy.ts new file mode 100644 index 0000000000..9c24cace87 --- /dev/null +++ b/packages/core/src/newServer/middlewares/proxy.ts @@ -0,0 +1,15 @@ +import type * as http from 'node:http'; +// import type * as net from 'node:net'; +// import connect from 'connect'; +import httpProxy from 'http-proxy'; + +export interface ProxyOptions extends httpProxy.ServerOptions { + rewrite?: (path: string) => string; + configure?: (proxy: httpProxy, options: ProxyOptions) => void; + bypass?: ( + req: http.IncomingMessage, + res: http.ServerResponse, + options: ProxyOptions + ) => void | null | undefined | false | string; + rewriteWsOrigin?: boolean | undefined; +} diff --git a/packages/core/src/newServer/middlewares/resource.ts b/packages/core/src/newServer/middlewares/resource.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/middlewares/static.ts b/packages/core/src/newServer/middlewares/static.ts new file mode 100644 index 0000000000..e69de29bb2 diff --git a/packages/core/src/newServer/publicDir.ts b/packages/core/src/newServer/publicDir.ts new file mode 100644 index 0000000000..9b6725ce51 --- /dev/null +++ b/packages/core/src/newServer/publicDir.ts @@ -0,0 +1,35 @@ +import { ResolvedUserConfig } from '../config/types.js'; +import { recursiveReaddir } from '../utils/index.js'; + +export const ERR_SYMLINK_IN_RECURSIVE_READDIR = + 'ERR_SYMLINK_IN_RECURSIVE_READDIR'; + +const publicFilesMap = new WeakMap>(); + +export async function initPublicFiles( + config: ResolvedUserConfig +): Promise | undefined> { + let fileNames: string[]; + const publicDir: string = config.compilation?.assets?.publicDir as string; + console.log(publicDir); + + try { + fileNames = await recursiveReaddir(publicDir); + } catch (e) { + if (e.code === ERR_SYMLINK_IN_RECURSIVE_READDIR) { + return; + } + throw e; + } + const publicFiles = new Set( + fileNames.map((fileName) => fileName.slice(publicDir.length)) + ); + publicFilesMap.set(config, publicFiles); + return publicFiles; +} + +export function getPublicFiles( + config: ResolvedUserConfig +): Set | undefined { + return publicFilesMap.get(config); +} diff --git a/packages/core/src/newServer/type.ts b/packages/core/src/newServer/type.ts new file mode 100644 index 0000000000..1fe2aaf024 --- /dev/null +++ b/packages/core/src/newServer/type.ts @@ -0,0 +1,100 @@ +export type HMRPayload = + | ConnectedPayload + | UpdatePayload + | FullReloadPayload + | CustomPayload + | ErrorPayload + | PrunePayload + +export interface ConnectedPayload { + type: 'connected' +} + +export interface UpdatePayload { + type: 'update' + updates: Update[] +} + +export interface Update { + type: 'js-update' | 'css-update' + path: string + acceptedPath: string + timestamp: number + /** @internal */ + explicitImportRequired?: boolean + /** @internal */ + isWithinCircularImport?: boolean + /** @internal */ + ssrInvalidates?: string[] +} + +export interface PrunePayload { + type: 'prune' + paths: string[] +} + +export interface FullReloadPayload { + type: 'full-reload' + path?: string + /** @internal */ + triggeredBy?: string +} + +export interface CustomPayload { + type: 'custom' + event: string + data?: any +} + +export interface ErrorPayload { + type: 'error' + err: { + [name: string]: any + message: string + stack: string + id?: string + frame?: string + plugin?: string + pluginCode?: string + loc?: { + file?: string + line: number + column: number + } + } +} + +export interface CustomEventMap { + 'vite:beforeUpdate': UpdatePayload + 'vite:afterUpdate': UpdatePayload + 'vite:beforePrune': PrunePayload + 'vite:beforeFullReload': FullReloadPayload + 'vite:error': ErrorPayload + 'vite:invalidate': InvalidatePayload + 'vite:ws:connect': WebSocketConnectionPayload + 'vite:ws:disconnect': WebSocketConnectionPayload +} + +export interface WebSocketConnectionPayload { + webSocket: WebSocket +} + +export interface InvalidatePayload { + path: string + message: string | undefined +} + +export type InferCustomEventPayload = + T extends keyof CustomEventMap ? CustomEventMap[T] : any + + +export interface HMRBroadcasterClient { + /** + * Send event to the client + */ + send(payload: HMRPayload): void + /** + * Send custom event + */ + send(event: string, payload?: CustomPayload['data']): void +} diff --git a/packages/core/src/newServer/ws.ts b/packages/core/src/newServer/ws.ts new file mode 100644 index 0000000000..5460a61313 --- /dev/null +++ b/packages/core/src/newServer/ws.ts @@ -0,0 +1,196 @@ +import type { IncomingMessage, Server } from 'node:http'; +import { STATUS_CODES, createServer as createHttpServer } from 'node:http'; +import type { ServerOptions as HttpsServerOptions } from 'node:https'; +import { createServer as createHttpsServer } from 'node:https'; +import type { Socket } from 'node:net'; +import path from 'node:path'; +import type { Duplex } from 'node:stream'; +import type { WebSocket as WebSocketRaw } from 'ws'; +import { WebSocketServer as WebSocketServerRaw_ } from 'ws'; +import { NormalizedServerConfig, ResolvedUserConfig } from '../config/types.js'; +import { HmrEngine } from '../server/hmr-engine.js'; +import { WebSocket as WebSocketTypes } from '../types/ws.js'; +import { ILogger, Logger } from '../utils/logger.js'; +import { isObject } from '../utils/share.js'; +import { HMRChannel } from './hmr.js'; +import { CommonServerOptions } from './http.js'; +import { HttpServer, ServerOptions } from './index.js'; +import { + CustomPayload, + ErrorPayload, + HMRPayload, + InferCustomEventPayload +} from './type.js'; + +export interface WebSocketServer extends HMRChannel { + /** + * Listen on port and host + */ + listen(): void; + /** + * Get all connected clients. + */ + clients: Set; + /** + * Disconnect all clients and terminate the server. + */ + close(): Promise; + /** + * Handle custom event emitted by `import.meta.hot.send` + */ + on: WebSocketTypes.Server['on'] & { + ( + event: T, + listener: WebSocketCustomListener> + ): void; + }; + /** + * Unregister event listener. + */ + off: WebSocketTypes.Server['off'] & { + // biome-ignore lint/complexity/noBannedTypes: + (event: string, listener: Function): void; + }; +} + +export interface WebSocketClient { + /** + * Send event to the client + */ + send(payload: HMRPayload): void; + /** + * Send custom event + */ + send(event: string, payload?: CustomPayload['data']): void; + /** + * The raw WebSocket instance + * @advanced + */ + socket: WebSocketTypes; +} + +const wsServerEvents = [ + 'connection', + 'error', + 'headers', + 'listening', + 'message' +]; + +function noop() { + // noop +} + +const HMR_HEADER = 'farm_hmr'; + +export type WebSocketCustomListener = ( + data: T, + client: WebSocketClient +) => void; + +const WebSocketServerRaw = process.versions.bun + ? // @ts-expect-error: Bun defines `import.meta.require` + import.meta.require('ws').WebSocketServer + : WebSocketServerRaw_; + +export class WsServer { + public wss: WebSocketRaw; + public customListeners = new Map>>(); + public clientsMap = new WeakMap(); + public bufferedError: ErrorPayload | null = null; + public logger: ILogger; + public wsServerOrHmrServer: Server; + + constructor( + private httpServer: HttpServer, + private config: ResolvedUserConfig, + private httpsOptions: HttpsServerOptions, + private publicPath: string, + private hmrEngine: HmrEngine, + logger?: ILogger + ) { + this.logger = logger ?? new Logger(); + this.createWebSocketServer(); + } + + createWebSocketServer() { + const serverConfig = this.config.server as ServerOptions; + if (serverConfig.ws === false) { + return { + name: 'ws', + get clients() { + return new Set(); + }, + async close() { + // noop + }, + on: noop as any as WebSocketServer['on'], + off: noop as any as WebSocketServer['off'], + listen: noop, + send: noop + }; + } + let wss: WebSocketServerRaw_; + let wsHttpServer: Server | undefined = undefined; + + const hmr = isObject(serverConfig.hmr) && serverConfig.hmr; + const hmrServer = hmr && hmr.server; + const hmrPort = hmr && hmr.port; + const portsAreCompatible = !hmrPort || hmrPort === serverConfig.port; + // @ts-ignore + this.wsServerOrHmrServer = + hmrServer || (portsAreCompatible && this.httpServer); + let hmrServerWsListener: ( + req: InstanceType, + socket: Duplex, + head: Buffer + ) => void; + const port = hmrPort || 9000; + const host = (hmr && hmr.host) || undefined; + + if (this.wsServerOrHmrServer) { + let hmrBase = this.publicPath; + const hmrPath = hmr ? hmr.path : undefined; + if (hmrPath) { + hmrBase = path.posix.join(hmrBase, hmrPath as string); + } + wss = new WebSocketServerRaw({ noServer: true }); + hmrServerWsListener = (req, socket, head) => { + if ( + req.headers['sec-websocket-protocol'] === HMR_HEADER && + req.url === hmrBase + ) { + wss.handleUpgrade(req, socket as Socket, head, (ws) => { + wss.emit('connection', ws, req); + }); + } + }; + this.wsServerOrHmrServer.on('upgrade', hmrServerWsListener); + } else { + // http server request handler keeps the same with + // https://github.com/websockets/ws/blob/45e17acea791d865df6b255a55182e9c42e5877a/lib/websocket-server.js#L88-L96 + const route = ((_, res) => { + const statusCode = 426; + const body = STATUS_CODES[statusCode]; + if (!body) + throw new Error( + `No body text found for the ${statusCode} status code` + ); + + res.writeHead(statusCode, { + 'Content-Length': body.length, + 'Content-Type': 'text/plain' + }); + res.end(body); + }) as Parameters[1]; + if (this.httpsOptions) { + wsHttpServer = createHttpsServer(this.httpsOptions, route); + } else { + wsHttpServer = createHttpServer(route); + } + // vite dev server in middleware mode + // need to call ws listen manually + wss = new WebSocketServerRaw({ server: wsHttpServer }); + } + } +} diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index 3ea9330584..4f16e9c00d 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -3,10 +3,11 @@ "compilerOptions": { "rootDir": "src", "outDir": "dist", - "composite": true + "composite": true, + "noUnusedLocals": false }, "include": ["src/**/*.ts", "binding/**/*.d.ts"], - "exclude": ["src/**/*.spec.ts"], + "exclude": ["src/**/*.spec.ts", "src/newServer/**"], "references": [ { "path": "../utils/tsconfig.json" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0745fe1d41..7607c58402 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,6 +25,12 @@ importers: '@commitlint/config-conventional': specifier: ^17.0.3 version: 17.8.1 + '@farmfe/cli': + specifier: workspace:* + version: link:packages/cli + '@farmfe/core': + specifier: workspace:* + version: link:packages/core '@types/node': specifier: ^18.0.1 version: 18.18.8 @@ -2246,8 +2252,8 @@ importers: specifier: ^11.0.6 version: 11.0.6 execa: - specifier: ^7.1.1 - version: 7.2.0 + specifier: 9.3.0 + version: 9.3.0 farm-browserslist-generator: specifier: ^1.0.0 version: 1.0.0 @@ -2288,14 +2294,11 @@ importers: specifier: ^2.1.35 version: 2.1.35 open: - specifier: ^9.1.0 - version: 9.1.0 + specifier: 10.1.0 + version: 10.1.0 slashes: specifier: ^3.0.12 version: 3.0.12 - ws: - specifier: ^8.12.0 - version: 8.14.2(bufferutil@4.0.8)(utf-8-validate@6.0.3) zod: specifier: ^3.23.8 version: 3.23.8 @@ -2306,12 +2309,18 @@ importers: '@napi-rs/cli': specifier: ^2.18.4 version: 2.18.4 + '@types/connect': + specifier: ^3.4.38 + version: 3.4.38 '@types/figlet': specifier: ^1.5.5 version: 1.5.7 '@types/fs-extra': specifier: ^11.0.1 version: 11.0.3 + '@types/http-proxy': + specifier: ^1.17.14 + version: 1.17.14 '@types/koa': specifier: ^2.13.5 version: 2.13.10 @@ -2331,11 +2340,32 @@ importers: specifier: ^2.1.2 version: 2.1.3 '@types/ws': - specifier: ^8.5.4 + specifier: ^8.5.8 version: 8.5.8 + connect: + specifier: ^3.7.0 + version: 3.7.0 + cors: + specifier: ^2.8.5 + version: 2.8.5 + debug: + specifier: ^4.3.5 + version: 4.3.5 + etag: + specifier: ^1.8.1 + version: 1.8.1 + http-proxy: + specifier: ^1.18.1 + version: 1.18.1(debug@4.3.5) react-refresh: specifier: ^0.14.0 version: 0.14.0 + sirv: + specifier: ^2.0.3 + version: 2.0.3 + ws: + specifier: ^8.14.2 + version: 8.14.2(bufferutil@4.0.8)(utf-8-validate@6.0.3) packages/create-farm: devDependencies: @@ -4285,6 +4315,9 @@ packages: cpu: [x64] os: [win32] + '@sec-ant/readable-stream@0.4.1': + resolution: {integrity: sha512-831qok9r2t8AlxLko40y2ebgSDhenenCatLVeW/uBtnHPyhHOvG0C7TvfgecV+wHzIm5KUICgzmVpWS+IMEAeg==} + '@simonwep/pickr@1.8.2': resolution: {integrity: sha512-/l5w8BIkrpP6n1xsetx9MWPWlU6OblN5YgZZphxan0Tq4BByTCETL6lyIeY8lagalS2Nbt4F2W034KHLIiunKA==} @@ -4298,6 +4331,10 @@ packages: resolution: {integrity: sha512-t09vSN3MdfsyCHoFcTRCH/iUtG7OJ0CsjzB8cjAmKc/va/kIgeDI/TxsigdncE/4be734m0cvIYwNaV4i2XqAw==} engines: {node: '>=10'} + '@sindresorhus/merge-streams@4.0.0': + resolution: {integrity: sha512-tlqY9xq5ukxTUZBmoOp+m61cqwQD5pHJtFY3Mn8CA8ps6yghLH/Hw8UPdqg4OLmFW3IFlcXnQNmo/dh8HzXYIQ==} + engines: {node: '>=18'} + '@sinonjs/commons@3.0.1': resolution: {integrity: sha512-K3mCHKQ9sVh8o1C9cxkwxaOmXoAMlDxC1mYyHrjqOWEcBjYr76t96zL2zlj5dUGZ3HSw240X1qgH3Mjf1yJWpQ==} @@ -4806,8 +4843,8 @@ packages: resolution: {integrity: sha512-VwVFUHlneOsWfv/GaaY7Kwk4XasDqkAlyFQtsHxnOw0yyBYWTrlEXtmb9RtC+VFBCdtuOeIXECmELNd5RrKp/g==} deprecated: This is a stub types definition. clipboard provides its own type definitions, so you do not need this installed. - '@types/connect@3.4.37': - resolution: {integrity: sha512-zBUSRqkfZ59OcwXon4HVxhx5oWCJmc0OtBTK05M+p0dYjgN6iTwIL2T/WbsQZrEsdnwaF9cWQ+azOnpPvIqY3Q==} + '@types/connect@3.4.38': + resolution: {integrity: sha512-K6uROf1LD88uDQqJCktA4yzL1YYAK6NgfsI0v/mTgyPKWsX1CnJ0XPSDhViejru1GcRkLWb8RlzFYJRqGUbaug==} '@types/content-disposition@0.5.7': resolution: {integrity: sha512-V9/5u21RHFR1zfdm3rQ6pJUKV+zSSVQt+yq16i1YhdivVzWgPEoKedc3GdT8aFjsqQbakdxuy3FnEdePUQOamQ==} @@ -5944,10 +5981,6 @@ packages: resolution: {integrity: sha512-pbnl5XzGBdrFU/wT4jqmJVPn2B6UHPBOhzMQkY/SPUPB6QtUXtmBHBIwCbXJol93mOpGMnQyP/+BB19q04xj7g==} engines: {node: '>=4'} - big-integer@1.6.51: - resolution: {integrity: sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==} - engines: {node: '>=0.6'} - big.js@5.2.2: resolution: {integrity: sha512-vyL2OymJxmarO8gxMr0mhChsO9QGwhynfuu4+MHTAW6czfq9humCB7rKpUjDd9YUiDPU4mzpyupFSvOClAwbmQ==} @@ -5990,10 +6023,6 @@ packages: resolution: {integrity: sha512-j//dBVuyacJbvW+tvZ9HuH03fZ46QcaKvvhZickZqtB271DxJ7SNRSNxrV/dZX0085m7hISRZWbzWlJvx/rHSg==} engines: {node: '>=14.16'} - bplist-parser@0.2.0: - resolution: {integrity: sha512-z0M+byMThzQmD9NILRniCUXYsYpjwnlO8N5uCFaCqIOpqRsJCrQL9NK3JsD67CN5a08nF5oIL2bD6loTdHOuKw==} - engines: {node: '>= 5.10.0'} - brace-expansion@1.1.11: resolution: {integrity: sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==} @@ -6055,9 +6084,9 @@ packages: builder-util@24.13.1: resolution: {integrity: sha512-NhbCSIntruNDTOVI9fdXz0dihaqX2YuE1D6zZMrwiErzH4ELZHE6mdiB40wEgZNprDia+FghRFgKoAqMZRRjSA==} - bundle-name@3.0.0: - resolution: {integrity: sha512-PKA4BeSvBpQKQ8iPOGCSiell+N8P+Tf1DlwqmYhpe2gAhKPHn8EYOxVT+ShuGmhg8lN8XiSlS80yiExKXrURlw==} - engines: {node: '>=12'} + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} @@ -6457,6 +6486,10 @@ packages: resolution: {integrity: sha512-aMKprgk5YhBNyH25hj8wGt2+D52Sw1DRRIzqBwLp2Ya9mFmY8KPvvtvmna8SxVR9JMZ4kzMD68N22vlaRpkeFA==} engines: {node: '>=8'} + connect@3.7.0: + resolution: {integrity: sha512-ZqRXc+tZukToSNmh5C2iWMSoV3X1YUcPbqEM4DkEG5tNQXrQUZCNVGGv3IuicnkMtPfGf3Xtp8WCXs295iQ1pQ==} + engines: {node: '>= 0.10.0'} + consola@2.15.3: resolution: {integrity: sha512-9vAdYbHj6x2fLKC4+oPH0kFzY/orMZyG2Aj+kNylHxKGJ/Ed4dpNyAQYwJOdqO4zdM7XpVHmyejQDcQHrnuXbw==} @@ -7153,6 +7186,15 @@ packages: supports-color: optional: true + debug@4.3.5: + resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} engines: {node: '>=0.10.0'} @@ -7205,13 +7247,13 @@ packages: resolution: {integrity: sha512-3sUqbMEc77XqpdNO7FRyRog+eW3ph+GYCbj+rK+uYyRMuwsVy0rMiVtPn+QJlKFvWP/1PYpapqYn0Me2knFn+A==} engines: {node: '>=0.10.0'} - default-browser-id@3.0.0: - resolution: {integrity: sha512-OZ1y3y0SqSICtE8DE4S8YOE9UZOJ8wO16fKWVP5J1Qz42kV9jcnMVFrEE/noXb/ss3Q4pZIH79kxofzyNNtUNA==} - engines: {node: '>=12'} + default-browser-id@5.0.0: + resolution: {integrity: sha512-A6p/pu/6fyBcA1TRz/GqWYPViplrftcW2gZC9q79ngNCKAeR/X3gcEdXQHl4KNXV+3wgIJ1CPkJQ3IHM6lcsyA==} + engines: {node: '>=18'} - default-browser@4.0.0: - resolution: {integrity: sha512-wX5pXO1+BrhMkSbROFsyxUm0i/cJEScyNhA4PPxc41ICuv05ZZB/MX28s8aZx6xjmatvebIapF6hLEKEcpneUA==} - engines: {node: '>=14.16'} + default-browser@5.2.1: + resolution: {integrity: sha512-WY/3TUME0x3KPYdRRxEJJvXRHV4PyPoUsxtZa78lwItwRQRHhd2U9xOscaT/YTf8uCXIAjeJOFBVEh/7FtD8Xg==} + engines: {node: '>=18'} defaults@1.0.4: resolution: {integrity: sha512-eFuaLoy/Rxalv2kr+lqMlUnrDWV+3j4pljOIJgLIhI058IQfWJ7vXhyEIHu+HtC738klGALYxOKDO0bQP3tg8A==} @@ -7695,6 +7737,10 @@ packages: resolution: {integrity: sha512-VyhnebXciFV2DESc+p6B+y0LjSm0krU4OgJN44qFAhBY0TJ+1V61tYD2+wHusZ6F9n5K+vl8k0sTy7PEfV4qpg==} engines: {node: '>=16.17'} + execa@9.3.0: + resolution: {integrity: sha512-l6JFbqnHEadBoVAVpN5dl2yCyfX28WoBAGaoQcNmLLSedOxTxcn2Qa83s8I/PA5i56vWru2OHOtrwF7Om2vqlg==} + engines: {node: ^18.19.0 || >=20.5.0} + exit-on-epipe@1.0.1: resolution: {integrity: sha512-h2z5mrROTxce56S+pnvAV890uu7ls7f1kEvVGJbw1OlFH3/mlJ5bkXu0KRyW94v37zzHPiUd55iLn3DA7TjWpw==} engines: {node: '>=0.8'} @@ -7940,6 +7986,10 @@ packages: resolution: {integrity: sha512-ej8ksPF4x6e5wvK9yevct0UCXh8TTFlWGVLlgjZuoBH1HwjIfKE/IdL5mq89sFA7zELi1VhKpmtDnrs7zWyeyg==} engines: {node: '>=14'} + figures@6.1.0: + resolution: {integrity: sha512-d+l3qxjSesT4V7v2fh+QnmFnUWv9lSpjarhShNTgBOfA0ttejbQUAlHLitbjkoRiDulW0OPoQPYIGhIC8ohejg==} + engines: {node: '>=18'} + file-entry-cache@6.0.1: resolution: {integrity: sha512-7Gps/XWymbLk2QLYK4NzpMOrYjMhdIxXuIvy2QBsLE6ljuodKvdkWs/cpyJJ3CVIVpH0Oi1Hvg1ovbMzLdFBBg==} engines: {node: ^10.12.0 || >=12.0.0} @@ -7967,6 +8017,10 @@ packages: resolution: {integrity: sha512-8rXg1ZnX7xzy2NGDVkBVaAy+lSlPNwad13BtgSlLuxfIslyt5Vg64U7tFcCt4WS1R0hvtnQybT/IyCkGZ3DpXQ==} engines: {node: '>=0.10.0'} + finalhandler@1.1.2: + resolution: {integrity: sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==} + engines: {node: '>= 0.8'} + finalhandler@1.2.0: resolution: {integrity: sha512-5uXcUVftlQMFnWC9qu/svkWv3GTd2PfUhK/3PLkYNAe7FbqJMt3515HaxE6eRL74GdsriiwujiawdaB1BpEISg==} engines: {node: '>= 0.8'} @@ -8200,6 +8254,10 @@ packages: resolution: {integrity: sha512-VaUJspBffn/LMCJVoMvSAdmscJyS1auj5Zulnn5UoYcY531UWmdwhRWkcGKnGU93m5HSXP9LP2usOryrBtQowA==} engines: {node: '>=16'} + get-stream@9.0.1: + resolution: {integrity: sha512-kVCxPF3vQM/N0B1PmoqVUqgHP+EeVjmZSQn+1oCRPxd2P21P2F19lIgbR3HBosbB1PUhOAoctJnfEn2GbN2eZA==} + engines: {node: '>=18'} + get-symbol-description@1.0.0: resolution: {integrity: sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==} engines: {node: '>= 0.4'} @@ -8481,6 +8539,10 @@ packages: resolution: {integrity: sha512-AXcZb6vzzrFAUE61HnN4mpLqd/cSIwNQjtNWR0euPm6y0iqx3G4gOXaIDdtdDwZmhwe82LA6+zinmW4UBWVePQ==} engines: {node: '>=16.17.0'} + human-signals@7.0.0: + resolution: {integrity: sha512-74kytxOUSvNbjrT9KisAbaTZ/eJwD/LrbM/kh5j0IhPuJzwuA19dWvniFGwBzN9rVjg+O/e+F310PjObDXS+9Q==} + engines: {node: '>=18.18.0'} + humanize-ms@1.2.1: resolution: {integrity: sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==} @@ -8745,6 +8807,10 @@ packages: resolution: {integrity: sha512-gwsOE28k+23GP1B6vFl1oVh/WOzmawBrKwo5Ev6wMKzPkaXaCDIQKzLnvsA42DRlbVTWorkgTKIviAKCWkfUwA==} engines: {node: '>=10'} + is-plain-obj@4.1.0: + resolution: {integrity: sha512-+Pgi+vMuUNkJyExiMBt5IlFoMyKnr5zhJ4Uspz58WOhBF5QoIZkFyNHIbBAtHwzVAgk5RtndVNsDRN61/mmDqg==} + engines: {node: '>=12'} + is-plain-object@2.0.4: resolution: {integrity: sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==} engines: {node: '>=0.10.0'} @@ -8787,6 +8853,10 @@ packages: resolution: {integrity: sha512-LnQR4bZ9IADDRSkvpqMGvt/tEJWclzklNgSw48V5EAaAeDd6qGvN8ei6k5p0tvxSR171VmGyHuTiAOfxAbr8kA==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + is-stream@4.0.1: + resolution: {integrity: sha512-Dnz92NInDqYckGEUJv689RbRiTSEHCQ7wOVeALbkOz999YpqT46yMRIGtSNl2iCL1waAZSx40+h59NV/EwzV/A==} + engines: {node: '>=18'} + is-string@1.0.7: resolution: {integrity: sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==} engines: {node: '>= 0.4'} @@ -8818,6 +8888,10 @@ packages: resolution: {integrity: sha512-43r2mRvz+8JRIKnWJ+3j8JtjRKZ6GmjzfaE/qiBJnikNnYv/6bagRJ1kUhNk8R5EX/GkobD+r+sfxCPJsiKBLQ==} engines: {node: '>=12'} + is-unicode-supported@2.0.0: + resolution: {integrity: sha512-FRdAyx5lusK1iHG0TWpVtk9+1i+GjrzRffhDg4ovQ7mcidMQ6mj+MhKPmvh7Xwyv5gIS06ns49CA7Sqg7lC22Q==} + engines: {node: '>=18'} + is-weakmap@2.0.2: resolution: {integrity: sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==} engines: {node: '>= 0.4'} @@ -8844,6 +8918,10 @@ packages: resolution: {integrity: sha512-fKzAra0rGJUUBwGBgNkHZuToZcn+TtXHpeCgmkMJMMYx1sQDYaCSyjJBSCa2nH1DGm7s3n1oBnohoVTBaN7Lww==} engines: {node: '>=8'} + is-wsl@3.1.0: + resolution: {integrity: sha512-UcVfVfaK4Sc4m7X3dUSoHoozQGBEFeDC+zVo06t98xe8CzHSZZBekNXH+tu0NalHolcJ/QAGqS46Hef7QXBIMw==} + engines: {node: '>=16'} + isarray@0.0.1: resolution: {integrity: sha512-D2S+3GLxWH+uhrNEcoh/fnmYeP8E8/zHl644d/jdA0g2uyXvy3sb0qxotE+ne0LtccHknQzWwZEzhak7oJ0COQ==} @@ -9858,6 +9936,10 @@ packages: resolution: {integrity: sha512-sJOdmRGrY2sjNTRMbSvluQqg+8X7ZK61yvzBEIDhz4f8z1TZFYABsqjjCBd/0PUNE9M6QDgHJXQkGUEm7Q+l9Q==} engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + npm-run-path@5.3.0: + resolution: {integrity: sha512-ppwTtiJZq0O/ai0z7yfudtBpWIoxM8yE6nHi1X47eFR2EWORqfbu6CnPlNsjeN683eT0qG6H/Pyf9fCcvjnnnQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + npmlog@6.0.2: resolution: {integrity: sha512-/vBvz5Jfr9dT/aFWd0FIRf+T/Q2WBsLENygUaFUqstqsycmZAP/t5BvFJTK0viFmSUxiUKTUplWy5vt+rvKIxg==} engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} @@ -9914,6 +9996,10 @@ packages: resolution: {integrity: sha512-tqa/UMy/CCoYmj+H5qc07qvSL9dqcs/WZENZ1JbtWBlATP+iVOe778gE6MSijnyCnORzDuX6hU+LA4SZ09YjFQ==} engines: {node: '>=0.10.0'} + on-finished@2.3.0: + resolution: {integrity: sha512-ikqdkGAAyf/X/gPhXGvfgAytDZtDbr+bkNUJ0N9h5MI/dmdgCs3l6hoHrcUv41sRKew3jIwrp4qQDXiK99Utww==} + engines: {node: '>= 0.8'} + on-finished@2.4.1: resolution: {integrity: sha512-oVlzkg3ENAhCk2zdv7IJwd/QUD4z2RxRwpkcGY8psCVcCYZNq4wYnVWALHM+brtuJjePWiYF/ClmuDr8Ch5+kg==} engines: {node: '>= 0.8'} @@ -9940,9 +10026,9 @@ packages: only@0.0.2: resolution: {integrity: sha512-Fvw+Jemq5fjjyWz6CpKx6w9s7xxqo3+JCyM0WXWeCSOboZ8ABkyvP8ID4CZuChA/wxSx+XSJmdOm8rGVyJ1hdQ==} - open@9.1.0: - resolution: {integrity: sha512-OS+QTnw1/4vrf+9hh1jc1jnYjzSG4ttTBB8UxOwAnInG3Uo4ssetzC1ihqaIHjLJnA5GGlRl6QlZXOTQhRBUvg==} - engines: {node: '>=14.16'} + open@10.1.0: + resolution: {integrity: sha512-mnkeQ1qP5Ue2wd+aivTD3NHd/lZ96Lu0jgf0pwktLPtx6cTZiH7tyeGRRHs0zX0rbrahXPnXlUnbeXyaBBuIaw==} + engines: {node: '>=18'} opencollective-postinstall@2.0.3: resolution: {integrity: sha512-8AV/sCtuzUeTo8gQK5qDZzARrulB3egtLzFgteqB2tcT4Mw7B8Kt7JcDHmltjz6FOAHsvTevk70gZEbhM4ZS9Q==} @@ -10065,6 +10151,10 @@ packages: resolution: {integrity: sha512-ayCKvm/phCGxOkYRSCM82iDwct8/EonSEgCSxWxD7ve6jHggsFl4fZVQBPRNgQoKiuV/odhFrGzQXZwbifC8Rg==} engines: {node: '>=8'} + parse-ms@4.0.0: + resolution: {integrity: sha512-TXfryirbmq34y8QBwgqCVLi+8oA3oWx2eAnSn62ITyEhEYaWRlVZ2DvMM9eZbMs/RfxPu/PK/aBLyGj4IrqMHw==} + engines: {node: '>=18'} + parse-node-version@1.0.1: resolution: {integrity: sha512-3YHlOa/JgH6Mnpr05jP9eDG254US9ek25LyIxZlDItp2iJtwyaXQb57lBYLdT3MowkUFYEV2XXNAYIPlESvJlA==} engines: {node: '>= 0.10'} @@ -10392,6 +10482,10 @@ packages: resolution: {integrity: sha512-Pdlw/oPxN+aXdmM9R00JVC9WVFoCLTKJvDVLgmJ+qAffBMxsV85l/Lu7sNx4zSzPyoL2euImuEwHhOXdEgNFZQ==} engines: {node: ^14.15.0 || ^16.10.0 || >=18.0.0} + pretty-ms@9.0.0: + resolution: {integrity: sha512-E9e9HJ9R9NasGOgPaPE8VMeiPKAyWR5jcFpNnwIejslIhWqdqOrb2wShBsncMPUb+BcCd2OPYfh7p2W6oemTng==} + engines: {node: '>=18'} + primevue@3.52.0: resolution: {integrity: sha512-HLOVP5YI0ArFKUhIyfZsWmTNMaBYNCBWC/3DYvdd/Po4LY5/WXf7yIYvArE2q/3OuwSXJXvjlR8UNQeJYRSQog==} peerDependencies: @@ -11129,9 +11223,9 @@ packages: engines: {node: '>=18.0.0', npm: '>=8.0.0'} hasBin: true - run-applescript@5.0.0: - resolution: {integrity: sha512-XcT5rBksx1QdIhlFOCtgZkB99ZEouFZ1E2Kc2LHqNW13U3/74YGdkQRmThTwxy4QIyookibDKYZOPqX//6BlAg==} - engines: {node: '>=12'} + run-applescript@7.0.0: + resolution: {integrity: sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A==} + engines: {node: '>=18'} run-async@2.4.1: resolution: {integrity: sha512-tvVnVv01b8c1RrA6Ep7JkStj85Guv/YrMcwqYQnwjsAS2cTmmPGBBjAjpCW7RrSodNSoE2/qg9O4bceNvUuDgQ==} @@ -11790,6 +11884,10 @@ packages: resolution: {integrity: sha512-dOESqjYr96iWYylGObzd39EuNTa5VJxyvVAEm5Jnh7KGo75V43Hk1odPQkNDyXNmUR6k+gEiDVXnjB8HJ3crXw==} engines: {node: '>=12'} + strip-final-newline@4.0.0: + resolution: {integrity: sha512-aulFJcD6YK8V1G7iRB5tigAP4TsHBZZrOV8pjV++zdUwmeV8uzbY7yn6h9MswN62adStNZFuCIx4haBnRuMDaw==} + engines: {node: '>=18'} + strip-indent@3.0.0: resolution: {integrity: sha512-laJTa3Jb+VQpaC6DseHhF7dXVqHTfJPCRDaEbid/drOhgitgYku/letMUqOXFoWV0zIIUbjpdH2t+tYj4bQMRQ==} engines: {node: '>=8'} @@ -12057,10 +12155,6 @@ packages: resolution: {integrity: sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg==} engines: {node: '>=14.0.0'} - titleize@3.0.0: - resolution: {integrity: sha512-KxVu8EYHDPBdUYdKZdKtU2aj2XfEx9AfjXxE/Aj0vT06w2icA09Vus1rh6eSu1y01akYg6BjIK/hxyLJINoMLQ==} - engines: {node: '>=12'} - tmp-promise@3.0.3: resolution: {integrity: sha512-RwM7MoPojPxsOBYnyd2hy0bxtIlVrihNs9pj5SUvY8Zz1sQcQG2tG1hSr8PDxfgEB8RNKDhqbIlroIarSNDNsQ==} @@ -12430,10 +12524,6 @@ packages: resolution: {integrity: sha512-PcA2tsuGSF9cnySLHTLSh2qrQiJ70mn+r+Glzxv2TWZblxsxCC52BDlZoPCsz7STd9pN7EZetkWZBAvk4cgZdQ==} engines: {node: '>=0.10.0'} - untildify@4.0.0: - resolution: {integrity: sha512-KK8xQ1mkzZeg9inewmFVDNkg3l5LUhoq9kN6iWYB/CC9YMG8HA+c1Q8HwDe6dEX7kErrEVNVBO3fWsVq5iDgtw==} - engines: {node: '>=8'} - update-browserslist-db@1.0.13: resolution: {integrity: sha512-xebP81SNcPuNpPP3uzeW1NYXxI3rxyJzF3pD6sH4jE7o/IX+WtSpwnVU+qIsDPyk0d3hmFQ7mjqc6AtV604hbg==} hasBin: true @@ -12984,6 +13074,10 @@ packages: resolution: {integrity: sha512-9bnSc/HEW2uRy67wc+T8UwauLuPJVn28jb+GtJY16iiKWyvmYJRXVT4UamsAEGQfPohgr2q4Tq0sQbQlxTfi1g==} engines: {node: '>=12.20'} + yoctocolors@2.1.1: + resolution: {integrity: sha512-GQHQqAopRhwU8Kt1DDM8NjibDXHC8eoh1erhGAJPEyveY9qqVeXvVikNKrDz69sHowPMorbPUrH/mx8c50eiBQ==} + engines: {node: '>=18'} + zod-validation-error@3.3.0: resolution: {integrity: sha512-Syib9oumw1NTqEv4LT0e6U83Td9aVRk9iTXPUQr1otyV1PuXQKOvOwhMNqZIq5hluzHP2pMgnOmHEo7kPdI2mw==} engines: {node: '>=18.0.0'} @@ -13331,7 +13425,7 @@ snapshots: '@babel/traverse': 7.24.1 '@babel/types': 7.24.0 convert-source-map: 2.0.0 - debug: 4.3.4 + debug: 4.3.5 gensync: 1.0.0-beta.2 json5: 2.2.3 semver: 6.3.1 @@ -13403,7 +13497,7 @@ snapshots: '@babel/core': 7.24.3 '@babel/helper-compilation-targets': 7.23.6 '@babel/helper-plugin-utils': 7.24.0 - debug: 4.3.4 + debug: 4.3.5 lodash.debounce: 4.0.8 resolve: 1.22.8 transitivePeerDependencies: @@ -13772,7 +13866,7 @@ snapshots: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.24.1 '@babel/types': 7.24.0 - debug: 4.3.4 + debug: 4.3.5 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -13787,7 +13881,7 @@ snapshots: '@babel/helper-split-export-declaration': 7.22.6 '@babel/parser': 7.24.1 '@babel/types': 7.24.0 - debug: 4.3.4 + debug: 4.3.5 globals: 11.12.0 transitivePeerDependencies: - supports-color @@ -14453,7 +14547,7 @@ snapshots: '@electron/get': 3.0.0 chalk: 4.1.2 commander: 4.1.1 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 listr2: 7.0.2 semver: 7.5.4 @@ -14468,7 +14562,7 @@ snapshots: '@electron/rebuild': 3.6.0 '@malept/cross-spawn-promise': 2.0.0 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 find-up: 5.0.0 fs-extra: 10.1.0 log-symbols: 4.1.0 @@ -14496,7 +14590,7 @@ snapshots: '@electron/rebuild': 3.6.0 '@malept/cross-spawn-promise': 2.0.0 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 fast-glob: 3.3.2 filenamify: 4.3.0 find-up: 5.0.0 @@ -14599,7 +14693,7 @@ snapshots: dependencies: '@electron-forge/shared-types': 7.4.0 '@malept/cross-spawn-promise': 2.0.0 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 username: 5.1.0 transitivePeerDependencies: @@ -14654,7 +14748,7 @@ snapshots: '@electron/get@2.0.3': dependencies: - debug: 4.3.4 + debug: 4.3.5 env-paths: 2.2.1 fs-extra: 8.1.0 got: 11.8.6 @@ -14668,7 +14762,7 @@ snapshots: '@electron/get@3.0.0': dependencies: - debug: 4.3.4 + debug: 4.3.5 env-paths: 2.2.1 fs-extra: 8.1.0 got: 11.8.6 @@ -14682,7 +14776,7 @@ snapshots: '@electron/notarize@2.2.1': dependencies: - debug: 4.3.4 + debug: 4.3.5 fs-extra: 9.1.0 promise-retry: 2.0.1 transitivePeerDependencies: @@ -14690,7 +14784,7 @@ snapshots: '@electron/notarize@2.3.2': dependencies: - debug: 4.3.4 + debug: 4.3.5 fs-extra: 9.1.0 promise-retry: 2.0.1 transitivePeerDependencies: @@ -14699,7 +14793,7 @@ snapshots: '@electron/osx-sign@1.0.5': dependencies: compare-version: 0.1.2 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 isbinaryfile: 4.0.10 minimist: 1.2.8 @@ -14710,7 +14804,7 @@ snapshots: '@electron/osx-sign@1.3.0': dependencies: compare-version: 0.1.2 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 isbinaryfile: 4.0.10 minimist: 1.2.8 @@ -14726,7 +14820,7 @@ snapshots: '@electron/osx-sign': 1.3.0 '@electron/universal': 2.0.1 '@electron/windows-sign': 1.1.2 - debug: 4.3.4 + debug: 4.3.5 extract-zip: 2.0.1 filenamify: 4.3.0 fs-extra: 11.2.0 @@ -14746,7 +14840,7 @@ snapshots: dependencies: '@malept/cross-spawn-promise': 2.0.0 chalk: 4.1.2 - debug: 4.3.4 + debug: 4.3.5 detect-libc: 2.0.3 fs-extra: 10.1.0 got: 11.8.6 @@ -14766,7 +14860,7 @@ snapshots: dependencies: '@electron/asar': 3.2.10 '@malept/cross-spawn-promise': 1.1.1 - debug: 4.3.4 + debug: 4.3.5 dir-compare: 3.3.0 fs-extra: 9.1.0 minimatch: 3.1.2 @@ -14778,7 +14872,7 @@ snapshots: dependencies: '@electron/asar': 3.2.10 '@malept/cross-spawn-promise': 2.0.0 - debug: 4.3.4 + debug: 4.3.5 dir-compare: 4.2.0 fs-extra: 11.2.0 minimatch: 9.0.5 @@ -14789,7 +14883,7 @@ snapshots: '@electron/windows-sign@1.1.2': dependencies: cross-dirname: 0.1.0 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 11.2.0 minimist: 1.2.8 postject: 1.0.0-alpha.6 @@ -14943,7 +15037,7 @@ snapshots: '@eslint/eslintrc@2.1.4': dependencies: ajv: 6.12.6 - debug: 4.3.4 + debug: 4.3.5 espree: 9.6.1 globals: 13.24.0 ignore: 5.2.4 @@ -15035,7 +15129,7 @@ snapshots: '@humanwhocodes/config-array@0.11.14': dependencies: '@humanwhocodes/object-schema': 2.0.3 - debug: 4.3.4 + debug: 4.3.5 minimatch: 3.1.2 transitivePeerDependencies: - supports-color @@ -15306,7 +15400,7 @@ snapshots: '@malept/flatpak-bundler@0.4.0': dependencies: - debug: 4.3.4 + debug: 4.3.5 fs-extra: 9.1.0 lodash: 4.17.21 tmp-promise: 3.0.3 @@ -15605,6 +15699,8 @@ snapshots: '@rollup/rollup-win32-x64-msvc@4.14.1': optional: true + '@sec-ant/readable-stream@0.4.1': {} + '@simonwep/pickr@1.8.2': dependencies: core-js: 3.36.1 @@ -15616,6 +15712,8 @@ snapshots: '@sindresorhus/is@4.6.0': {} + '@sindresorhus/merge-streams@4.0.0': {} + '@sinonjs/commons@3.0.1': dependencies: type-detect: 4.0.8 @@ -15631,7 +15729,7 @@ snapshots: '@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1))': dependencies: '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1)) - debug: 4.3.4 + debug: 4.3.5 svelte: 4.0.0 vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: @@ -16629,7 +16727,7 @@ snapshots: '@types/body-parser@1.19.4': dependencies: - '@types/connect': 3.4.37 + '@types/connect': 3.4.38 '@types/node': 18.18.8 '@types/cacheable-request@6.0.3': @@ -16643,7 +16741,7 @@ snapshots: dependencies: clipboard: 2.0.11 - '@types/connect@3.4.37': + '@types/connect@3.4.38': dependencies: '@types/node': 18.18.8 @@ -16653,7 +16751,7 @@ snapshots: '@types/cookies@0.7.9': dependencies: - '@types/connect': 3.4.37 + '@types/connect': 3.4.38 '@types/express': 4.17.21 '@types/keygrip': 1.0.4 '@types/node': 18.18.8 @@ -17021,7 +17119,7 @@ snapshots: dependencies: '@typescript-eslint/typescript-estree': 6.21.0(typescript@5.4.5) '@typescript-eslint/utils': 6.21.0(eslint@8.57.0)(typescript@5.4.5) - debug: 4.3.4 + debug: 4.3.5 eslint: 8.57.0 ts-api-utils: 1.3.0(typescript@5.4.5) optionalDependencies: @@ -17035,7 +17133,7 @@ snapshots: dependencies: '@typescript-eslint/types': 6.21.0 '@typescript-eslint/visitor-keys': 6.21.0 - debug: 4.3.4 + debug: 4.3.5 globby: 11.1.0 is-glob: 4.0.3 minimatch: 9.0.3 @@ -17810,7 +17908,7 @@ snapshots: agent-base@6.0.2: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -18050,7 +18148,7 @@ snapshots: builder-util: 24.13.1 builder-util-runtime: 9.2.4 chromium-pickle-js: 0.2.0 - debug: 4.3.4 + debug: 4.3.5 dmg-builder: 24.13.3 ejs: 3.1.10 electron-publish: 24.13.1 @@ -18239,7 +18337,7 @@ snapshots: axios@1.6.5: dependencies: - follow-redirects: 1.15.4(debug@4.3.4) + follow-redirects: 1.15.4 form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -18247,7 +18345,7 @@ snapshots: axios@1.7.2: dependencies: - follow-redirects: 1.15.6 + follow-redirects: 1.15.6(debug@4.3.5) form-data: 4.0.0 proxy-from-env: 1.1.0 transitivePeerDependencies: @@ -18393,8 +18491,6 @@ snapshots: dependencies: is-windows: 1.0.2 - big-integer@1.6.51: {} - big.js@5.2.2: {} binary-extensions@2.2.0: {} @@ -18484,10 +18580,6 @@ snapshots: widest-line: 4.0.1 wrap-ansi: 8.1.0 - bplist-parser@0.2.0: - dependencies: - big-integer: 1.6.51 - brace-expansion@1.1.11: dependencies: balanced-match: 1.0.2 @@ -18561,7 +18653,7 @@ snapshots: builder-util-runtime@9.2.4: dependencies: - debug: 4.3.4 + debug: 4.3.5 sax: 1.3.0 transitivePeerDependencies: - supports-color @@ -18575,7 +18667,7 @@ snapshots: builder-util-runtime: 9.2.4 chalk: 4.1.2 cross-spawn: 7.0.3 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 http-proxy-agent: 5.0.0 https-proxy-agent: 5.0.1 @@ -18587,9 +18679,9 @@ snapshots: transitivePeerDependencies: - supports-color - bundle-name@3.0.0: + bundle-name@4.1.0: dependencies: - run-applescript: 5.0.0 + run-applescript: 7.0.0 busboy@1.6.0: dependencies: @@ -19033,6 +19125,15 @@ snapshots: write-file-atomic: 3.0.3 xdg-basedir: 4.0.0 + connect@3.7.0: + dependencies: + debug: 2.6.9 + finalhandler: 1.1.2 + parseurl: 1.3.3 + utils-merge: 1.0.1 + transitivePeerDependencies: + - supports-color + consola@2.15.3: {} console-control-strings@1.1.0: {} @@ -19452,6 +19553,10 @@ snapshots: dependencies: ms: 2.1.2 + debug@4.3.5: + dependencies: + ms: 2.1.2 + decamelize-keys@1.1.1: dependencies: decamelize: 1.2.0 @@ -19513,17 +19618,12 @@ snapshots: deepmerge@4.3.1: {} - default-browser-id@3.0.0: - dependencies: - bplist-parser: 0.2.0 - untildify: 4.0.0 + default-browser-id@5.0.0: {} - default-browser@4.0.0: + default-browser@5.2.1: dependencies: - bundle-name: 3.0.0 - default-browser-id: 3.0.0 - execa: 7.2.0 - titleize: 3.0.0 + bundle-name: 4.1.0 + default-browser-id: 5.0.0 defaults@1.0.4: dependencies: @@ -19745,7 +19845,7 @@ snapshots: dependencies: '@malept/cross-spawn-promise': 1.1.1 asar: 3.2.0 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 9.1.0 glob: 7.2.3 lodash: 4.17.21 @@ -19761,7 +19861,7 @@ snapshots: electron-installer-debian@3.2.0: dependencies: '@malept/cross-spawn-promise': 1.1.1 - debug: 4.3.4 + debug: 4.3.5 electron-installer-common: 0.10.3 fs-extra: 9.1.0 get-folder-size: 2.0.1 @@ -19775,7 +19875,7 @@ snapshots: electron-installer-redhat@3.4.0: dependencies: '@malept/cross-spawn-promise': 1.1.1 - debug: 4.3.4 + debug: 4.3.5 electron-installer-common: 0.10.3 fs-extra: 9.1.0 lodash: 4.17.21 @@ -19804,7 +19904,7 @@ snapshots: electron-winstaller@5.3.1: dependencies: '@electron/asar': 3.2.10 - debug: 4.3.4 + debug: 4.3.5 fs-extra: 7.0.1 lodash: 4.17.21 temp: 0.9.4 @@ -20175,6 +20275,21 @@ snapshots: signal-exit: 4.1.0 strip-final-newline: 3.0.0 + execa@9.3.0: + dependencies: + '@sindresorhus/merge-streams': 4.0.0 + cross-spawn: 7.0.3 + figures: 6.1.0 + get-stream: 9.0.1 + human-signals: 7.0.0 + is-plain-obj: 4.1.0 + is-stream: 4.0.1 + npm-run-path: 5.3.0 + pretty-ms: 9.0.0 + signal-exit: 4.1.0 + strip-final-newline: 4.0.0 + yoctocolors: 2.1.1 + exit-on-epipe@1.0.1: {} exit@0.1.2: {} @@ -20320,7 +20435,7 @@ snapshots: extract-zip@2.0.1: dependencies: - debug: 4.3.4 + debug: 4.3.5 get-stream: 5.2.0 yauzl: 2.10.0 optionalDependencies: @@ -20495,6 +20610,10 @@ snapshots: escape-string-regexp: 5.0.0 is-unicode-supported: 1.3.0 + figures@6.1.0: + dependencies: + is-unicode-supported: 2.0.0 + file-entry-cache@6.0.1: dependencies: flat-cache: 3.1.1 @@ -20524,6 +20643,18 @@ snapshots: filter-obj@1.1.0: {} + finalhandler@1.1.2: + dependencies: + debug: 2.6.9 + encodeurl: 1.0.2 + escape-html: 1.0.3 + on-finished: 2.3.0 + parseurl: 1.3.3 + statuses: 1.5.0 + unpipe: 1.0.0 + transitivePeerDependencies: + - supports-color + finalhandler@1.2.0: dependencies: debug: 2.6.9 @@ -20567,7 +20698,7 @@ snapshots: flora-colossus@2.0.0: dependencies: - debug: 4.3.4 + debug: 4.3.5 fs-extra: 10.1.0 transitivePeerDependencies: - supports-color @@ -20586,11 +20717,11 @@ snapshots: follow-redirects@1.15.3: {} - follow-redirects@1.15.4(debug@4.3.4): - optionalDependencies: - debug: 4.3.4 + follow-redirects@1.15.4: {} - follow-redirects@1.15.6: {} + follow-redirects@1.15.6(debug@4.3.5): + optionalDependencies: + debug: 4.3.5 for-each@0.3.3: dependencies: @@ -20706,7 +20837,7 @@ snapshots: galactus@1.0.0: dependencies: - debug: 4.3.4 + debug: 4.3.5 flora-colossus: 2.0.0 fs-extra: 10.1.0 transitivePeerDependencies: @@ -20789,6 +20920,11 @@ snapshots: get-stream@8.0.1: {} + get-stream@9.0.1: + dependencies: + '@sec-ant/readable-stream': 0.4.1 + is-stream: 4.0.1 + get-symbol-description@1.0.0: dependencies: call-bind: 1.0.7 @@ -21082,25 +21218,25 @@ snapshots: dependencies: '@tootallnate/once': 2.0.0 agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color http-proxy-middleware@3.0.0: dependencies: '@types/http-proxy': 1.17.14 - debug: 4.3.4 - http-proxy: 1.18.1(debug@4.3.4) + debug: 4.3.5 + http-proxy: 1.18.1(debug@4.3.5) is-glob: 4.0.3 is-plain-obj: 3.0.0 micromatch: 4.0.5 transitivePeerDependencies: - supports-color - http-proxy@1.18.1(debug@4.3.4): + http-proxy@1.18.1(debug@4.3.5): dependencies: eventemitter3: 4.0.7 - follow-redirects: 1.15.4(debug@4.3.4) + follow-redirects: 1.15.6(debug@4.3.5) requires-port: 1.0.0 transitivePeerDependencies: - debug @@ -21113,7 +21249,7 @@ snapshots: https-proxy-agent@5.0.1: dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -21125,6 +21261,8 @@ snapshots: human-signals@5.0.0: {} + human-signals@7.0.0: {} + humanize-ms@1.2.1: dependencies: ms: 2.1.3 @@ -21393,6 +21531,8 @@ snapshots: is-plain-obj@3.0.0: {} + is-plain-obj@4.1.0: {} + is-plain-object@2.0.4: dependencies: isobject: 3.0.1 @@ -21424,6 +21564,8 @@ snapshots: is-stream@3.0.0: {} + is-stream@4.0.1: {} + is-string@1.0.7: dependencies: has-tostringtag: 1.0.0 @@ -21450,6 +21592,8 @@ snapshots: is-unicode-supported@1.3.0: {} + is-unicode-supported@2.0.0: {} + is-weakmap@2.0.2: {} is-weakref@1.0.2: @@ -21471,6 +21615,10 @@ snapshots: dependencies: is-docker: 2.2.1 + is-wsl@3.1.0: + dependencies: + is-inside-container: 1.0.0 + isarray@0.0.1: {} isarray@1.0.0: {} @@ -21521,7 +21669,7 @@ snapshots: istanbul-lib-source-maps@4.0.1: dependencies: - debug: 4.3.4 + debug: 4.3.5 istanbul-lib-coverage: 3.2.0 source-map: 0.6.1 transitivePeerDependencies: @@ -22016,7 +22164,7 @@ snapshots: koa-send@5.0.1: dependencies: - debug: 4.3.4 + debug: 4.3.5 http-errors: 1.8.1 resolve-path: 1.4.0 transitivePeerDependencies: @@ -22751,6 +22899,10 @@ snapshots: dependencies: path-key: 4.0.0 + npm-run-path@5.3.0: + dependencies: + path-key: 4.0.0 + npmlog@6.0.2: dependencies: are-we-there-yet: 3.0.1 @@ -22804,6 +22956,10 @@ snapshots: dependencies: isobject: 3.0.1 + on-finished@2.3.0: + dependencies: + ee-first: 1.1.1 + on-finished@2.4.1: dependencies: ee-first: 1.1.1 @@ -22828,12 +22984,12 @@ snapshots: only@0.0.2: {} - open@9.1.0: + open@10.1.0: dependencies: - default-browser: 4.0.0 + default-browser: 5.2.1 define-lazy-prop: 3.0.0 is-inside-container: 1.0.0 - is-wsl: 2.2.0 + is-wsl: 3.1.0 opencollective-postinstall@2.0.3: {} @@ -22955,6 +23111,8 @@ snapshots: json-parse-even-better-errors: 2.3.1 lines-and-columns: 1.2.4 + parse-ms@4.0.0: {} + parse-node-version@1.0.1: {} parse-passwd@1.0.0: {} @@ -23268,6 +23426,10 @@ snapshots: ansi-styles: 5.2.0 react-is: 18.2.0 + pretty-ms@9.0.0: + dependencies: + parse-ms: 4.0.0 + primevue@3.52.0(vue@3.3.12(typescript@5.4.5)): dependencies: vue: 3.3.12(typescript@5.4.5) @@ -23875,7 +24037,7 @@ snapshots: read-binary-file-arch@1.0.6: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -24149,9 +24311,7 @@ snapshots: '@rollup/rollup-win32-x64-msvc': 4.14.1 fsevents: 2.3.3 - run-applescript@5.0.0: - dependencies: - execa: 5.1.1 + run-applescript@7.0.0: {} run-async@2.4.1: {} @@ -24570,7 +24730,7 @@ snapshots: socks-proxy-agent@7.0.0: dependencies: agent-base: 6.0.2 - debug: 4.3.4 + debug: 4.3.5 socks: 2.8.3 transitivePeerDependencies: - supports-color @@ -24804,6 +24964,8 @@ snapshots: strip-final-newline@3.0.0: {} + strip-final-newline@4.0.0: {} + strip-indent@3.0.0: dependencies: min-indent: 1.0.1 @@ -24842,7 +25004,7 @@ snapshots: sumchecker@3.0.1: dependencies: - debug: 4.3.4 + debug: 4.3.5 transitivePeerDependencies: - supports-color @@ -24850,7 +25012,7 @@ snapshots: dependencies: component-emitter: 1.3.1 cookiejar: 2.1.4 - debug: 4.3.4 + debug: 4.3.5 fast-safe-stringify: 2.1.1 form-data: 4.0.0 formidable: 2.1.2 @@ -25204,8 +25366,6 @@ snapshots: tinyspy@2.2.0: {} - titleize@3.0.0: {} - tmp-promise@3.0.3: dependencies: tmp: 0.2.3 @@ -25639,8 +25799,6 @@ snapshots: has-value: 0.3.1 isobject: 3.0.1 - untildify@4.0.0: {} - update-browserslist-db@1.0.13(browserslist@4.22.1): dependencies: browserslist: 4.22.1 @@ -25729,7 +25887,7 @@ snapshots: vite-node@1.4.0(@types/node@18.18.8)(less@4.2.0)(sass@1.74.1)(terser@5.31.1): dependencies: cac: 6.7.14 - debug: 4.3.4 + debug: 4.3.5 pathe: 1.1.1 picocolors: 1.0.0 vite: 5.2.8(@types/node@18.18.8)(less@4.2.0)(sass@1.74.1)(terser@5.31.1) @@ -25746,7 +25904,7 @@ snapshots: vite-node@1.4.0(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1): dependencies: cac: 6.7.14 - debug: 4.3.4 + debug: 4.3.5 pathe: 1.1.1 picocolors: 1.0.0 vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1) @@ -26066,7 +26224,7 @@ snapshots: '@vitest/utils': 1.4.0 acorn-walk: 8.3.2 chai: 4.3.10 - debug: 4.3.4 + debug: 4.3.5 execa: 8.0.1 local-pkg: 0.5.0 magic-string: 0.30.5 @@ -26511,6 +26669,8 @@ snapshots: yocto-queue@1.0.0: {} + yoctocolors@2.1.1: {} + zod-validation-error@3.3.0(zod@3.23.8): dependencies: zod: 3.23.8 From 9e03be5984ef0ce4c0e2ca0774873efd49b360e4 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Fri, 19 Jul 2024 16:54:57 +0800 Subject: [PATCH 2/9] chore: update ws type --- packages/core/src/types/ws.ts | 559 ++++++++++++++++++++++++++++++++++ 1 file changed, 559 insertions(+) create mode 100644 packages/core/src/types/ws.ts diff --git a/packages/core/src/types/ws.ts b/packages/core/src/types/ws.ts new file mode 100644 index 0000000000..f03298cd9b --- /dev/null +++ b/packages/core/src/types/ws.ts @@ -0,0 +1,559 @@ +// Modified and inlined to avoid extra dependency +// Source: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/ws/index.d.ts + +// Type definitions for ws 8.5 +// Project: https://github.com/websockets/ws +// Definitions by: Paul Loyd +// Margus Lamp +// Philippe D'Alva +// reduckted +// teidesu +// Bartosz Wojtkowiak +// Kyle Hensel +// Samuel Skeen +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import { EventEmitter } from 'node:events'; +import type { + Agent, + ClientRequest, + ClientRequestArgs, + Server as HTTPServer, + IncomingMessage, + OutgoingHttpHeaders +} from 'node:http'; +import type { Server as HTTPSServer } from 'node:https'; +import type { Duplex, DuplexOptions } from 'node:stream'; +import type { SecureContextOptions } from 'node:tls'; +import type { URL } from 'node:url'; +import type { ZlibOptions } from 'node:zlib'; + +// WebSocket socket. +declare class WebSocket extends EventEmitter { + /** The connection is not yet open. */ + static readonly CONNECTING: 0; + /** The connection is open and ready to communicate. */ + static readonly OPEN: 1; + /** The connection is in the process of closing. */ + static readonly CLOSING: 2; + /** The connection is closed. */ + static readonly CLOSED: 3; + + binaryType: 'nodebuffer' | 'arraybuffer' | 'fragments'; + readonly bufferedAmount: number; + readonly extensions: string; + /** Indicates whether the websocket is paused */ + readonly isPaused: boolean; + readonly protocol: string; + /** The current state of the connection */ + readonly readyState: + | typeof WebSocket.CONNECTING + | typeof WebSocket.OPEN + | typeof WebSocket.CLOSING + | typeof WebSocket.CLOSED; + readonly url: string; + + /** The connection is not yet open. */ + readonly CONNECTING: 0; + /** The connection is open and ready to communicate. */ + readonly OPEN: 1; + /** The connection is in the process of closing. */ + readonly CLOSING: 2; + /** The connection is closed. */ + readonly CLOSED: 3; + + onopen: ((event: WebSocket.Event) => void) | null; + onerror: ((event: WebSocket.ErrorEvent) => void) | null; + onclose: ((event: WebSocket.CloseEvent) => void) | null; + onmessage: ((event: WebSocket.MessageEvent) => void) | null; + + constructor(address: null); + constructor( + address: string | URL, + options?: WebSocket.ClientOptions | ClientRequestArgs + ); + constructor( + address: string | URL, + protocols?: string | string[], + options?: WebSocket.ClientOptions | ClientRequestArgs + ); + + close(code?: number, data?: string | Buffer): void; + ping(data?: any, mask?: boolean, cb?: (err: Error) => void): void; + pong(data?: any, mask?: boolean, cb?: (err: Error) => void): void; + send(data: any, cb?: (err?: Error) => void): void; + send( + data: any, + options: { + mask?: boolean | undefined; + binary?: boolean | undefined; + compress?: boolean | undefined; + fin?: boolean | undefined; + }, + cb?: (err?: Error) => void + ): void; + terminate(): void; + + /** + * Pause the websocket causing it to stop emitting events. Some events can still be + * emitted after this is called, until all buffered data is consumed. This method + * is a noop if the ready state is `CONNECTING` or `CLOSED`. + */ + pause(): void; + /** + * Make a paused socket resume emitting events. This method is a noop if the ready + * state is `CONNECTING` or `CLOSED`. + */ + resume(): void; + + // HTML5 WebSocket events + addEventListener( + method: 'message', + cb: (event: WebSocket.MessageEvent) => void, + options?: WebSocket.EventListenerOptions + ): void; + addEventListener( + method: 'close', + cb: (event: WebSocket.CloseEvent) => void, + options?: WebSocket.EventListenerOptions + ): void; + addEventListener( + method: 'error', + cb: (event: WebSocket.ErrorEvent) => void, + options?: WebSocket.EventListenerOptions + ): void; + addEventListener( + method: 'open', + cb: (event: WebSocket.Event) => void, + options?: WebSocket.EventListenerOptions + ): void; + + removeEventListener( + method: 'message', + cb: (event: WebSocket.MessageEvent) => void + ): void; + removeEventListener( + method: 'close', + cb: (event: WebSocket.CloseEvent) => void + ): void; + removeEventListener( + method: 'error', + cb: (event: WebSocket.ErrorEvent) => void + ): void; + removeEventListener( + method: 'open', + cb: (event: WebSocket.Event) => void + ): void; + + // Events + on( + event: 'close', + listener: (this: WebSocket, code: number, reason: Buffer) => void + ): this; + on(event: 'error', listener: (this: WebSocket, err: Error) => void): this; + on( + event: 'upgrade', + listener: (this: WebSocket, request: IncomingMessage) => void + ): this; + on( + event: 'message', + listener: ( + this: WebSocket, + data: WebSocket.RawData, + isBinary: boolean + ) => void + ): this; + on(event: 'open', listener: (this: WebSocket) => void): this; + on( + event: 'ping' | 'pong', + listener: (this: WebSocket, data: Buffer) => void + ): this; + on( + event: 'unexpected-response', + listener: ( + this: WebSocket, + request: ClientRequest, + response: IncomingMessage + ) => void + ): this; + on( + event: string | symbol, + listener: (this: WebSocket, ...args: any[]) => void + ): this; + + once( + event: 'close', + listener: (this: WebSocket, code: number, reason: Buffer) => void + ): this; + once(event: 'error', listener: (this: WebSocket, err: Error) => void): this; + once( + event: 'upgrade', + listener: (this: WebSocket, request: IncomingMessage) => void + ): this; + once( + event: 'message', + listener: ( + this: WebSocket, + data: WebSocket.RawData, + isBinary: boolean + ) => void + ): this; + once(event: 'open', listener: (this: WebSocket) => void): this; + once( + event: 'ping' | 'pong', + listener: (this: WebSocket, data: Buffer) => void + ): this; + once( + event: 'unexpected-response', + listener: ( + this: WebSocket, + request: ClientRequest, + response: IncomingMessage + ) => void + ): this; + once( + event: string | symbol, + listener: (this: WebSocket, ...args: any[]) => void + ): this; + + off( + event: 'close', + listener: (this: WebSocket, code: number, reason: Buffer) => void + ): this; + off(event: 'error', listener: (this: WebSocket, err: Error) => void): this; + off( + event: 'upgrade', + listener: (this: WebSocket, request: IncomingMessage) => void + ): this; + off( + event: 'message', + listener: ( + this: WebSocket, + data: WebSocket.RawData, + isBinary: boolean + ) => void + ): this; + off(event: 'open', listener: (this: WebSocket) => void): this; + off( + event: 'ping' | 'pong', + listener: (this: WebSocket, data: Buffer) => void + ): this; + off( + event: 'unexpected-response', + listener: ( + this: WebSocket, + request: ClientRequest, + response: IncomingMessage + ) => void + ): this; + off( + event: string | symbol, + listener: (this: WebSocket, ...args: any[]) => void + ): this; + + addListener( + event: 'close', + listener: (code: number, reason: Buffer) => void + ): this; + addListener(event: 'error', listener: (err: Error) => void): this; + addListener( + event: 'upgrade', + listener: (request: IncomingMessage) => void + ): this; + addListener( + event: 'message', + listener: (data: WebSocket.RawData, isBinary: boolean) => void + ): this; + addListener(event: 'open', listener: () => void): this; + addListener(event: 'ping' | 'pong', listener: (data: Buffer) => void): this; + addListener( + event: 'unexpected-response', + listener: (request: ClientRequest, response: IncomingMessage) => void + ): this; + addListener(event: string | symbol, listener: (...args: any[]) => void): this; + + removeListener( + event: 'close', + listener: (code: number, reason: Buffer) => void + ): this; + removeListener(event: 'error', listener: (err: Error) => void): this; + removeListener( + event: 'upgrade', + listener: (request: IncomingMessage) => void + ): this; + removeListener( + event: 'message', + listener: (data: WebSocket.RawData, isBinary: boolean) => void + ): this; + removeListener(event: 'open', listener: () => void): this; + removeListener( + event: 'ping' | 'pong', + listener: (data: Buffer) => void + ): this; + removeListener( + event: 'unexpected-response', + listener: (request: ClientRequest, response: IncomingMessage) => void + ): this; + removeListener( + event: string | symbol, + listener: (...args: any[]) => void + ): this; +} + +declare const WebSocketAlias: typeof WebSocket; +// @ts-ignore +interface WebSocketAlias extends WebSocket {} // tslint:disable-line no-empty-interface + +// @ts-ignore +// biome-ignore lint/style/noNamespace: +declare namespace WebSocket { + /** + * Data represents the raw message payload received over the WebSocket. + */ + type RawData = Buffer | ArrayBuffer | Buffer[]; + + /** + * Data represents the message payload received over the WebSocket. + */ + type Data = string | Buffer | ArrayBuffer | Buffer[]; + + /** + * CertMeta represents the accepted types for certificate & key data. + */ + type CertMeta = string | string[] | Buffer | Buffer[]; + + /** + * VerifyClientCallbackSync is a synchronous callback used to inspect the + * incoming message. The return value (boolean) of the function determines + * whether or not to accept the handshake. + */ + type VerifyClientCallbackSync = (info: { + origin: string; + secure: boolean; + req: IncomingMessage; + }) => boolean; + + /** + * VerifyClientCallbackAsync is an asynchronous callback used to inspect the + * incoming message. The return value (boolean) of the function determines + * whether or not to accept the handshake. + */ + type VerifyClientCallbackAsync = ( + info: { origin: string; secure: boolean; req: IncomingMessage }, + callback: ( + res: boolean, + code?: number, + message?: string, + headers?: OutgoingHttpHeaders + ) => void + ) => void; + + interface ClientOptions extends SecureContextOptions { + protocol?: string | undefined; + followRedirects?: boolean | undefined; + generateMask?(mask: Buffer): void; + handshakeTimeout?: number | undefined; + maxRedirects?: number | undefined; + perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined; + localAddress?: string | undefined; + protocolVersion?: number | undefined; + headers?: { [key: string]: string } | undefined; + origin?: string | undefined; + agent?: Agent | undefined; + host?: string | undefined; + family?: number | undefined; + checkServerIdentity?(servername: string, cert: CertMeta): boolean; + rejectUnauthorized?: boolean | undefined; + maxPayload?: number | undefined; + skipUTF8Validation?: boolean | undefined; + } + + interface PerMessageDeflateOptions { + serverNoContextTakeover?: boolean | undefined; + clientNoContextTakeover?: boolean | undefined; + serverMaxWindowBits?: number | undefined; + clientMaxWindowBits?: number | undefined; + zlibDeflateOptions?: + | { + flush?: number | undefined; + finishFlush?: number | undefined; + chunkSize?: number | undefined; + windowBits?: number | undefined; + level?: number | undefined; + memLevel?: number | undefined; + strategy?: number | undefined; + dictionary?: Buffer | Buffer[] | DataView | undefined; + info?: boolean | undefined; + } + | undefined; + zlibInflateOptions?: ZlibOptions | undefined; + threshold?: number | undefined; + concurrencyLimit?: number | undefined; + } + + interface Event { + type: string; + target: WebSocket; + } + + interface ErrorEvent { + error: any; + message: string; + type: string; + target: WebSocket; + } + + interface CloseEvent { + wasClean: boolean; + code: number; + reason: string; + type: string; + target: WebSocket; + } + + interface MessageEvent { + data: Data; + type: string; + target: WebSocket; + } + + interface EventListenerOptions { + once?: boolean | undefined; + } + + interface ServerOptions { + host?: string | undefined; + port?: number | undefined; + backlog?: number | undefined; + server?: HTTPServer | HTTPSServer | undefined; + verifyClient?: + | VerifyClientCallbackAsync + | VerifyClientCallbackSync + | undefined; + handleProtocols?: ( + protocols: Set, + request: IncomingMessage + ) => string | false; + path?: string | undefined; + noServer?: boolean | undefined; + clientTracking?: boolean | undefined; + perMessageDeflate?: boolean | PerMessageDeflateOptions | undefined; + maxPayload?: number | undefined; + skipUTF8Validation?: boolean | undefined; + WebSocket?: typeof WebSocket.WebSocket | undefined; + } + + interface AddressInfo { + address: string; + family: string; + port: number; + } + + // WebSocket Server + class Server extends EventEmitter { + options: ServerOptions; + path: string; + clients: Set; + + constructor(options?: ServerOptions, callback?: () => void); + + address(): AddressInfo | string; + close(cb?: (err?: Error) => void): void; + handleUpgrade( + request: IncomingMessage, + socket: Duplex, + upgradeHead: Buffer, + callback: (client: T, request: IncomingMessage) => void + ): void; + shouldHandle(request: IncomingMessage): boolean | Promise; + + // Events + on( + event: 'connection', + cb: (this: Server, socket: T, request: IncomingMessage) => void + ): this; + on(event: 'error', cb: (this: Server, error: Error) => void): this; + on( + event: 'headers', + cb: (this: Server, headers: string[], request: IncomingMessage) => void + ): this; + on(event: 'close' | 'listening', cb: (this: Server) => void): this; + on( + event: string | symbol, + listener: (this: Server, ...args: any[]) => void + ): this; + + once( + event: 'connection', + cb: (this: Server, socket: T, request: IncomingMessage) => void + ): this; + once(event: 'error', cb: (this: Server, error: Error) => void): this; + once( + event: 'headers', + cb: (this: Server, headers: string[], request: IncomingMessage) => void + ): this; + once(event: 'close' | 'listening', cb: (this: Server) => void): this; + once( + event: string | symbol, + listener: (this: Server, ...args: any[]) => void + ): this; + + off( + event: 'connection', + cb: (this: Server, socket: T, request: IncomingMessage) => void + ): this; + off(event: 'error', cb: (this: Server, error: Error) => void): this; + off( + event: 'headers', + cb: (this: Server, headers: string[], request: IncomingMessage) => void + ): this; + off(event: 'close' | 'listening', cb: (this: Server) => void): this; + off( + event: string | symbol, + listener: (this: Server, ...args: any[]) => void + ): this; + + addListener( + event: 'connection', + cb: (client: T, request: IncomingMessage) => void + ): this; + addListener(event: 'error', cb: (err: Error) => void): this; + addListener( + event: 'headers', + cb: (headers: string[], request: IncomingMessage) => void + ): this; + addListener(event: 'close' | 'listening', cb: () => void): this; + addListener( + event: string | symbol, + listener: (...args: any[]) => void + ): this; + + removeListener(event: 'connection', cb: (client: T) => void): this; + removeListener(event: 'error', cb: (err: Error) => void): this; + removeListener( + event: 'headers', + cb: (headers: string[], request: IncomingMessage) => void + ): this; + removeListener(event: 'close' | 'listening', cb: () => void): this; + removeListener( + event: string | symbol, + listener: (...args: any[]) => void + ): this; + } + + const WebSocketServer: typeof Server; + interface WebSocketServer extends Server {} // tslint:disable-line no-empty-interface + const WebSocket: typeof WebSocketAlias; + interface WebSocket extends WebSocketAlias {} // tslint:disable-line no-empty-interface + + // WebSocket stream + function createWebSocketStream( + websocket: WebSocket, + options?: DuplexOptions + ): Duplex; +} + +// export = WebSocket +export { WebSocket, WebSocketAlias }; From cdd5494ab28a38559546aa7f56c9551b22084d04 Mon Sep 17 00:00:00 2001 From: ADNY <66500121+ErKeLost@users.noreply.github.com> Date: Mon, 22 Jul 2024 17:49:09 +0800 Subject: [PATCH 3/9] chore: refactor cli (#1649) * chore: update cli * chore: test cli example * chore: update config * chore: update config * chore: update config * chore: finish cli code * chore: finish cli options * chore: update cspell --- cspell.json | 16 +- examples/refactor-react/.gitignore | 22 + examples/refactor-react/README.md | 37 ++ examples/refactor-react/farm.config.ts | 10 + examples/refactor-react/index.html | 14 + examples/refactor-react/package.json | 24 ++ examples/refactor-react/public/favicon.ico | Bin 0 -> 4154 bytes examples/refactor-react/src/assets/logo.png | Bin 0 -> 16859 bytes examples/refactor-react/src/assets/react.svg | 1 + examples/refactor-react/src/index.css | 69 +++ examples/refactor-react/src/index.tsx | 11 + examples/refactor-react/src/main.css | 42 ++ examples/refactor-react/src/main.tsx | 32 ++ examples/refactor-react/src/typings.d.ts | 3 + examples/refactor-react/tsconfig.json | 25 ++ examples/refactor-react/tsconfig.node.json | 11 + js-plugins/electron/src/index.ts | 6 +- packages/cli/src/config.ts | 40 -- packages/cli/src/index.ts | 276 +++++++----- packages/cli/src/types.ts | 18 +- packages/cli/src/utils.ts | 115 +---- packages/core/src/config/index.ts | 423 ++++++++++--------- packages/core/src/config/mergeConfig.ts | 81 ++-- packages/core/src/config/schema.ts | 6 +- packages/core/src/config/types.ts | 20 +- packages/core/src/index.ts | 82 +++- packages/core/src/utils/share.ts | 2 +- packages/core/tests/common.ts | 5 +- packages/core/tsconfig.build.json | 2 +- pnpm-lock.yaml | 138 +++++- 30 files changed, 997 insertions(+), 534 deletions(-) create mode 100644 examples/refactor-react/.gitignore create mode 100644 examples/refactor-react/README.md create mode 100644 examples/refactor-react/farm.config.ts create mode 100644 examples/refactor-react/index.html create mode 100644 examples/refactor-react/package.json create mode 100644 examples/refactor-react/public/favicon.ico create mode 100644 examples/refactor-react/src/assets/logo.png create mode 100644 examples/refactor-react/src/assets/react.svg create mode 100644 examples/refactor-react/src/index.css create mode 100644 examples/refactor-react/src/index.tsx create mode 100644 examples/refactor-react/src/main.css create mode 100644 examples/refactor-react/src/main.tsx create mode 100644 examples/refactor-react/src/typings.d.ts create mode 100644 examples/refactor-react/tsconfig.json create mode 100644 examples/refactor-react/tsconfig.node.json delete mode 100644 packages/cli/src/config.ts diff --git a/cspell.json b/cspell.json index 24cc0c7c4d..ad1648aaad 100644 --- a/cspell.json +++ b/cspell.json @@ -16,6 +16,7 @@ "Architecure", "arraify", "Avenir", + "Bartosz", "Basepath", "bindgen", "bpos", @@ -69,6 +70,7 @@ "guolao", "hashbrown", "hasher", + "Hensel", "icns", "idents", "IHDR", @@ -76,6 +78,7 @@ "importee", "Inctive", "indicatif", + "instanceof", "Instantiator", "jfif", "JIDA", @@ -91,6 +94,7 @@ "loglevel", "lukastaegert", "mapref", + "Margus", "mdsvex", "Menlo", "Mergeable", @@ -104,6 +108,7 @@ "nanospinner", "napi", "NAPI", + "nodebuffer", "Nonoctal", "normpath", "npmlog", @@ -133,6 +138,7 @@ "querify", "querystring", "Raspopov", + "reduckted", "replacen", "repr", "rfind", @@ -148,6 +154,7 @@ "shulan", "shulandmimi", "sirv", + "Skeen", "srcset", "struct", "styl", @@ -156,6 +163,7 @@ "svgr", "tailwindcss", "Tauri", + "teidesu", "Tencent", "thiserror", "threadsafe", @@ -181,13 +189,9 @@ "wasix", "wasmer", "wechat", + "Wojtkowiak", "xlink", - "Yuxi", - "wasmer", - "primevue", - "shulan", - "globset", - "instanceof" + "Yuxi" ], "ignorePaths": [ "pnpm-lock.yaml", diff --git a/examples/refactor-react/.gitignore b/examples/refactor-react/.gitignore new file mode 100644 index 0000000000..a4cf82d2cd --- /dev/null +++ b/examples/refactor-react/.gitignore @@ -0,0 +1,22 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +pnpm-debug.log* +lerna-debug.log* + +node_modules +dist +dist-ssr +*.local + +# Editor directories and files +.vscode/* +!.vscode/extensions.json +.idea +.DS_Store +*.suo +*.sln +*.sw? diff --git a/examples/refactor-react/README.md b/examples/refactor-react/README.md new file mode 100644 index 0000000000..5802e857f7 --- /dev/null +++ b/examples/refactor-react/README.md @@ -0,0 +1,37 @@ +# Farm + React + +This template should help you start developing using React and TypeScript in Farm. + +## Setup + +Install the dependencies: + +```bash +pnpm install +``` + +## Get Started + +Start the dev server: + +```bash +pnpm start +``` + +Build the app for production: + +```bash +pnpm build +``` + +Preview the Production build product: + +```bash +pnpm preview +``` + +Clear persistent cache local files + +```bash +pnpm clean +``` diff --git a/examples/refactor-react/farm.config.ts b/examples/refactor-react/farm.config.ts new file mode 100644 index 0000000000..6ab6a340c1 --- /dev/null +++ b/examples/refactor-react/farm.config.ts @@ -0,0 +1,10 @@ +import { defineConfig } from '@farmfe/core'; + +export default defineConfig({ + plugins: ['@farmfe/plugin-react'], + compilation: { + presetEnv: false, + progress: false, + sourcemap: false + } +}); diff --git a/examples/refactor-react/index.html b/examples/refactor-react/index.html new file mode 100644 index 0000000000..56d5a1bdb6 --- /dev/null +++ b/examples/refactor-react/index.html @@ -0,0 +1,14 @@ + + + + + + + + Farm + React + TS + + +
+ + + \ No newline at end of file diff --git a/examples/refactor-react/package.json b/examples/refactor-react/package.json new file mode 100644 index 0000000000..87544a4faf --- /dev/null +++ b/examples/refactor-react/package.json @@ -0,0 +1,24 @@ +{ + "name": "react-template", + "version": "1.0.0", + "scripts": { + "dev": "farm start", + "start": "farm start", + "build": "farm build", + "preview": "farm preview", + "clean": "farm clean" + }, + "dependencies": { + "react": "18", + "react-dom": "18" + }, + "devDependencies": { + "@farmfe/cli": "workspace:*", + "@farmfe/core": "workspace:*", + "@farmfe/plugin-react": "^1.2.0", + "@types/react": "18", + "core-js": "^3.36.1", + "@types/react-dom": "18", + "react-refresh": "^0.14.0" + } +} diff --git a/examples/refactor-react/public/favicon.ico b/examples/refactor-react/public/favicon.ico new file mode 100644 index 0000000000000000000000000000000000000000..80465dedc03cfd08b0e3b118db6e765f65e3adc3 GIT binary patch literal 4154 zcmb`~duWw)9LMqBoO)WB8>rdNSy794a8L80HKCYy;X53Ll~aB<(pZM`qE!25qV^T{4`B6-myS?o2hN82+<+U< zgU>Js#Y@ls0rgpHaWfVd>OhcuLiH?%JvX{-jp-L?TuqIfpde{Z+6RpMT(1M2a zNgW#BR8$vQhXMP8dvl>UUXQDxF|NSvPbf6_&zLFD zH5>=EtG%cFqj(pZ5A8>dbr{yJ+S~!fc|+tT()+LzipxT%okH!;)YStw?b>8VB6{p_in}7AeAdaJ^{r}^?eMB-Gk({ zrayu9w#~ow!{$co^?m3pP+TWG|G2Mpr`Uyk4031DEWT^Zs#|q!fzAf4HC z@HD383zV1%YP(h6O6-MVF$0><`LHpo%n?h&yyCS6;aV%P*?jSIU3mWM_tJK}3hkK- z(TTZGyGg9VBE;t=>{Gt7qs&mJ>d|=ip#xfr=c5gZ$yw07U$FsIX?|Ok>qC96J=cd; z@;YC2-m6XRg(lYaG*Z2nG~YT0)YowAdafLws6MUp<@g2%pfgBwk;0cy``Y{OLgf^v zvdn?TV0Do;U>(}g2+jRrsC}dJR{Q2sg!{9Maj?GBP`Bpc6{z<{_vLJy;6Olit;eS4G)6KtfV<)|&@?~GFW7k{s0_}^bcdli`x%y$}s)w9QNY*W`%sMACqBL=U`#(}{kZI}9O!ob|625;;!v7E?e72>_ YXKTD4qPpQwz4tCb{gqHVI7FV$f0MB}F8}}l literal 0 HcmV?d00001 diff --git a/examples/refactor-react/src/assets/logo.png b/examples/refactor-react/src/assets/logo.png new file mode 100644 index 0000000000000000000000000000000000000000..0caeb4381267cff0c3adf3020077c55bac612a20 GIT binary patch literal 16859 zcmXwBWmFtZ(`Avx3GS}JT>`-^IKkcB-DL^BXmE!RoZuGRLvVKu?(X_6&wIWf91d(x zb@gmbch$YOCQ?~Z8Wo8U2?`1dRpyI?3KSH81oDHA0EGO4z1=x3Tj;_n3fpCwAyh=i!LHY@WbqFI%s5*P^3b=QJt<)ms|=?8^nE#<9_ z{_B3hx1ZiV-F0#Y&byp_g7vooa=~N-ad3#3M;D4)zyATSnw+EyvJl}^)&SP;CnYMeT#R?)RCP`5%cVP^^GMLm=Gj+Np}*cL#Lbu0KKM zLrF@8d~RN-3(uGm)EI9!#^GUU( zxA)Ajy!&ZSPKus1VOGLXUu9!VF}I*d_h7ysBmyPf zCi?3A$}ov%ZRMHy)%mU>*w1SykV=u{?epe6geT08o6)M zOP#r`nSPG~z4$FrH*Rycd!rLG>UaA0HwGZDu|%hIyO^sidq6W zhG+NC-bcbRq>EN07|DfUG2&HDS+!TgZ%zdL4J)D5Lp&Ryh!b$E?83LsKQ&N9lU)UW zd2;`poQ6w6HYz<7zsFgQ5aGe#sB?{uoJDM%I?NlL$&pXT;Uea$=6yx)%C%WM>gM;x zAziWT1X&-)4ZZl7**Oi4d@=k;G2^Bt;-)-wHsHJ(X;*b@f;Us+INAmHYflR@l63Y&;W#@#V@Tcu7{k9%z|ivV zs&7{yOtt&LNA-h6w221BCXq}(bq`c7=;oLeyDQ*l#SQ<@MD){fBhhWkoPMa!pCAvf z+D1Y3y0UqHODCXS7p_N>jk*eZBwXpQyno{awGOIxHIy)lk<||&$%O;UPm=LFDW$k1 zO=(QfbayF8e*PFN+{Utb$UP~~<~6}G_{{TIP60Im-p41Xx#8&~E;Yly30Xcs9#;k@ zFm+7II)JYo`UfL^f&h%odE=HqrIv;r<}D90TXQQfcps&>yf%s?yz%V)@rN4=X~8Dh zZ5oyL+fzAEB%HikEo&CN|F5EFPL4g^0 zW2oG%Www4>sXY0Q&R^Xq#ZU`&f`sDW#g5UkRMQ&keh()1YL>_`muaxQx((XWI0?ko z?_N`xj}@ld?0}#%&U^Tq^TUC)!-#dhYHT!8B0SUj!HS-VCMM+$iYs*! zdBb}e?AMVRLJSJlzW;a~S~<1ozxpbHmIo~IYN_1s$z_UcmQ8M7h@cA-zY zyPqs*0~{s;mbz6T%kz@0^4y5Da78E`o%h1)=G-38^qA&rmak-?7UQ7qgwwbJS2W2> zsPV#Z{$p^bKIh&Z>c5sp+$b;+mIq0Oeq@U}buO5cN z5S>LbetGNz0VFocuI;{X4f;pkA22Aaztkg^CR16dbYvf$!p}wYzn>3UfBZ}wJ1xf1 zc9Vrpn}-cdUPCPGW}7ABgyl zpnJJi+dmVe2Z_bla<>#RCIav)mi$w)u!}bp$G$N1r<#Y{OR2fZmG`r3IU4$};I_S* zA$(*N=fxN3IJ1c_lSH;~_>3Z2fC0XpU$CR^H`Ja~5}6kmijIJZc#e8~AlnmIyiIBu8{9sp+t; zW+?TDGjLfx&)$oqi@X`1$LQybMC_kHRhu23V20XmL#uZJh%?v9keHKhB^7l5IG|DQ&3>Lzd2y)|*6O$?28PJ1tuUW#b?c*}NrioPfPXjN_dr z&xMio5^k;FKb85_dPe6x+wdoAxGC%Y#q;=BLx^!L@UI(a(wL{J} z91}G|`SBrYI}ydEYQiw?%={HU_Km+CNI|u>a3{n1#1inPTn!aftt3j-!;v4%{eB$y zN2kCT5OL@17NTRE=O9UE{5KbUrV2o~`^Su9LUMyZaFLsnMVtT0l$R~rBx#Q)%7LBP zyJcFhA@GGwIW<4g2AtC`Q7LF@TqKMg2_7*Z-KCm zhoFRU()sFB_{&PsS2u+YHviG^9X@WApOu88L1RBfxN!68tp}}sI9IJp#U9vn=|ctn zRL&JU(So~;c9SrqpD|dr1|CYe9W%n93m^3)RaxZAQCeFIgKn?WKG|F!Qtr>y);)2pwr$YYTxw%>~an$O!EctrtV0xc(Ku$Uh_ zS(UQ;(&*QzDUQSIa)t8DjSTw0B)WDhNfdFW=Y~-?j3YS~X(?^L*mUg+3HHq)W+1m# z8o}>(qD+%xvBu2=jZ3=T39Kc#p)NW0%mM6Ux24B55Wj9T`q{n4Iq^?Y70f0nlrG+p zZiFDByU}m|Lt&(vS)Pm_CHxZaN$1y%wAS=KFILB56@|-U@~p8;1ghXbPP_Ao$h|gK z?a7niH#%z16AO1%kydZF7GYDJnhZz(Eeub0RNd+PM5Mtpjw}Ddakj!AGunl2)*q=Y zYUzC#BL2WEcw#-N%YPP1h+S7f7%Spw#^n=tVomGR1_v4oF)1*TGLC5IS_650dsL}& zsQlSp#qY+0B30YO&;9U`zdvd;T}GS~K#p?$dwlOt6-Jb6FTsOXq<8OC!zcMStxuTY zLz?EArJrm%AI8WmwzP}Xn@FDLTPbWw>`|E5Q_`?n^4eF-lSV)PO1 zLWtr^Rqd95dl%u4yzpTx!t*k`AxRk7eR&6kmfE1={N53?=4vQ8`+S1^#GnkUY_l&p zXuIpl9P6;Jk_+IsBJA}bzl5+h{Pu6td)?92-{tMViN7P2uenTG77?X{452$P8cme8 z>!x#Ufk2bIB8lQA5DqI;wfN+;;*pTE#R=~R2Hd)7kX1+(}?9Bmc)+0n7mW#4By0gr$5>ys^z$1IOlqIhPR z0onmsw?=j4Gfl#eg;JxNrvP?DR#nd}jDL4kdWTXg8m2=+(3^%1M*d-ADv@eaFMNeOh3}E=r z7&S}LSiL6FX1hhyqZCV<)MY1sN0M9unuFoKWt+WQ_6--b8Kp~`SI~a zr~GVzwjoZ$9{@KkP2?abVO%`NNk!1z;D-6hAC9-1k+eGYfdMuvyK%9 z9wlM4hlp}M)fr7xQKo!euJ9t1=2S*TQLEb@Ir8l_Tc7TUjwPS|=U~5KhdOu$26$Fa zpA^w3RfZ-?#EEil(88$G^B>8HUBBtHdreP4u=WWX#8=_?AH}yPNU&puSksX07&)$op1IjMQga`9o?ct<4EBNUe#RXv9+>c#<|+p6h*cBZF%u4h{gs_-%O z6b35qU!}NZTMzbxPQ-+8g<0ec5tJZJ%J2+YlXuiAS4KVz{F8qk4_*3TmTG6y3>Px) zI796-AwO)o67jVP-`=!xO)9c-i{QCo?NzUh2%nL_3%~CTTTt*r$a?2eGA8-WPz~9@ ziSMLLOp6H@JkhZaJ6!UnS&^_b$K`-Sd^TJDI+e0v^2?fusI>Ibj;=#rDR1=6O;#WR z`8xDaKY5FT)l$nT@yd+88ZSTDt4EAK=n=*=0kv5&P^q zYnHY*E{bqE$71kr!oG9pI9P7b6~<&5Ab!ls3oYilecs-&os=QC^aC0iA{fIyBJ6+q zXs6)&6aC4LXRs&*jy!sGA=ZJtLT{DOAA3+_-47QL+6PXXc&~uKxCW!4{R!n>#|=`k zy+Ikj^@N?QiFK)cd5uozJ)jypqhS1Vh}BWOxG=$>ExYEm(l|hK}&z%NtF(22lHCa@K;s@9l5_9%i zmaTSnXRXZ)!HUac_QAEbLiJHacypzR2htW&YbQx4%fiMIWHb}Txkl_06!9cSb9I!w zF28`$N$lRd7`Ws|>LSKo0`CSQSei^79nt&x z2>zhmup9B={8ELmeAO;&)}bna4S`8(?#dO7yno!F@ExlD z)5RI8T3>@Dp_BCoyDNX8fq3zGs4D2T7oX)1k|}=_wHOS?_R59dqJuQVNtr;QP`pW@ zc(l_ae_w5glWE{c3iyD2bo_|o246P5;jXj)i~H_&JhK_L(sWbgo_ce7F{Pz|&-@`_ zzDb>^Kq{oT_dqLXm_e2(@zy03APgQ`g?$yJ=rucc#$XIEq-cDwOOU!I1$9_1v$L_9 z^v90w{S;nL3sU>Y|2^FzH5(7lkUB~5jvr;8aq@e7H%8bYRLR+)ACb}oXA#cwc+4j` zE~Uk&B(DoBCSahjNxz`??2%MQK;K^+ZPjOdgv?Z7;s2n3VKPl=rci)kq#~r+#<>3> z1{B+ngWy9N?;h|hhVZS|o8+!t(te^rxQawXTisMVF7#t#=E2UBS z=Q(iyd=Rolmu7wQWVfodj3`h@iHwIVtj z0V)a{-F+73%@a*p$vd6r`yCkBM@`=|-MP;Lk!7+$2gZyZ-tW$wXPQER9fDdLO z2_6RggdVTP@vW92Alsr{SI1CkS6x<&h1j}@`e5V%(ImY^E*d8Z$>2hh#8{kC&K~;t zT{X^Ai)-Jb*q5;FStE}fg7rn0@LDvu{YhCFt^~?D~-$8&kvk3nnk| zLE?bNX6wQAl;CTf$nRDi91>;!v_aBOrt*+0$*$O(a3Ss%P`sfzt?hBau0XOMx@J*_ zvnyf)#Phl$ob`Fs5uctfVP>!+6+(npmz9-21mqu$R79H&goauxRW82o*E>;+aNgr# zFurDr*uLQ4Q@^Vdr)bKP^`-uji+V27H z(Ypr{5=NchibRPX*xLL0nh-Y{t8sKyKIY(gWS;)Lqm+_Kixy5#U$~%ouqm!(dv}lU zk_B{?^AXktQFp2#0a4~>VP>RaWWmY(D<4vMnw4-kW)tGrtA&`wVcpKyXHT3)k73R3 zd$DHIy*TN!j1;C{_qqXW_WuAdLKxZan9?2z+4THKbp3n?pOBB{!ka#Vz~^ zI8X<2&mK%sX%WrOhhHntpUowd%qB=2Oj^K&R?-mI*#k#4xcQGrzoca&MH3n*6^D&- zxZcG78jH27?gLh95*)_Kzd6d@soMLI^1Ei-)ejSYO==?O3C8{^MaAJ98UFI0iuZ)_ zGpPyKskO||wW*CY?{yb-%PaYn9WwbjzBY?^}*_B6=PFvTvj zi*P&(XWbCH8-}4!)U@2TON>CNySWse>v}tJd)bmxR^Iqs7;BOr(bH?<;l@oPo@k49 zGDE!zqf;bNh_xc@`|ZbY0d0ILM zszGoThxQdG0VUxrbv3t266QNKKma|Ns6$8d5Z-Y4IPU@9KXv?6Cum;|P%Sn@7JLmgHL$Eruh4^CZ%$XDPenh1IQ@6ZLW_SB{3?Ou!k4;6 zubn}v9(SYa&ewcR9X!|qdNn?MpAw`#W&rSzeP~d9BjEyn<`OUAO#TZMB4YF*=H6BQ zI!XTv-}k1YSvDrUmJHdrvvf)t4xhYd_Mh9aZ1E3d#$lcIy;9Wx@J$tDl9+uNs8t@P zso96!Lw@noHJE^k1;oi)77mf;`t;bdGuTOkFGFUAr7Ge=#I!eoKk zpdsj96Gj30f622=M#+Cn+cNjJ>#xSZkUVFsr5%{U0`~Vjf}D=en+SNlIqhFW6URuS zA^4!C=7y;-i71go81IBB%sI^*Sdt#%OVk-9uI z6=~PowUo#=G0YC;KHtPeQ`s=vO2NMpKi8+OqI&-?W5j(Kpvo;G_C|a(Q%o_s)ya?C z{`j8_juGH+YROK^SYKf1QC{-`rw*+r(rx)81Ti zz^XYKWDBGfbc(Q+%)NfHemjw5p@xPJTmJdB|6zGtlOMKisEgF#T!o)@RDUssbBE)hS>ex-t@|>K;uUVv zFkY@`XQb98-ox?X%@r7|$UxmWJaUIB@roP6wH@8>l1)ZeGMiQ#2XZPDkR;pEwbQ8~ zfhY7dmO~pFTfqd;LOrL}O0$rY!+1O$8p6+Rc)t@gbIWmp=l)Q5I4bj{AoN>ZCQZ2- zY}`7ZUkr@=&D`jpm2Wyor@=e=WM2_meCHie(psnMFFV|2Lh`X9tsAFB93GYfC!o7I zacUD0^e$AYy$AZW5PBBcJZSLMdQF2c!*;-OkQ=~^{U)1IH-0CK`B-H=II2%j8bvN6 zZh&&mghwF^FPS%2Z9Z`DhQD!phylH3RuqUV%F2CvF87Z5(q-(V6#T~NIw0K+m>+U@ zd_XuQjQ#WHO>NS_?L$d5#RHWEyRY(x0N-wogU2hOxC9ntJ4s2)x&1)_AWRTIR`o>i(s8JvM*_8ff?}ijZYqz-fs64m?K6tyx{rQrXz91oBQ7e;! zy7_7CN>u@4U(tly^GngznyZtlC%5^jWF-zx_RV@585&zP4J1chiweSv`eb|k%NR9i zHqc~4p#L$&?0@uK^0oj-6_QkD1MV0OF%-C_FQg!hhF-EIxc*-Y@K$8qe~D{<_ZVWwx%p&PYKfM1d&NIzd4IaDQ-tD8 z5nSbJi;~$vsK`CcTDOU}(o>~RY#=A!RIS{}JFSX0d&>7jsx2u==lRK@z5sy#QgHXp zdJsJ8G-z+VuZ9==_d;&V_>8!z3XJ6sFM>=sbatlncH}LB`^QBReMJNuRJ^E*gU8kj| zc8ceI7@zB6{q z3Zy{rJ1QxI+qBkg;%rvH*`XY&A$5IgjZf4Jecoxm$Qt%`^9qKw{Ze*M?IxSP~4Ynq(-T9I!< zpbd_&SZiDV1ci9GWu0Iz4tzMWiU9lHgF28UblFkb1<5?qaOzi=`e$h9XAdEPmu5K> zbQSUGKZSc6S!Mc*$HTfpom4qTFyA2 zFnPuYhkKf~LNWU44tSu{2&TEd0W0uu@@g}6c^AahKQhbw?5|AGn&AM6)yUPVy5S@E z2H!ItWx{CKIa|v-;GNckBWWe4F8}oCKO2`y4)lAc+5cUIn{gPa_Xk-CyvnOJ!h6+6 z{m=_%C_MVp@MHfUc+fHi_5i+!=4>%Ok4S3xtG?)x9Q_({pKp-2F#5?3eaJv=1Pq#%Yyf&4yr)wx{;h=7sF7=hr?)5mWi%#6kFH`Y% z(0+C`0Xa)p*~UdXqYowp(J3cgeq30KnW`tbMnYs{fv+eLwCUClC2_9LT-?n3-WG!_ zridl}5|wehJFsDXnqhVIsxcyD?EiEvbkLNiO9JhlDom}v3tpRWj7Agxu9&3#w-=oy zWHLJ8E)C5G4UU8ThfHd*kHKXgIaA=o?=UZSdGkZkGV!3f(fg7G+>g<>`31P#I+W=z z7|h?SfbX=1!DB2DM>FBvuIapew7jWMoSUBTJv#dSp&r6$J?wbQN9(1Yd{$wLHLBL{ z+^u6q2*~-Att*T&;a)^D&?-8f#VSu$W3if%i`gdu{Ge5}6ytSjJi%N<(_VshAPaV< z=O2uJ#>F=k<-;CXcMFw4-NXX!YfLAMH3itQWo*xBaygrBNkH$FQKbY-sIYbJs_XBf zUQrquEPx-5yq6zgkHp-LdDtn-(cmY4pghuc{g_fBJ~^-jMv!95$`1nh1t?E67aKD4 z1dhYUk=zgf;UMQPrwUrR@a=LN^Ig|ExQE=dJ_-mvH;MKr_PRr(t?;E(a8A@Bq(b8P zl0`HhJYt|yK{gt0K2Kjue~NBeJu!#M`B|qOnr!%kj&rO@pe!Sd=qG#uJ(zB$gG-eS zXE*bL4OzWyjoPG%>YrnM*7Hv`TpO}Ms_GP&>j3g{3NsaQMy5`X1IT=XUw4z zh5wwSn@lM8qnpLI_RrsF(~UF(fXfN^SsWsX(3e#-xS#1uj(zzPslFi(9D`*WLeA&1 z5M&pLO1nrxxA_jz;u2zB9v1ZRm6I2D+GiiR<)eaE>UXM7*^yL zs+A?vZc?XR%D1G%86O_BR!*@?=M%AOXg4@NJea0muIu&>pY}OEJy6ZZ&cH_Jg1zvm zbxS)rf4a4f00T4*L%#Au?57nF$)c1 z2N6DNs}zgWfnS=-b4?uDttzbtu`c5V{G-ayvmu;r-BzgfX<{)3H_QV;HQX0L`M#_6 z%0SiU3QhBnf%$w>&3;=u;?MATiI3@el6ju#5Blg8u*=M!t!UV*wpSb*R1j-aJ~pTz z)NqvhXaIw|laE@$D%#8rXl!>kjyDEId%vw75q^uwL`5}gMJJw$F>1u_6ZYuWc!?r8GxiUL>(rmcXG8vm!U8|j8 zPPS@aw+T$P9Jae8>~LwgJe6li%<~6J=0)P5#Oo8pqp)$adll;}wx1>y^IrsFbqN}^ zK)}O5Z*GgHIb^fW)ds`XJ70N@iUs*9mj&$k)O^lX8B$rw)>`Ag;Q4`0cYVv|za?(O zK-Jn$Ep+rtSWF##1-H}_sn@hKvg6Tv7iY#3*^mP={U~y?dy-M8xv5?H8gcxZij(T> zmi&5;+@GF*2j7dkzgjLk_88l62u!LQ-+_|<0@WZa5?p3Y%s=mkGQo(lLNnoNxsY)y zC3K`Bq(u1j>1)3?l)tHIpkgBWz&pQNxPiO%Q?eMp(a$2&CdDvJ<%xarwXZ%`zkR}z z{?JX<1k@6FuLwFtDc)&IAiw0J5x;c%DCGEaPBc1{Sj%0$K(Ki(DlON@X7VComBUo- z?}ii16Bc7D@ccFDiD%1xI4cZoj}|66P;4SwzFUCmBvF5r+p##EWBXx*0Xjc>uK463 z*qoW)A%|S3PnJjFm6F1V8jCEM@h245Bb!3DN&rv;w66$o-wSc`6AifPVLrwqURmYN z>9ROu7Kr1m`2B)8kSHD%OIQDhH50&7?@jjyY17f=45r`zCB1aaMg)kDOmWY`6|uZ} z4E>#J(-3|J4l1|rn@42*a8p|vA~U~1wGK^MbIPZXns2U@ZrC8^a_SofrNmUgHK_<0 zv{vs%L()?W_pKvn9*Qd|=m+etHwAH*m;N;A1=~)M1#ple<;oxJ7Qrcsw*y@ILFHq$ zj~!hje_>X8R?wxRV)1@yP*~(^JIE~FNRG!d`V_&HTzmVGb!Ec(hzG4>%Abr_ec*y! z>&?4cUey6|z+3WO+nL(UQdKul+9?z?a&Y*rxk4-cP08`8vRqCZZW;uKT|r1^S8zjV zpaOV|SRC!e@l^MRuND-S8Ys*n=m&K74;0cOm$xzZ!s8cO3&%LT}vJ zZ8aLdyss{4rUlo}wZDWpEEHrE6K~w!#+0Fx=uQedtT|wt`$`4RTEX^NvBg1~a{YC{ zNLbz!F7w>;mRWw$Pa}Jx?mJu~t09b@B{x9qf>vE(Ngf3CBWbWf*?JSEgs8E=-eQX( z$1AWdA6e#LqK`9fDD-#pvW&?G%&TtN;;+m@814K(*lA6XW*ZQ<7DhY=Y^y_+4s=8l zY8mSC=Afn6c$1_*QGT4_vi#CtRrE zdfAxhEcxbN|D%BEz|GeFX^DyqtI;Vb(l5v4!w26lw%p{@?D+3jUf{y|5T5R3u!-nO zZIiFqkD3c?XvNAfoJm+8w2g4BNpVK_E&67yO4lgl7*%|TEfQY@MDaC=jar9x)@Xi1 z?RL0{M3kGRJj|#+o_{qNzi0cKBTWpV5Nk%>`~RVCg9)XBy7&^e8P1~3aKbD1SV9h? z4nf(@F!pnhT-4lu5bTq0ID>LD3UW>k^zP(8<;v;V{td3%Seg9*Vjhy;2!|2`Y#>@N zMVoDNn#Wf4?ihF7<(r<-5n`A;&2Hme+ogC z3@j#k0YD<*+rgCUJOqb0ql{>WB%q_uRpm5ekliTDNp|X%5$g!f9_&F((tQ=FZoMCiL^H%GN zJaS8&ATo=8;L@@IYMy=c3Kio$CRA}MZZMft<%;F)zsQ49)}*i>?F{b>=h$O;_5;*% zYr)Mw8W@SVpxJNaec5>4GiodZ3BE9&3#%K1u9>u6K7H9_HQ3pr$%Zj*vZv?W`yu!< z8AA8yUNg*Cu}NX{Ink1$?fwHTFx?4gI%bArRTKQYTYtFPbpQ!9-g(}U{h zS^9R|n}Re!=dmg)K_cXwC0HbQOo_M4Dw=UNm?W)ZM~-?V?LZP{N&$ zsJcT%oCxv8_?;2u3U!yK!g)2Q8PD_)cA5oGRDZR#T7OITJQi%twTP^jE**TVer1B) zbxW&AMt1EwozUqn&<){x^&I!QELhpSq?=?Wyu9(rKaXw*oRpKXwrDTW;NaUZP|Qni z6;+;6G$}nAC7fvj#(B2q07Iu@2*=R;`5zdlH=eA>w`M2SH{Dm4R$D0#3xPX|692S*A=tI>Ai?L{<|6{1 zxvRD^iGd>S#TgE~5VBUq8X!{)pcPDV-(*4i8a@TZu*dDcU4RiBj`jeo>inkN8Dkng zWWHVg_g!y{!pc!5G>IrV5Hy&G^k9Il$D7s;*XPJKeQD7dyI5IQA2ws$x5)-118$TD zj5bVpW0;EZVcA|$#+6}_WQK%LoY9_tXd{;}9F=2;2zc! zWdcyoQ@G1tD=TjtnIWSriUp6#fy!L*e0uA*PYu2+C+8>nHk$qwfD)QyG~seE04|AM zTLRn-Y38T4Z5~v5JwlR$Zd!}{BG zf!fla>0wJ<>m~s%M{i|nGSmCAmqB`PKnTDH-rhvlb9Ym0W**B{%pFfZ` z%UsUnEJtG_&_t-|fQ;rxN8Z$W@0=EEn$ zsh{o8R1Kk&8T_|gX4Q1I=Aqwr`YrPJR6#nU^-RMWiR&li@PRXhij*7FpusT{e|VaNShh&v;dPpZqfeVg`ahjq%J zvKw(wK#x4#>{cBi@D**d6|UUd*mjA?VbrAI-%RxWLf?_jkYrXsv;^Ci3JAASLD>f8 zdC8ra)xB|=mqD^ymm<;Q61fprI4L-@*layI0T*?ameWtBbL+&~Ae@_`cr}K!KE46Z z`CuE;PF#MZnx?OE?bre$5=EQKGiX^&A22e5yrI@t8yc@phlMhX@9L}WjROI0S4*pP z4Cj;mIEOJ7iOQ<^rXNZgWM0+KHTBa&U9!H9q%|^#GaIm++M@P%iZS@IU}VEMjb`iKl7$)8x$vakTpE!10$BK1y`xTQSP%vv1mD#R3)>Ff64pC~?IS_CNp%s7SdWKk)f>?H z(}8|y3+10oAWRZL1ti0(*}PLv7|6gTX&p~c=^i+|s12A-j07E+?7JMOJC-kotq6+v zp}8vB0W~kpSX_^r@PEfdI^5*PIt7}(3rP_V$$#vN&}Qjwr>%2Tr0I7y=SwSqV@Ivt zn4ESfDO2Xaz;m~Z>@=IlJ&hiT+2mj&bW1YMpW$(t+w zp&s+_waDdiH(2rry+e6$|El7R(-xD%PhCaF4kE!Z@E8#i;8XoC)3C(OCU(g^# zT~s1Nk8{CV?$mllLYRl21M3d3rk1x2ahmtVnw4NdJ@=I3xBtElmQ_RCca-O5<-hIv zpSbpn%Tc%h~0Nd7sdhRjuumvM~iIWKV)T&`b^o{FOI z34yq}fA@ass*FeJkr7+PBK(Q5e)&&dXK4t3On1(8+|W1|iM7t<_h*lth7zL5!BvaU z?WQgpQV}6XJ>heiE(uji>rbN9+Zc#9}u0 z=|=o`A%d%YEWoI=N)*fO+5Y>a;l@e{%NP5(LD-H4J=j)a%Niq$^myxsDBa)hr9?Ft zrX+PNxl6few^$;JPM+~L2Gd{Avs_@ZhCm@Se~)cC zCa3Pm1j^zw`9~t>a%!>n>UCn(JSt|uQBjY&n*tlq3CjjiI;8N0JkAISOofXrNEbQCe`zqi zKLro0{VMHiwvc)qMs>iFl8XkF5NWA{E>I#Y(ySlonp_mP1|dWnL(}=nz`t;LMh8#+ z3h>Xy{?oM;exC2c+XzHuhMW}d1|7E3DApTl6;w*?*ELn`8gZ0k+Hoxe^NdC4r zI#m2wSAfyb#7+&c`N$l1ctQCmhEZw?_Mz<9CBZ!tW4#!D5gq}53$}Qr10^7p{=Pl( zU>|uW_C)1)+1Hvh4X_CVb}?t-;;iWfUmo=G5hQ2^Ke!b0LH75)?+}35aP$-Z zT%dLVagbVHy5U#qfPG2sUNDNKzcMpFO|@fc?g(1X$Tv^?R%$-PpF8}QJ5s%vUx>Rx z@f|JULg|WjKGXeuS8f)C^E=Y^uq!$-{FCcyM_qLrf*amGlFlMBn_?ppF|`P>*dD z&PZ+^>l!~ko$7n^6|Wm<@c}~{E{W!W8(Ip|U@rR=^Vs+2xUT_zx@IDn(c99}6^@ z!Een%<^yeDWrUVXKq2RaoF6kkPFCc9?O7td*^*~lWkzF#VIDqmvyCS+*|m$Lt-ZZ# zg}cg%!oU{Tt9vI}q2es(a*7n(Y^3oi{ojo7JO(v#4s&+ChQ*MU)+dSM-?ByzMHxHF z9f_t?vRJI| z4u{8FBF+p~)po~Y7y|15PZ{UOCFx&eaz=pFeSCazrr^7L*8E5z{NFc+>XOF&xM_@P zQdcT(_sG{_i3lHTq)MFTAhB?s28g7uiq&f$!nC-zErr;vaB z#CUHKF5I{O+%4xr(S2z^~yXR z5}>sMdKAFHu5>zy>sQDF4GG~8yV-+g)7z}yz7=EKb5;6<2OC1_<6kPJZ4h0Jd`)dt zyhJHJ%e`RthA)iRD(4UXrB3~>Y4jI1NH5@!Qp`4*3-YO2IAVUyh#P*y9m7@pDSO4j z2iX{FUQV@NxNKf#rTB$Ulm7BvpysDnNcr>#E^?!cx}3>Z#nyl2ZL9(z1W~2me-v5x z@FUzSnH!+=*}9$IgJm~mhVQ(^zHl@tq(WBERoh}0=p}4Qm9^(Wy=zc zo1Kw46$76{Of`_83=g#lB~_`J`fn`$U_B(qw0EwaSGL=ftuRB!0P1_VrbQOsdiFoa zI|BUQ-wOaZ|ER@uJa)_U``W+Vt17A4Wf=mpE=NBSSIwq1R^;Wtq|FAw@3eIjAWJ#!;F|Jaf!Mdc zFB%I8k`OEr{-HgFX=%0O5DnmFj-DPNK{JAU$`7MhQ3Q+%N&}{dBn&;(Pf7CGUNgGu_lj z6gI%;KFGTVgh#{1BsrDgA)T+K!7_8=Gbs0w5Q703sM%2#d1&uZ2%q>XyoBH!3u5q@ ji-;d@RD^`>{4E>P*d_6jJR9=11}GUxMTtr=qi_EQr81c) literal 0 HcmV?d00001 diff --git a/examples/refactor-react/src/assets/react.svg b/examples/refactor-react/src/assets/react.svg new file mode 100644 index 0000000000..6c87de9bb3 --- /dev/null +++ b/examples/refactor-react/src/assets/react.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/examples/refactor-react/src/index.css b/examples/refactor-react/src/index.css new file mode 100644 index 0000000000..6cc4daf982 --- /dev/null +++ b/examples/refactor-react/src/index.css @@ -0,0 +1,69 @@ +:root { + font-family: Inter, system-ui, Avenir, Helvetica, Arial, sans-serif; + line-height: 1.5; + font-weight: 400; + + color-scheme: light dark; + color: rgba(255, 255, 255, 0.87); + background-color: #242424; + + font-synthesis: none; + text-rendering: optimizeLegibility; + -webkit-font-smoothing: antialiased; + -moz-osx-font-smoothing: grayscale; + -webkit-text-size-adjust: 100%; +} + +a { + font-weight: 500; + color: #9f1a8f; + text-decoration: inherit; +} +a:hover { + color: #9f1a8f; +} + +body { + margin: 0; + display: flex; + place-items: center; + min-width: 320px; + min-height: 100vh; +} + +h1 { + font-size: 3.2em; + line-height: 1.1; +} + +button { + border-radius: 8px; + border: 1px solid transparent; + padding: 0.6em 1.2em; + font-size: 1em; + font-weight: 500; + font-family: inherit; + background-color: #1a1a1a; + cursor: pointer; + transition: border-color 0.25s; +} +button:hover { + border-color: #9f1a8f; +} +button:focus, +button:focus-visible { + outline: 4px auto -webkit-focus-ring-color; +} + +@media (prefers-color-scheme: light) { + :root { + color: #213547; + background-color: #ffffff; + } + a:hover { + color: #9F1A8F; + } + button { + background-color: #f9f9f9; + } +} diff --git a/examples/refactor-react/src/index.tsx b/examples/refactor-react/src/index.tsx new file mode 100644 index 0000000000..39df64e842 --- /dev/null +++ b/examples/refactor-react/src/index.tsx @@ -0,0 +1,11 @@ +import React from 'react'; +import { createRoot } from 'react-dom/client'; +import { Main } from './main'; +import './index.css' + + +const container = document.querySelector('#root'); +// biome-ignore lint/style/noNonNullAssertion: +const root = createRoot(container!); + +root.render(
); diff --git a/examples/refactor-react/src/main.css b/examples/refactor-react/src/main.css new file mode 100644 index 0000000000..ff29d41287 --- /dev/null +++ b/examples/refactor-react/src/main.css @@ -0,0 +1,42 @@ +#root { + max-width: 1280px; + margin: 0 auto; + padding: 2rem; + text-align: center; +} + +.logo { + height: 6em; + padding: 1.5em; + will-change: filter; + transition: filter 300ms; +} +.logo:hover { + filter: drop-shadow(0 0 2em #9F1A8Faa); +} +.logo.react:hover { + filter: drop-shadow(0 0 2em #61dafbaa); +} + +@keyframes logo-spin { + from { + transform: rotate(0deg); + } + to { + transform: rotate(360deg); + } +} + +@media (prefers-reduced-motion: no-preference) { + a:nth-of-type(2) .logo { + animation: logo-spin infinite 20s linear; + } +} + +.card { + padding: 2em; +} + +.read-the-docs { + color: #888; +} diff --git a/examples/refactor-react/src/main.tsx b/examples/refactor-react/src/main.tsx new file mode 100644 index 0000000000..419a29c9be --- /dev/null +++ b/examples/refactor-react/src/main.tsx @@ -0,0 +1,32 @@ +import React, { useState } from "react"; +import "./main.css"; +import reactLogo from "./assets/react.svg"; +import FarmLogo from "./assets/logo.png"; +export function Main() { + const [count, setCount] = useState(0); + + return ( + <> + +

Farm + React

+
+ +

+ Edit src/main.tsx and save to test HMR +

+
+

+ Click on the Farm and React logos to learn more +

+ + ); +} diff --git a/examples/refactor-react/src/typings.d.ts b/examples/refactor-react/src/typings.d.ts new file mode 100644 index 0000000000..fa0a2da548 --- /dev/null +++ b/examples/refactor-react/src/typings.d.ts @@ -0,0 +1,3 @@ +declare module '*.svg'; +declare module '*.png'; +declare module '*.css'; diff --git a/examples/refactor-react/tsconfig.json b/examples/refactor-react/tsconfig.json new file mode 100644 index 0000000000..7a7611e4a3 --- /dev/null +++ b/examples/refactor-react/tsconfig.json @@ -0,0 +1,25 @@ +{ + "compilerOptions": { + "target": "ES2020", + "useDefineForClassFields": true, + "lib": ["ES2020", "DOM", "DOM.Iterable"], + "module": "ESNext", + "skipLibCheck": true, + + /* Bundler mode */ + "moduleResolution": "bundler", + "allowImportingTsExtensions": true, + "resolveJsonModule": true, + "isolatedModules": true, + "noEmit": true, + "jsx": "react-jsx", + + /* Linting */ + "strict": true, + "noUnusedLocals": true, + "noUnusedParameters": true, + "noFallthroughCasesInSwitch": true + }, + "include": ["src"], + "references": [{ "path": "./tsconfig.node.json" }] +} \ No newline at end of file diff --git a/examples/refactor-react/tsconfig.node.json b/examples/refactor-react/tsconfig.node.json new file mode 100644 index 0000000000..8d4232518e --- /dev/null +++ b/examples/refactor-react/tsconfig.node.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "composite": true, + "skipLibCheck": true, + "module": "ESNext", + "moduleResolution": "bundler", + "allowSyntheticDefaultImports": true, + "strict": true + }, + "include": ["farm.config.ts"] +} diff --git a/js-plugins/electron/src/index.ts b/js-plugins/electron/src/index.ts index 84d5c48d3b..46305ba716 100644 --- a/js-plugins/electron/src/index.ts +++ b/js-plugins/electron/src/index.ts @@ -3,7 +3,7 @@ import type { AddressInfo } from 'node:net'; import path from 'node:path'; // TODO: submit a PR to farm(export default farm) import { - type FarmCLIOptions, + type FarmCliOptions, type JsPlugin, type Server, type UserConfig, @@ -158,8 +158,8 @@ function resolveFarmConfig( }); } - // TODO: submit a PR to farm(Omit & UserConfig) - return opts.farm as FarmCLIOptions; + // TODO: submit a PR to farm(Omit & UserConfig) + return opts.farm as FarmCliOptions; } function resolveServerUrl(server: Server) { diff --git a/packages/cli/src/config.ts b/packages/cli/src/config.ts deleted file mode 100644 index 467019af8a..0000000000 --- a/packages/cli/src/config.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { FarmCLIOptions, UserConfig } from '@farmfe/core'; -import { FarmCLIBuildOptions, GlobalFarmCLIOptions } from './types.js'; - -export function getOptionFromBuildOption( - options: FarmCLIBuildOptions & GlobalFarmCLIOptions -): FarmCLIOptions & UserConfig { - const { - input, - outDir, - target, - format, - watch, - minify, - sourcemap, - treeShaking, - mode - } = options; - - const output: UserConfig['compilation']['output'] = { - ...(outDir && { path: outDir }), - ...(target && { targetEnv: target }), - ...(format && { format }) - }; - - const compilation: UserConfig['compilation'] = { - input: { ...(input && { index: input }) }, - output, - ...(watch && { watch }), - ...(minify && { minify }), - ...(sourcemap && { sourcemap }), - ...(treeShaking && { treeShaking }) - }; - - const defaultOptions: FarmCLIOptions & UserConfig = { - compilation, - ...(mode && { mode }) - }; - - return defaultOptions; -} diff --git a/packages/cli/src/index.ts b/packages/cli/src/index.ts index e8409c5c3d..3e3891ced6 100644 --- a/packages/cli/src/index.ts +++ b/packages/cli/src/index.ts @@ -1,37 +1,43 @@ -import { readFileSync } from 'node:fs'; - import { cac } from 'cac'; -import { getOptionFromBuildOption } from './config.js'; + import { handleAsyncOperationErrors, - preventExperimentalWarning, resolveCliConfig, resolveCommandOptions, - resolveCore + resolveCore, + version } from './utils.js'; +import type { UserConfig } from '@farmfe/core'; import type { - FarmCLIBuildOptions, - FarmCLIPreviewOptions, - FarmCLIServerOptions, - GlobalFarmCLIOptions, - ICleanOptions + CleanOptions, + CliBuildOptions, + CliPreviewOptions, + CliServerOptions, + GlobalCliOptions } from './types.js'; -const { version } = JSON.parse( - readFileSync(new URL('../package.json', import.meta.url)).toString() -); - const cli = cac('farm'); // common command cli - .option('-c, --config ', 'use specified config file') - .option('-m, --mode ', 'set env mode') - .option('--base ', 'public base path') - .option('--clearScreen', 'allow/disable clear screen when logging', { - default: true - }); + .option( + '-c, --config ', + '[string] use specified config file (default: farm.config.js / farm.config.ts / farm.config.mjs / farm.config.cjs / farm.config.mts / farm.config.cts)' + ) + .option( + '-m, --mode ', + '[string] set env mode, when use with development (default: /)' + ) + .option('--base ', '[string] public base path') + .option('-d, --debug [feat]', `[string | boolean] show debug logs`) + .option( + '--clearScreen', + '[boolean] allow/disable clear screen when logging (default: true)', + { + default: true + } + ); // dev command cli @@ -41,33 +47,55 @@ cli ) .alias('start') .alias('dev') - .option('-l, --lazy', 'lazyCompilation') - .option('--host ', 'specify host') - .option('--port ', 'specify port') - .option('--open', 'open browser on server start') - .option('--hmr', 'enable hot module replacement') - .option('--cors', 'enable cors') - .option('--strictPort', 'specified port is already in use, exit with error') + .option('-l, --lazy', '[boolean] lazyCompilation (default: true)') + .option('--host ', '[string] specify host') + .option('--port ', '[string] specify port') + .option('--open', '[boolean] open browser on server start') + .option('--hmr', '[boolean] enable hot module replacement') + .option('--cors', '[boolean] enable cors') + .option( + '--strictPort', + '[boolean] specified port is already in use, exit with error (default: true)' + ) + .option('--target ', '[string] transpile targetEnv node, browser') + .option('--format ', '[string] transpile format esm, commonjs') + .option('--sourcemap', '[boolean] output source maps for build') + .option( + '--treeShaking', + '[boolean] Eliminate useless code without side effects' + ) + .option('--minify', '[boolean] code compression at build time') .action( async ( - rootPath: string, - options: FarmCLIServerOptions & GlobalFarmCLIOptions + root: string, + options: CliServerOptions & CliBuildOptions & GlobalCliOptions ) => { - const { root, configPath } = resolveCliConfig(rootPath, options); const resolveOptions = resolveCommandOptions(options); const defaultOptions = { root, - compilation: { - lazyCompilation: options.lazy - }, server: resolveOptions, clearScreen: options.clearScreen, - configPath, - mode: options.mode + configFile: options.config, + mode: options.mode, + compilation: { + lazyCompilation: options.lazy, + output: { + path: options?.outDir, + targetEnv: options?.target, + format: options?.format + }, + input: { + index: options?.input + }, + sourcemap: options.sourcemap, + minify: options.minify, + treeShaking: options.treeShaking + } }; const { start } = await resolveCore(); + handleAsyncOperationErrors( start(defaultOptions), 'Failed to start server' @@ -78,83 +106,113 @@ cli // build command cli .command('build [root]', 'compile the project in production mode') - .option('-o, --outDir ', 'output directory') - .option('-i, --input ', 'input file path') - .option('-w, --watch', 'watch file change') - .option('--target ', 'transpile targetEnv node, browser') - .option('--format ', 'transpile format esm, commonjs') - .option('--sourcemap', 'output source maps for build') - .option('--treeShaking', 'Eliminate useless code without side effects') - .option('--minify', 'code compression at build time') - .action( - async ( - rootPath: string, - options: FarmCLIBuildOptions & GlobalFarmCLIOptions - ) => { - const { root, configPath } = resolveCliConfig(rootPath, options); + .option('-o, --outDir ', '[string] output directory') + .option('-i, --input ', '[string] input file path') + .option('-w, --watch', '[boolean] watch file change') + .option('--target ', '[string] transpile targetEnv node, browser') + .option('--format ', '[string] transpile format esm, commonjs') + .option('--sourcemap', '[boolean] output source maps for build') + .option( + '--treeShaking', + '[boolean] Eliminate useless code without side effects' + ) + .option('--minify', '[boolean] code compression at build time') + .action(async (root: string, options: CliBuildOptions & GlobalCliOptions) => { + const defaultOptions = { + root, + configFile: options.configFile, + mode: options.mode, + watch: options.watch, + compilation: { + output: { + path: options?.outDir, + targetEnv: options?.target, + format: options?.format + }, + input: { + index: options?.input + }, + sourcemap: options.sourcemap, + minify: options.minify, + treeShaking: options.treeShaking + } + }; - const defaultOptions = { - root, - configPath, - ...getOptionFromBuildOption(options) - }; + const { build } = await resolveCore(); - const { build } = await resolveCore(); - handleAsyncOperationErrors(build(defaultOptions), 'error during build'); - } - ); + handleAsyncOperationErrors(build(defaultOptions), 'error during build'); + }); cli .command('watch [root]', 'watch file change') - .option('-o, --outDir ', 'output directory') - .option('-i, --input ', 'input file path') - .option('--target ', 'transpile targetEnv node, browser') - .option('--format ', 'transpile format esm, commonjs') - .option('--sourcemap', 'output source maps for build') - .option('--treeShaking', 'Eliminate useless code without side effects') - .option('--minify', 'code compression at build time') - .action( - async ( - rootPath: string, - options: FarmCLIBuildOptions & GlobalFarmCLIOptions - ) => { - const { root, configPath } = resolveCliConfig(rootPath, options); - - const defaultOptions = { - root, - configPath, - ...getOptionFromBuildOption(options) - }; - - const { watch } = await resolveCore(); - handleAsyncOperationErrors( - watch(defaultOptions), - 'error during watch project' - ); - } - ); + .option('-o, --outDir ', '[string] output directory') + .option('-i, --input ', '[string] input file path') + .option('--target ', '[string] transpile targetEnv node, browser') + .option('--format ', '[string] transpile format esm, commonjs') + .option('--sourcemap', '[boolean] output source maps for build') + .option( + '--treeShaking', + '[boolean] Eliminate useless code without side effects' + ) + .option('--minify', '[boolean] code compression at build time') + .action(async (root: string, options: CliBuildOptions & GlobalCliOptions) => { + const defaultOptions = { + root, + configFile: options.configFile, + mode: options.mode, + compilation: { + watch: options.watch, + output: { + path: options?.outDir, + targetEnv: options?.target, + format: options?.format + }, + input: { + index: options?.input + }, + sourcemap: options.sourcemap, + minify: options.minify, + treeShaking: options.treeShaking + } + }; + + const { watch } = await resolveCore(); + + handleAsyncOperationErrors( + watch(defaultOptions), + 'error during watch project' + ); + }); cli .command('preview [root]', 'compile the project in watch mode') - .option('--port ', 'specify port') - .option('--open', 'open browser on server preview start') + .option('--host [host]', `[string] specify hostname`) + .option('--port ', `[number] specify port`) + .option('--open', '[boolean] open browser on server preview start') + .option('--outDir ', `[string] output directory (default: dist)`) + .option('--strictPort', `[boolean] exit if specified port is already in use`) .action( - async ( - rootPath: string, - options: FarmCLIPreviewOptions & GlobalFarmCLIOptions - ) => { - const { root, configPath } = resolveCliConfig(rootPath, options); - - const resolveOptions = resolveCommandOptions(options); + async (root: string, options: CliPreviewOptions & GlobalCliOptions) => { const defaultOptions = { root, mode: options.mode, - server: resolveOptions, - configPath, - port: options.port + preview: { + port: options.port, + strictPort: options?.strictPort, + host: options.host, + open: options.open + }, + configPath: options.configPath, + port: options.port, + compilation: { + output: { + path: options.outDir + } + } }; const { preview } = await resolveCore(); + handleAsyncOperationErrors( preview(defaultOptions), 'Failed to start preview server' @@ -168,18 +226,14 @@ cli '--recursive', 'Recursively search for node_modules directories and clean them' ) - .action(async (rootPath: string, options: ICleanOptions) => { + .action(async (rootPath: string, options: CleanOptions) => { const { root } = resolveCliConfig(rootPath, options); - const { clean } = await resolveCore(); - try { - await clean(root, options?.recursive); - } catch (e) { - const { Logger } = await import('@farmfe/core'); - const logger = new Logger(); - logger.error(`Failed to clean cache: \n ${e.stack}`); - process.exit(1); - } + const { clean } = await resolveCore(); + handleAsyncOperationErrors( + clean(root, options?.recursive), + 'Failed to clean cache' + ); }); // Listening for unknown command @@ -187,16 +241,10 @@ cli.on('command:*', async () => { const { Logger } = await import('@farmfe/core'); const logger = new Logger(); logger.error( - 'Unknown command place Run "farm --help" to see available commands' + `Unknown command place Run "farm --help" to see available commands` ); }); -// warning::: use mdn browser compatibility data with experimental warning in terminal so prevent experimental warning -// we don't use it in `@farmfe/core` package because -// we need to prevent it in cli package but we don't prevent it in core package -// We only keep the original code environment. -preventExperimentalWarning(); - cli.help(); cli.version(version); diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index afdd44364f..37f668636a 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -1,11 +1,11 @@ -export interface GlobalFarmCLIOptions { +export interface GlobalCliOptions { '--'?: string[]; c?: boolean | string; config?: string; configPath?: string; m?: string; base?: string; - mode?: 'development' | 'production'; + mode?: 'development' | 'production' | string; w?: boolean; watch?: boolean; watchPath?: string; @@ -15,12 +15,12 @@ export interface GlobalFarmCLIOptions { clearScreen?: boolean; } -export interface ICleanOptions { +export interface CleanOptions { path?: string; recursive?: boolean; } -export interface FarmCLIServerOptions { +export interface CliServerOptions { port?: string; open?: boolean; https?: boolean; @@ -28,7 +28,8 @@ export interface FarmCLIServerOptions { strictPort?: boolean; } -export interface FarmCLIBuildOptions { +export interface CliBuildOptions { + configFile?: string | undefined; input?: string; outDir?: string; sourcemap?: boolean; @@ -47,7 +48,10 @@ export interface FarmCLIBuildOptions { | 'browser-esnext'; } -export interface FarmCLIPreviewOptions { - open?: boolean; +export interface CliPreviewOptions { + host?: string | boolean; port?: number; + open?: boolean | string; + strictPort?: boolean; + outDir?: string; } diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index 18717f8cb8..f3840e35e8 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -1,25 +1,11 @@ -import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'node:fs'; +import { readFileSync } from 'node:fs'; import path from 'node:path'; -import readline from 'node:readline'; -import { fileURLToPath } from 'node:url'; import type { build, clean, preview, start, watch } from '@farmfe/core'; import { Logger } from '@farmfe/core'; -import spawn from 'cross-spawn'; -import walkdir from 'walkdir'; -import type { GlobalFarmCLIOptions, ICleanOptions } from './types.js'; +import type { CleanOptions, GlobalCliOptions } from './types.js'; const logger = new Logger(); -interface installProps { - cwd: string; - package: string; -} - -export const TEMPLATES_DIR = path.join( - path.dirname(fileURLToPath(import.meta.url)), - '..', - 'templates' -); export async function resolveCore(): Promise<{ start: typeof start; @@ -38,69 +24,6 @@ export async function resolveCore(): Promise<{ } } -export function copyFiles( - source: string, - dest: string, - callback?: (content: string) => string -): void { - walkdir(source, { sync: true }, (p, stat) => { - if (stat.isFile()) { - const content = readFileSync(p).toString(); - const newContent = callback?.(content) ?? content; - - const relativePath = path.relative(source, p); - const destPath = path.join(dest, relativePath); - - if (!existsSync(path.dirname(destPath))) { - mkdirSync(path.dirname(destPath), { recursive: true }); - } - - writeFileSync(destPath, newContent); - } - }); - - if (!existsSync(path.join(dest, '.gitignore'))) { - writeFileSync( - path.join(dest, '.gitignore'), - ` -node_modules -*.farm` - ); - } -} - -export async function install(options: installProps): Promise { - const cwd = options.cwd; - return new Promise((resolve, reject) => { - const command = options.package; - const args = ['install']; - - const child = spawn(command, args, { - cwd, - stdio: 'inherit' - }); - - child.once('close', (code: number) => { - if (code !== 0) { - reject({ - command: `${command} ${args.join(' ')}` - }); - return; - } - resolve(); - }); - child.once('error', reject); - }); -} -/** - * 用于规范化目标路径 - * @param {string |undefined} targetDir - * @returns - */ -export function formatTargetDir(targetDir: string | undefined) { - return targetDir?.trim()?.replace(/\/+$/g, ''); -} - /** * filter duplicate item in options */ @@ -112,18 +35,7 @@ export function filterDuplicateOptions(options: T) { } } -/** - * clear command screen - */ -export function clearScreen() { - const repeatCount = process.stdout.rows - 2; - const blank = repeatCount > 0 ? '\n'.repeat(repeatCount) : ''; - console.log(blank); - readline.cursorTo(process.stdout, 0, 0); - readline.clearScreenDown(process.stdout); -} - -export function cleanOptions(options: GlobalFarmCLIOptions) { +export function cleanOptions(options: GlobalCliOptions) { const resolveOptions = { ...options }; delete resolveOptions['--']; @@ -141,8 +53,8 @@ export function cleanOptions(options: GlobalFarmCLIOptions) { } export function resolveCommandOptions( - options: GlobalFarmCLIOptions -): GlobalFarmCLIOptions { + options: GlobalCliOptions +): GlobalCliOptions { const resolveOptions = { ...options }; filterDuplicateOptions(resolveOptions); return cleanOptions(resolveOptions); @@ -164,17 +76,6 @@ export async function handleAsyncOperationErrors( } } -// prevent node experimental warning -export function preventExperimentalWarning() { - const defaultEmit = process.emit; - process.emit = function (...args: any[]) { - if (args[1].name === 'ExperimentalWarning') { - return undefined; - } - return defaultEmit.call(this, ...args); - }; -} - export function resolveRootPath(rootPath = '') { return rootPath && path.isAbsolute(rootPath) ? rootPath @@ -183,7 +84,7 @@ export function resolveRootPath(rootPath = '') { export function resolveCliConfig( root: string, - options: GlobalFarmCLIOptions & ICleanOptions + options: GlobalCliOptions & CleanOptions ) { root = resolveRootPath(root); const configPath = getConfigPath(root, options.config); @@ -192,3 +93,7 @@ export function resolveCliConfig( configPath }; } + +export const { version } = JSON.parse( + readFileSync(new URL('../package.json', import.meta.url)).toString() +); diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts index bcb9a51de8..15ed769b07 100644 --- a/packages/core/src/config/index.ts +++ b/packages/core/src/config/index.ts @@ -3,6 +3,7 @@ import fs from 'node:fs'; import module from 'node:module'; import path, { isAbsolute, join } from 'node:path'; import { pathToFileURL } from 'node:url'; +import fse from 'fs-extra'; import { bindingPath } from '../../binding/index.js'; import { OutputConfig } from '../types/binding.js'; @@ -14,7 +15,8 @@ import { resolveAsyncPlugins, resolveConfigHook, resolveConfigResolvedHook, - resolveFarmPlugins + resolveFarmPlugins, + rustPluginResolver } from '../plugin/index.js'; import { Server } from '../server/index.js'; import { @@ -59,7 +61,8 @@ import { mergeConfig, mergeFarmCliConfig } from './mergeConfig.js'; import { normalizeExternal } from './normalize-config/normalize-external.js'; import type { Alias, - FarmCLIOptions, + ConfigEnv, + FarmCliOptions, NormalizedServerConfig, ResolvedCompilation, ResolvedUserConfig, @@ -84,40 +87,7 @@ export function defineFarmConfig(config: UserConfigExport): UserConfigExport { return config; } -async function getDefaultConfig( - config: UserConfig, - inlineOptions: FarmCLIOptions, - mode?: CompilationMode, - logger?: Logger -) { - logger = logger ?? new Logger(); - const resolvedUserConfig = await resolveMergedUserConfig( - config, - undefined, - inlineOptions.mode ?? mode, - logger - ); - - resolvedUserConfig.server = normalizeDevServerConfig( - inlineOptions.server, - mode - ); - - resolvedUserConfig.compilation = await normalizeUserCompilationConfig( - resolvedUserConfig, - config, - logger, - mode, - true - ); - resolvedUserConfig.root = resolvedUserConfig.compilation.root; - resolvedUserConfig.jsPlugins = []; - resolvedUserConfig.rustPlugins = []; - - return resolvedUserConfig; -} - -async function handleServerPortConflict( +export async function handleServerPortConflict( resolvedUserConfig: ResolvedUserConfig, logger: Logger, mode?: CompilationMode @@ -136,45 +106,46 @@ async function handleServerPortConflict( * @param configPath */ export async function resolveConfig( - inlineOptions: FarmCLIOptions & UserConfig = {}, - mode?: CompilationMode, - logger?: Logger, - isHandleServerPortConflict = true + inlineOptions: FarmCliOptions & UserConfig, + command: 'start' | 'build' | 'preview', + defaultMode: CompilationMode = 'development', + defaultNodeEnv: CompilationMode = 'development', + isPreview = false, + logger?: Logger ): Promise { - // Clear the console according to the cli command - - checkClearScreen(inlineOptions); logger = logger ?? new Logger(); + + let mode = defaultMode; + const envMode = inlineOptions.mode || defaultMode; + const isNodeEnvSet = !!process.env.NODE_ENV; inlineOptions.mode = inlineOptions.mode ?? mode; + if (!isNodeEnvSet) { + setProcessEnv(defaultNodeEnv); + } + + const configEnv: ConfigEnv = { + mode: envMode, + command, + isPreview + }; + // configPath may be file or directory let { configPath } = inlineOptions; - let rawConfig: UserConfig = mergeFarmCliConfig(inlineOptions, {}); - - // if the config file can not found, just merge cli options and return default - if (configPath) { - if (!path.isAbsolute(configPath)) { - throw new Error('configPath must be an absolute path'); - } + const { configFile } = inlineOptions; + const loadedUserConfig: any = await loadConfigFile( + configFile, + inlineOptions, + configEnv + ); - const loadedUserConfig = await loadConfigFile( - configPath, - inlineOptions, - logger - ); + let rawConfig: UserConfig = mergeFarmCliConfig(inlineOptions, {}); - if (loadedUserConfig) { - configPath = loadedUserConfig.configFilePath; - rawConfig = mergeConfig(rawConfig, loadedUserConfig.config); - } - rawConfig.compilation.mode = - loadedUserConfig?.config?.compilation?.mode ?? mode; - } else { - mergeConfig( - rawConfig, - await getDefaultConfig(rawConfig, inlineOptions, mode, logger) - ); + if (loadedUserConfig) { + configPath = loadedUserConfig.configFilePath; + rawConfig = mergeConfig(rawConfig, loadedUserConfig.config); } - + rawConfig.compilation.mode = + loadedUserConfig?.config?.compilation?.mode ?? mode; const { config: userConfig, configFilePath } = { configFilePath: configPath, config: rawConfig @@ -193,38 +164,33 @@ export async function resolveConfig( const mergedUserConfig = mergeFarmCliConfig(inlineOptions, config); - const resolvedUserConfig = await resolveMergedUserConfig( + const resolvedUserConfig = await resolveUserConfig( mergedUserConfig, configFilePath, - inlineOptions.mode ?? mode, + mode, logger ); - // normalize server config first cause it may be used in normalizeUserCompilationConfig + // normalize server config first cause it may be used in normalizeUserCompilationFnConfig resolvedUserConfig.server = normalizeDevServerConfig( resolvedUserConfig.server, mode ); - if (isHandleServerPortConflict) { - await handleServerPortConflict(resolvedUserConfig, logger, mode); - } + // if (isHandleServerPortConflict) { + // await handleServerPortConflict(resolvedUserConfig, logger, mode); + // } resolvedUserConfig.compilation = await normalizeUserCompilationConfig( resolvedUserConfig, - mergedUserConfig, - logger, - mode + 'development' ); - // normalize root path - resolvedUserConfig.root = normalizeBasePath( - resolvedUserConfig.compilation.root - ); + resolvedUserConfig.root = resolvedUserConfig.compilation.root; resolvedUserConfig.jsPlugins = sortFarmJsPlugins; resolvedUserConfig.rustPlugins = rustPlugins; - // Temporarily dealing with alias objects and arrays in js will be unified in rust in the future.] + // // Temporarily dealing with alias objects and arrays in js will be unified in rust in the future.] if (vitePlugins.length) { resolvedUserConfig.compilation.resolve.alias = getAliasEntries( resolvedUserConfig.compilation.resolve.alias @@ -233,7 +199,7 @@ export async function resolveConfig( await resolveConfigResolvedHook(resolvedUserConfig, sortFarmJsPlugins); // Fix: Await the Promise and pass the resolved value to the function. - // TODO Temporarily solve the problem of alias adaptation to vite + // // TODO Temporarily solve the problem of alias adaptation to vite if (resolvedUserConfig.compilation?.resolve?.alias && vitePlugins.length) { resolvedUserConfig.compilation.resolve.alias = transformAliasWithVite( resolvedUserConfig.compilation.resolve.alias as unknown as Array @@ -258,26 +224,22 @@ export async function resolveConfig( */ export async function normalizeUserCompilationConfig( resolvedUserConfig: ResolvedUserConfig, - userConfig: UserConfig, - logger: Logger, mode: CompilationMode = 'development', - isDefault = false + logger: Logger = new Logger() ): Promise { - const { compilation, root = process.cwd(), clearScreen } = resolvedUserConfig; + const { compilation, root, clearScreen } = resolvedUserConfig; // resolve root path + const resolvedRootPath = normalizePath(root); resolvedUserConfig.root = resolvedRootPath; - if (!userConfig.compilation) { - userConfig.compilation = {}; - } - // if normalize default config, skip check input option - const inputIndexConfig = !isDefault - ? checkCompilationInputValue(userConfig, logger) - : {}; + const inputIndexConfig = checkCompilationInputValue( + resolvedUserConfig, + logger + ); const resolvedCompilation: ResolvedCompilation = merge( {}, @@ -299,7 +261,7 @@ export async function normalizeUserCompilationConfig( resolvedCompilation.coreLibPath = bindingPath; normalizeOutput(resolvedCompilation, isProduction, logger); - normalizeExternal(userConfig, resolvedCompilation); + normalizeExternal(resolvedUserConfig, resolvedCompilation); // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore do not check type for this internal option @@ -387,9 +349,9 @@ export async function normalizeUserCompilationConfig( if (!resolvedCompilation.runtime.namespace) { // read package.json name field const packageJsonPath = path.resolve(resolvedRootPath, 'package.json'); - const packageJsonExists = fs.existsSync(packageJsonPath); + const packageJsonExists = fse.existsSync(packageJsonPath); const namespaceName = packageJsonExists - ? JSON.parse(fs.readFileSync(packageJsonPath, { encoding: 'utf-8' })) + ? JSON.parse(fse.readFileSync(packageJsonPath, { encoding: 'utf-8' })) ?.name ?? FARM_DEFAULT_NAMESPACE : FARM_DEFAULT_NAMESPACE; @@ -413,12 +375,14 @@ export async function normalizeUserCompilationConfig( resolvedCompilation.mode = mode; } setProcessEnv(resolvedCompilation.mode); + // TODO add targetEnv `lib-browser` and `lib-node` support const is_entry_html = Object.keys(resolvedCompilation.input).length === 0 || - Object.values(resolvedCompilation.input).some((value) => - value.endsWith('.html') - ); + Object.values(resolvedCompilation.input) + .filter(Boolean) + .some((value) => value.endsWith('.html')); + if ( resolvedCompilation.output.targetEnv !== 'node' && isArray(resolvedCompilation.runtime.plugins) && @@ -546,10 +510,6 @@ export async function normalizeUserCompilationConfig( }; if (resolvedCompilation.script.parser.tsConfig !== undefined) resolvedCompilation.script.parser.tsConfig.decorators = true; - else - userConfig.compilation.script.parser.tsConfig = { - decorators: true - }; } // normalize persistent cache at last @@ -563,7 +523,7 @@ export async function normalizeUserCompilationConfig( } export const DEFAULT_HMR_OPTIONS: Required = { - host: true, + host: 'localhost', port: (process.env.FARM_DEFAULT_HMR_PORT && Number(process.env.FARM_DEFAULT_HMR_PORT)) ?? @@ -571,7 +531,11 @@ export const DEFAULT_HMR_OPTIONS: Required = { path: '/__hmr', overlay: true, protocol: 'ws', - watchOptions: {} + watchOptions: {}, + clientPort: 9000, + timeout: 0, + server: null, + channels: [] }; export const DEFAULT_DEV_SERVER_OPTIONS: NormalizedServerConfig = { @@ -586,6 +550,7 @@ export const DEFAULT_DEV_SERVER_OPTIONS: NormalizedServerConfig = { host: true, proxy: {}, hmr: DEFAULT_HMR_OPTIONS, + middlewareMode: false, open: false, strictPort: false, cors: false, @@ -673,12 +638,13 @@ const formatToExt: Record = { esm: 'mjs' }; -async function readConfigFile( - inlineOptions: FarmCLIOptions, +export async function readConfigFile( + inlineOptions: FarmCliOptions, configFilePath: string, + configEnv: any, logger: Logger ): Promise { - if (fs.existsSync(configFilePath)) { + if (fse.existsSync(configFilePath)) { !__FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ && logger.info(`Using config file at ${bold(green(configFilePath))}`); const format: Format = process.env.FARM_CONFIG_FORMAT @@ -686,8 +652,10 @@ async function readConfigFile( ? 'cjs' : 'esm' : formatFromExt[path.extname(configFilePath).slice(1)] ?? 'esm'; + // we need transform all type farm.config with __dirname and __filename const Compiler = (await import('../compiler/index.js')).Compiler; + const outputPath = path.join( path.dirname(configFilePath), 'node_modules', @@ -699,67 +667,25 @@ async function readConfigFile( .split('.') .join('')}.${formatToExt[format]}`; - const tsDefaultUserConfig: UserConfig = { - root: inlineOptions.root, - compilation: { - input: { - [fileName]: configFilePath - }, - output: { - entryFilename: '[entryName]', - path: outputPath, - format, - targetEnv: 'node' - }, - external: [ - ...(process.env.FARM_CONFIG_FULL_BUNDLE - ? [] - : ['!^(\\./|\\.\\./|[A-Za-z]:\\\\|/).*']), - '^@farmfe/core$' - ], - partialBundling: { - enforceResources: [ - { - name: fileName, - test: ['.+'] - } - ] - }, - watch: false, - sourcemap: false, - treeShaking: false, - minify: false, - presetEnv: false, - lazyCompilation: false, - persistentCache: false, - progress: false - } - }; - - const tsDefaultResolvedUserConfig: ResolvedUserConfig = - await resolveMergedUserConfig( - tsDefaultUserConfig, - undefined, - 'development', - logger - ); - - const normalizedConfig = await normalizeUserCompilationConfig( - tsDefaultResolvedUserConfig, - tsDefaultUserConfig, - logger, - 'development' + const normalizedConfig = await resolveDefaultUserConfig({ + inlineOptions, + configFilePath, + format, + outputPath, + fileName + }); + + const replaceDirnamePlugin = await rustPluginResolver( + 'farm-plugin-replace-dirname', + // normalizedConfig.root!, + process.cwd() ); - const replaceDirnamePlugin = await import( - 'farm-plugin-replace-dirname' - ).then((mod) => mod.default); - const compiler = new Compiler( { config: normalizedConfig, jsPlugins: [], - rustPlugins: [[replaceDirnamePlugin, '{}']] + rustPlugins: [replaceDirnamePlugin] }, logger ); @@ -784,17 +710,11 @@ async function readConfigFile( // Change to vm.module of node or loaders as far as it is stable const userConfig = (await import(filePath as string)).default; try { - fs.unlink(filePath, () => void 0); - // remove parent dir if empty - const isEmpty = fs.readdirSync(outputPath).length === 0; - if (isEmpty) { - fs.rmSync(outputPath); - } + fse.unlink(filePath, () => void 0); } catch { /** do nothing */ } - const configEnv = { mode: inlineOptions.mode ?? process.env.NODE_ENV }; const config = await (typeof userConfig === 'function' ? userConfig(configEnv) : userConfig); @@ -819,7 +739,7 @@ export function normalizePublicDir(root: string, userPublicDir?: string) { } export function checkClearScreen( - inlineConfig: FarmCLIOptions | ResolvedUserConfig + inlineConfig: FarmCliOptions | ResolvedUserConfig ) { if ( inlineConfig?.clearScreen && @@ -891,26 +811,31 @@ export async function resolveMergedUserConfig( * @returns loaded config and config file path */ export async function loadConfigFile( - configPath: string, - inlineOptions: FarmCLIOptions, + configFile: string, + inlineOptions: any, + configEnv: any, logger: Logger = new Logger() -): Promise<{ config: UserConfig; configFilePath: string } | undefined> { - // if configPath points to a directory, try to find a config file in it using default config +): Promise<{ config: any; configFilePath: string } | undefined> { + const { root = '.' } = inlineOptions; + const configRootPath = path.resolve(root); + let resolvedPath: string | undefined; try { - const configFilePath = await getConfigFilePath(configPath); - - if (configFilePath) { - const config = await readConfigFile( - inlineOptions, - configFilePath, - logger - ); - - return { - config: config && parseUserConfig(config), - configFilePath: configFilePath - }; + if (configFile) { + resolvedPath = path.resolve(root, configFile); + } else { + resolvedPath = await getConfigFilePath(configRootPath); } + + const config = await readConfigFile( + inlineOptions, + resolvedPath, + configEnv, + logger + ); + return { + config: config && parseUserConfig(config), + configFilePath: resolvedPath + }; } catch (error) { // In this place, the original use of throw caused emit to the outermost catch // callback, causing the code not to execute. If the internal catch compiler's own @@ -919,7 +844,6 @@ export async function loadConfigFile( const errorMessage = convertErrorMessage(error); const stackTrace = error.code === 'GenericFailure' ? '' : `\n${error.stack}`; - if (inlineOptions.mode === 'production') { logger.error( `Failed to load config file: ${errorMessage} \n${stackTrace}`, @@ -928,10 +852,8 @@ export async function loadConfigFile( } ); } - const potentialSolution = 'Potential solutions: \n1. Try set `FARM_CONFIG_FORMAT=cjs`(default to esm)\n2. Try set `FARM_CONFIG_FULL_BUNDLE=1`'; - throw new Error( `Failed to load farm config file: ${errorMessage}. \n ${potentialSolution} \n ${error.stack}` ); @@ -941,13 +863,14 @@ export async function loadConfigFile( function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { const { compilation } = userConfig; const targetEnv = compilation?.output?.targetEnv; + const inputValue = Object.values(compilation?.input).filter(Boolean); const isTargetNode = targetEnv === 'node'; const defaultHtmlPath = './index.html'; let inputIndexConfig: { index?: string } = { index: '' }; let errorMessage = ''; // Check if input is specified - if (!isEmptyObject(compilation?.input)) { + if (!isEmptyObject(compilation?.input) && inputValue.length) { inputIndexConfig = compilation?.input; } else { if (isTargetNode) { @@ -989,22 +912,19 @@ function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { } export async function getConfigFilePath( - configPath: string + configRootPath: string ): Promise { - if (fs.statSync(configPath).isDirectory()) { + if (fse.statSync(configRootPath).isDirectory()) { for (const name of DEFAULT_CONFIG_NAMES) { - const resolvedPath = path.join(configPath, name); + const resolvedPath = path.join(configRootPath, name); const isFile = - fs.existsSync(resolvedPath) && fs.statSync(resolvedPath).isFile(); + fse.existsSync(resolvedPath) && fse.statSync(resolvedPath).isFile(); if (isFile) { return resolvedPath; } } - } else if (fs.statSync(configPath).isFile()) { - return configPath; } - return undefined; } @@ -1037,3 +957,108 @@ export async function resolvePlugins( vitePluginAdapters }; } + +export async function resolveDefaultUserConfig(options: any) { + const { inlineOptions, format, outputPath, fileName, configFilePath } = + options; + const defaultConfig: UserConfig = { + root: path.resolve(inlineOptions.root ?? '.'), + compilation: { + input: { + [fileName]: configFilePath + }, + output: { + entryFilename: '[entryName]', + path: outputPath, + format, + targetEnv: 'node' + }, + external: [ + ...(process.env.FARM_CONFIG_FULL_BUNDLE + ? [] + : ['!^(\\./|\\.\\./|[A-Za-z]:\\\\|/).*']), + '^@farmfe/core$' + ], + partialBundling: { + enforceResources: [ + { + name: fileName, + test: ['.+'] + } + ] + }, + watch: false, + sourcemap: false, + treeShaking: false, + minify: false, + presetEnv: false, + lazyCompilation: false, + persistentCache: false, + progress: false + } + }; + + const resolvedUserConfig: ResolvedUserConfig = await resolveUserConfig( + defaultConfig, + undefined, + 'development' + ); + + const normalizedConfig = await normalizeUserCompilationConfig( + resolvedUserConfig, + 'development' + ); + + return normalizedConfig; +} + +export async function resolveUserConfig( + userConfig: UserConfig, + configFilePath: string | undefined, + mode: 'development' | 'production' | string, + logger: Logger = new Logger() +): Promise { + const resolvedUserConfig = { + ...userConfig + } as ResolvedUserConfig; + + // set internal config + resolvedUserConfig.envMode = mode; + + if (configFilePath) { + const dependencies = await traceDependencies(configFilePath, logger); + dependencies.sort(); + resolvedUserConfig.configFileDependencies = dependencies; + resolvedUserConfig.configFilePath = configFilePath; + } + + const resolvedRootPath = resolvedUserConfig.root ?? process.cwd(); + const resolvedEnvPath = resolvedUserConfig.envDir + ? resolvedUserConfig.envDir + : resolvedRootPath; + + const userEnv = loadEnv( + resolvedUserConfig.envMode ?? mode, + resolvedEnvPath, + resolvedUserConfig.envPrefix + ); + const existsEnvFiles = getExistsEnvFiles( + resolvedUserConfig.envMode ?? mode, + resolvedEnvPath + ); + + resolvedUserConfig.envFiles = [ + ...(Array.isArray(resolvedUserConfig.envFiles) + ? resolvedUserConfig.envFiles + : []), + ...existsEnvFiles + ]; + + resolvedUserConfig.env = { + ...userEnv, + NODE_ENV: userConfig.compilation.mode ?? mode, + mode: mode + }; + + return resolvedUserConfig; +} diff --git a/packages/core/src/config/mergeConfig.ts b/packages/core/src/config/mergeConfig.ts index f58578b625..d7cfc9f18d 100644 --- a/packages/core/src/config/mergeConfig.ts +++ b/packages/core/src/config/mergeConfig.ts @@ -1,7 +1,7 @@ import path, { isAbsolute } from 'node:path'; import { isString } from '../plugin/js/utils.js'; import { isArray, isObject } from '../utils/share.js'; -import { FarmCLIOptions, UserConfig } from './types.js'; +import { FarmCliOptions, UserConfig } from './types.js'; // eslint-disable-next-line @typescript-eslint/no-explicit-any export function mergeConfig>( @@ -46,10 +46,11 @@ export function mergeConfig>( } export function mergeFarmCliConfig( - cliOption: FarmCLIOptions & UserConfig, + cliOption: FarmCliOptions & UserConfig, target: UserConfig ): UserConfig { let left: UserConfig = {}; + const options = initialCliOptions(cliOption); ( [ @@ -62,10 +63,10 @@ export function mergeFarmCliConfig( 'server', 'vitePlugins' ] satisfies (keyof UserConfig)[] - ).forEach((key) => { - const value = cliOption[key]; + ).forEach((key: keyof (FarmCliOptions & UserConfig)) => { + const value = options[key]; if (value || typeof value === 'boolean') { - left = mergeConfig(left, { [key]: cliOption[key] }); + left = mergeConfig(left, { [key]: options[key] }); } }); @@ -77,12 +78,12 @@ export function mergeFarmCliConfig( const cliRoot = cliOption.root; if (!isAbsolute(cliRoot)) { - target.root = path.resolve(process.cwd(), cliRoot); + target.root = path.resolve(cliRoot); } else { target.root = cliRoot; } } else { - target.root = process.cwd(); + target.root = path.resolve('.'); } if (configRootPath) { @@ -95,55 +96,87 @@ export function mergeFarmCliConfig( } } - if (isString(cliOption.host) || typeof cliOption.host === 'boolean') { - left = mergeConfig(left, { server: { host: cliOption.host } }); + if (isString(options.host) || typeof options.host === 'boolean') { + left = mergeConfig(left, { server: { host: options.host } }); } - if (typeof cliOption.minify === 'boolean') { - left = mergeConfig(left, { compilation: { minify: cliOption.minify } }); + if (typeof options.minify === 'boolean') { + left = mergeConfig(left, { compilation: { minify: options.minify } }); } - if (cliOption.outDir) { + if (options.outDir) { left = mergeConfig(left, { - compilation: { output: { path: cliOption.outDir } } + compilation: { output: { path: options.outDir } } }); } - if (cliOption.port) { + if (options.port) { left = mergeConfig(left, { server: { - port: cliOption.port + port: options.port } }); } - if (cliOption.mode) { + if (options.mode) { left = mergeConfig(left, { compilation: { - mode: cliOption.mode as UserConfig['compilation']['mode'] + mode: options.mode as UserConfig['compilation']['mode'] } }); } - if (cliOption.https) { + if (options.https) { left = mergeConfig(left, { server: { - https: cliOption.https + https: options.https } }); } - if (cliOption.sourcemap) { + if (options.sourcemap) { left = mergeConfig(left, { - compilation: { sourcemap: cliOption.sourcemap } + compilation: { sourcemap: options.sourcemap } }); } return mergeConfig(left, target); } -export function initialCliOptions(options: FarmCLIOptions): FarmCLIOptions { - return { - ...options +export function initialCliOptions(options: any): any { + const { + input, + outDir, + target, + format, + watch, + minify, + sourcemap, + treeShaking, + mode + } = options; + + const output: UserConfig['compilation']['output'] = { + ...(outDir && { path: outDir }), + ...(target && { targetEnv: target }), + ...(format && { format }) }; + + const compilation: UserConfig['compilation'] = { + input: { ...(input && { index: input }) }, + output, + ...(watch && { watch }), + ...(minify && { minify }), + ...(sourcemap && { sourcemap }), + ...(treeShaking && { treeShaking }) + }; + + const defaultOptions: any = { + compilation, + root: options.root, + configFile: options.configFile, + ...(mode && { mode }) + }; + + return defaultOptions; } diff --git a/packages/core/src/config/schema.ts b/packages/core/src/config/schema.ts index 6e47e2e991..433056ba07 100644 --- a/packages/core/src/config/schema.ts +++ b/packages/core/src/config/schema.ts @@ -44,8 +44,7 @@ const compilationConfigSchema = z 'browser-legacy', 'browser-esnext', 'browser-es2015', - 'browser-es2017', - 'library' + 'browser-es2017' ]) .optional(), format: z.enum(['cjs', 'esm']).optional() @@ -217,8 +216,7 @@ const compilationConfigSchema = z z.literal('minify-module'), z.literal('minify-resource-pot') ]) - .optional(), - moduleDecls: z.boolean().optional() + .optional() }) ]) .optional(), diff --git a/packages/core/src/config/types.ts b/packages/core/src/config/types.ts index d736ff7616..96e454f1ab 100644 --- a/packages/core/src/config/types.ts +++ b/packages/core/src/config/types.ts @@ -10,9 +10,12 @@ import type { RustPlugin } from '../plugin/rust/index.js'; import type { JsPlugin } from '../plugin/type.js'; import type { Options } from 'http-proxy-middleware'; import type { Logger } from '../utils/index.js'; +import { HmrOptions } from '../newServer/index.js'; export interface ConfigEnv { mode: string; + command: string; + isPreview: boolean; } export type UserConfigFnPromise = (env: ConfigEnv) => Promise; @@ -42,6 +45,7 @@ export interface UserServerConfig { // whether to serve static assets in spa mode, default to true spa?: boolean; middlewares?: DevServerMiddleware[]; + middlewareMode?: boolean | string; writeToDisk?: boolean; } @@ -56,7 +60,7 @@ export interface UserPreviewServerConfig { export type NormalizedServerConfig = Required< Omit & { - hmr?: Required; + hmr?: UserHmrConfig; } >; @@ -65,12 +69,7 @@ export interface NormalizedConfig { serverConfig?: NormalizedServerConfig; } -export interface UserHmrConfig { - host?: string | boolean; - port?: number; - path?: string; - overlay?: boolean; - protocol?: string; +export interface UserHmrConfig extends HmrOptions { watchOptions?: WatchOptions; } @@ -125,7 +124,7 @@ export interface ResolvedUserConfig extends UserConfig { rustPlugins?: [string, string][]; } -export interface GlobalFarmCLIOptions { +export interface GlobalCliOptions { '--'?: string[]; c?: boolean | string; config?: string; @@ -155,11 +154,12 @@ export interface FarmCLIPreviewOptions { host?: string | boolean; } -export interface FarmCLIOptions +export interface FarmCliOptions extends FarmCLIBuildOptions, - FarmCLIPreviewOptions { + FarmCLIPreviewOptions { logger?: Logger; config?: string; + configFile?: string; configPath?: string; compilation?: Config['config']; mode?: string; diff --git a/packages/core/src/index.ts b/packages/core/src/index.ts index 3fac0c1c2a..ddfe375bbe 100644 --- a/packages/core/src/index.ts +++ b/packages/core/src/index.ts @@ -46,7 +46,7 @@ import { FileWatcher } from './watcher/index.js'; import { __FARM_GLOBAL__ } from './config/_global.js'; import type { - FarmCLIOptions, + FarmCliOptions, ResolvedUserConfig, UserPreviewServerConfig } from './config/types.js'; @@ -58,7 +58,7 @@ import { ConfigWatcher } from './watcher/config-watcher.js'; import type { JsPlugin } from './plugin/type.js'; export async function start( - inlineConfig?: FarmCLIOptions & UserConfig + inlineConfig?: FarmCliOptions & UserConfig ): Promise { inlineConfig = inlineConfig ?? {}; const logger = inlineConfig.logger ?? new Logger(); @@ -67,10 +67,42 @@ export async function start( try { const resolvedUserConfig = await resolveConfig( inlineConfig, + 'start', 'development', + 'development', + false + ); + + const compiler = await createCompiler(resolvedUserConfig, logger); + + const devServer = await createDevServer( + compiler, + resolvedUserConfig, logger ); + await devServer.listen(); + } catch (error) { + logger.error('Failed to start the server', { exit: true, error }); + } +} + +export async function startRefactorCli( + inlineConfig?: FarmCliOptions & UserConfig +): Promise { + inlineConfig = inlineConfig ?? {}; + const logger = inlineConfig.logger ?? new Logger(); + setProcessEnv('development'); + + try { + const resolvedUserConfig = await resolveConfig( + inlineConfig, + 'start', + 'development', + 'development', + false + ); + const compiler = await createCompiler(resolvedUserConfig, logger); const devServer = await createDevServer( @@ -85,8 +117,32 @@ export async function start( } } +export async function buildRefactorCli( + inlineConfig?: FarmCliOptions & UserConfig +): Promise { + inlineConfig = inlineConfig ?? {}; + const logger = inlineConfig.logger ?? new Logger(); + setProcessEnv('production'); + + try { + const resolvedUserConfig = await resolveConfig( + inlineConfig, + 'build', + 'production', + 'production', + false + ); + + await createBundleHandler(resolvedUserConfig, logger); + // copy resources under publicDir to output.path + await copyPublicDirectory(resolvedUserConfig, logger); + } catch (err) { + logger.error(`Failed to build: ${err}`, { exit: true }); + } +} + export async function build( - inlineConfig?: FarmCLIOptions & UserConfig + inlineConfig?: FarmCliOptions & UserConfig ): Promise { inlineConfig = inlineConfig ?? {}; const logger = inlineConfig.logger ?? new Logger(); @@ -94,8 +150,9 @@ export async function build( const resolvedUserConfig = await resolveConfig( inlineConfig, + 'build', + 'production', 'production', - logger, false ); @@ -108,13 +165,15 @@ export async function build( } } -export async function preview(inlineConfig?: FarmCLIOptions): Promise { +export async function preview(inlineConfig?: FarmCliOptions): Promise { inlineConfig = inlineConfig ?? {}; const logger = inlineConfig.logger ?? new Logger(); const resolvedUserConfig = await resolveConfig( inlineConfig, + 'preview', 'production', - logger + 'production', + true ); const { root, output } = resolvedUserConfig.compilation; @@ -154,7 +213,7 @@ export async function preview(inlineConfig?: FarmCLIOptions): Promise { } export async function watch( - inlineConfig?: FarmCLIOptions & UserConfig + inlineConfig?: FarmCliOptions & UserConfig ): Promise { inlineConfig = inlineConfig ?? {}; const logger = inlineConfig.logger ?? new Logger(); @@ -162,9 +221,10 @@ export async function watch( const resolvedUserConfig = await resolveConfig( inlineConfig, - 'development', - logger, - true + 'build', + 'production', + 'production', + false ); const hostname = await resolveHostname(resolvedUserConfig.server.host); @@ -428,7 +488,7 @@ export async function createFileWatcher( await devServer.close(); __FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ = true; - await start(resolvedUserConfig as FarmCLIOptions & UserConfig); + await start(resolvedUserConfig as FarmCliOptions & UserConfig); }); }); return fileWatcher; diff --git a/packages/core/src/utils/share.ts b/packages/core/src/utils/share.ts index a086b26c94..5a6316f87d 100644 --- a/packages/core/src/utils/share.ts +++ b/packages/core/src/utils/share.ts @@ -71,7 +71,7 @@ export const version = JSON.parse( ).version; export function normalizePath(id: string): string { - return path.posix.normalize(id); + return path.posix.normalize(isWindows ? id.replace(/\\/g, '/') : id); } export function normalizeBasePath(basePath: string): string { diff --git a/packages/core/tests/common.ts b/packages/core/tests/common.ts index ef997a5a74..72346e06c0 100644 --- a/packages/core/tests/common.ts +++ b/packages/core/tests/common.ts @@ -49,9 +49,8 @@ export async function getCompiler( const compilationConfig = await normalizeUserCompilationConfig( resolvedUserConfig, - userConfig, - new Logger(), - 'production' + 'production', + new Logger() ); return new Compiler({ diff --git a/packages/core/tsconfig.build.json b/packages/core/tsconfig.build.json index 4f16e9c00d..0646acb6ca 100644 --- a/packages/core/tsconfig.build.json +++ b/packages/core/tsconfig.build.json @@ -7,7 +7,7 @@ "noUnusedLocals": false }, "include": ["src/**/*.ts", "binding/**/*.d.ts"], - "exclude": ["src/**/*.spec.ts", "src/newServer/**"], + "exclude": ["src/**/*.spec.ts"], "references": [ { "path": "../utils/tsconfig.json" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 4983d91ea0..78c3036726 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -1104,6 +1104,37 @@ importers: specifier: ^0.14.0 version: 0.14.0 + examples/refactor-react: + dependencies: + react: + specifier: '18' + version: 18.2.0 + react-dom: + specifier: '18' + version: 18.2.0(react@18.2.0) + devDependencies: + '@farmfe/cli': + specifier: workspace:* + version: link:../../packages/cli + '@farmfe/core': + specifier: workspace:* + version: link:../../packages/core + '@farmfe/plugin-react': + specifier: ^1.2.0 + version: 1.2.0 + '@types/react': + specifier: '18' + version: 18.2.35 + '@types/react-dom': + specifier: '18' + version: 18.2.14 + core-js: + specifier: ^3.36.1 + version: 3.36.1 + react-refresh: + specifier: ^0.14.0 + version: 0.14.0 + examples/resolve-module-graph: devDependencies: '@farmfe/cli': @@ -3826,6 +3857,63 @@ packages: engines: {node: '>= 16'} hasBin: true + '@farmfe/plugin-react-darwin-arm64@1.2.0': + resolution: {integrity: sha512-9a8wp6lg8NytO+kU8hu2gCFer+PL4TJ92SkU/5v9xdcsioElWpnMDGlwcoI8bXqi60/WR8RyExsDIBubCgjbXQ==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [darwin] + + '@farmfe/plugin-react-darwin-x64@1.2.0': + resolution: {integrity: sha512-JXkdg3zmevlf+kbdd05+6x+L/l2IYY7Vm4hqkymbxlVdaFd2ydHmyMk9ekcmtkOijlUtEYoD3a9whstzvJ+FkA==} + engines: {node: '>= 10'} + cpu: [x64] + os: [darwin] + + '@farmfe/plugin-react-linux-arm64-gnu@1.2.0': + resolution: {integrity: sha512-B98ldEqeJn6Uesnxr13Y/nFfIP4Qr8Svcd3mJqaOFcaOF9OZvRYFvQha1DRAoBrp8VhntghijqoWJeC1qKUhKw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@farmfe/plugin-react-linux-arm64-musl@1.2.0': + resolution: {integrity: sha512-o49P/vCWlqAkFeIVtZqy1OyyIlGHr2w+O9ty5ojwMGXGXHOrvBi1IL2ItlFqxUawweli6mNspDO0bJSJZ51gOw==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [linux] + + '@farmfe/plugin-react-linux-x64-gnu@1.2.0': + resolution: {integrity: sha512-Z1hX52mHllxXn6GolTpuN3sqmz8yku6N/rs0NHbjezgyRPWFWOMS7fnD6SMf/TPvRPGeRX1bj49rr9GMqsQEgQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@farmfe/plugin-react-linux-x64-musl@1.2.0': + resolution: {integrity: sha512-eZzEE9eCeteIpsQr1u4dnFzEEisYuuUIVhbNZX8mPCBYQ9ZB6RXMZYj3lmHgl3qNGagxH26msqcpr7t3U8qPuQ==} + engines: {node: '>= 10'} + cpu: [x64] + os: [linux] + + '@farmfe/plugin-react-win32-arm64-msvc@1.2.0': + resolution: {integrity: sha512-JluDXSQFs3s5txZghCbeqdOjtocSW4vaoQWgcQQ88zpFrTlqqwg4xnrXdeC3CqgeNcVq5ZMJtx2VwsJqITvPxg==} + engines: {node: '>= 10'} + cpu: [arm64] + os: [win32] + + '@farmfe/plugin-react-win32-ia32-msvc@1.2.0': + resolution: {integrity: sha512-b6I+qSG8+a59YE0d2J+QLWDi5qxQUY1C/TeYvGUBeoOs7/pCKdznvd2eQJ5N9Yvafzn6zlN9//oz1A/VLvqSBg==} + engines: {node: '>= 10'} + cpu: [ia32] + os: [win32] + + '@farmfe/plugin-react-win32-x64-msvc@1.2.0': + resolution: {integrity: sha512-9GWEdbvGUB+ovdAAQhHF7l4v0MaTXjOIoQZd4g6+rGDQtMIx4d1M6EOPx4D1Yn9/+dI1157UWWt9PK9Lod2h+w==} + engines: {node: '>= 10'} + cpu: [x64] + os: [win32] + + '@farmfe/plugin-react@1.2.0': + resolution: {integrity: sha512-S5kU7NgqiyyhnDsZ7DEvszQIE6sCA0CNp7oTbdDcPxotPNBoyOcBHviSP3P5jvtIv6mmlF8Me2C1aLWJQRw9PA==} + '@farmfe/plugin-sass-darwin-arm64@1.0.5': resolution: {integrity: sha512-0uRiWqEjLUjEQbaJBXFKCdp4P++00vHE0WegUBgA7KpnQ8USWBJEJ+AQklBKuZitjpqlkJqCsq09bEmkwzEVYA==} engines: {node: '>= 10'} @@ -6208,12 +6296,12 @@ packages: builder-util@24.13.1: resolution: {integrity: sha512-NhbCSIntruNDTOVI9fdXz0dihaqX2YuE1D6zZMrwiErzH4ELZHE6mdiB40wEgZNprDia+FghRFgKoAqMZRRjSA==} - bundle-name@4.1.0: - resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} - engines: {node: '>=18'} bundle-n-require@1.1.1: resolution: {integrity: sha512-EB2wFjXF106LQLe/CYnKCMCdLeTW47AtcEtUfiqAOgr2a08k0+YgRklur2aLfEYHlhz6baMskZ8L2U92Hh0vyA==} + bundle-name@4.1.0: + resolution: {integrity: sha512-tjwM5exMg6BGRI+kNmTntNsvdZS1X8BFYS6tnJ2hdH0kVxM6/eVZ2xy+FqStSWvYmtfFMDLIxurorHwDKfDz5Q==} + engines: {node: '>=18'} busboy@1.6.0: resolution: {integrity: sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==} @@ -15383,6 +15471,45 @@ snapshots: inquirer: 9.2.11 walkdir: 0.4.1 + '@farmfe/plugin-react-darwin-arm64@1.2.0': + optional: true + + '@farmfe/plugin-react-darwin-x64@1.2.0': + optional: true + + '@farmfe/plugin-react-linux-arm64-gnu@1.2.0': + optional: true + + '@farmfe/plugin-react-linux-arm64-musl@1.2.0': + optional: true + + '@farmfe/plugin-react-linux-x64-gnu@1.2.0': + optional: true + + '@farmfe/plugin-react-linux-x64-musl@1.2.0': + optional: true + + '@farmfe/plugin-react-win32-arm64-msvc@1.2.0': + optional: true + + '@farmfe/plugin-react-win32-ia32-msvc@1.2.0': + optional: true + + '@farmfe/plugin-react-win32-x64-msvc@1.2.0': + optional: true + + '@farmfe/plugin-react@1.2.0': + optionalDependencies: + '@farmfe/plugin-react-darwin-arm64': 1.2.0 + '@farmfe/plugin-react-darwin-x64': 1.2.0 + '@farmfe/plugin-react-linux-arm64-gnu': 1.2.0 + '@farmfe/plugin-react-linux-arm64-musl': 1.2.0 + '@farmfe/plugin-react-linux-x64-gnu': 1.2.0 + '@farmfe/plugin-react-linux-x64-musl': 1.2.0 + '@farmfe/plugin-react-win32-arm64-msvc': 1.2.0 + '@farmfe/plugin-react-win32-ia32-msvc': 1.2.0 + '@farmfe/plugin-react-win32-x64-msvc': 1.2.0 + '@farmfe/plugin-sass-darwin-arm64@1.0.5': optional: true @@ -16214,9 +16341,8 @@ snapshots: '@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': dependencies: - '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(sass@1.74.1)(terser@5.31.1)) + '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) debug: 4.3.5 - svelte: 4.0.0 vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: @@ -19218,7 +19344,7 @@ snapshots: dependencies: esbuild: 0.20.2 node-eval: 2.0.0 - + bundle-name@4.1.0: dependencies: run-applescript: 7.0.0 From 72f88b891569d620f222f595f1fd4c425915d742 Mon Sep 17 00:00:00 2001 From: ADNY <66500121+ErKeLost@users.noreply.github.com> Date: Tue, 23 Jul 2024 16:03:56 +0800 Subject: [PATCH 4/9] chore: optimize core logic (#1657) * chore: optimize core package logic * chore: optimize config * chore: optimize code --- examples/refactor-react/farm.config.ts | 5 +- packages/core/src/config/index.ts | 555 +++++++++++------------- packages/core/src/config/mergeConfig.ts | 5 +- 3 files changed, 266 insertions(+), 299 deletions(-) diff --git a/examples/refactor-react/farm.config.ts b/examples/refactor-react/farm.config.ts index 6ab6a340c1..5e9d17aa52 100644 --- a/examples/refactor-react/farm.config.ts +++ b/examples/refactor-react/farm.config.ts @@ -5,6 +5,9 @@ export default defineConfig({ compilation: { presetEnv: false, progress: false, - sourcemap: false + sourcemap: false, + runtime: { + isolate: true + } } }); diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts index 15ed769b07..783d91af29 100644 --- a/packages/core/src/config/index.ts +++ b/packages/core/src/config/index.ts @@ -87,20 +87,6 @@ export function defineFarmConfig(config: UserConfigExport): UserConfigExport { return config; } -export async function handleServerPortConflict( - resolvedUserConfig: ResolvedUserConfig, - logger: Logger, - mode?: CompilationMode -) { - // check port availability: auto increment the port if a conflict occurs - - try { - mode !== 'production' && - (await Server.resolvePortConflict(resolvedUserConfig.server, logger)); - // eslint-disable-next-line no-empty - } catch {} -} - /** * Resolve and load user config from the specified path * @param configPath @@ -115,44 +101,48 @@ export async function resolveConfig( ): Promise { logger = logger ?? new Logger(); - let mode = defaultMode; - const envMode = inlineOptions.mode || defaultMode; + const compileMode = defaultMode; + const mode = inlineOptions.mode || defaultMode; const isNodeEnvSet = !!process.env.NODE_ENV; - inlineOptions.mode = inlineOptions.mode ?? mode; + inlineOptions.mode = mode; + if (!isNodeEnvSet) { setProcessEnv(defaultNodeEnv); } const configEnv: ConfigEnv = { - mode: envMode, + mode, command, isPreview }; // configPath may be file or directory - let { configPath } = inlineOptions; - const { configFile } = inlineOptions; + const { configFile, configPath: initialConfigPath } = inlineOptions; const loadedUserConfig: any = await loadConfigFile( configFile, inlineOptions, configEnv ); - let rawConfig: UserConfig = mergeFarmCliConfig(inlineOptions, {}); + let rawConfig: UserConfig = mergeFarmCliConfig( + inlineOptions, + {}, + compileMode + ); + let configPath = initialConfigPath; if (loadedUserConfig) { configPath = loadedUserConfig.configFilePath; rawConfig = mergeConfig(rawConfig, loadedUserConfig.config); } - rawConfig.compilation.mode = - loadedUserConfig?.config?.compilation?.mode ?? mode; + const { config: userConfig, configFilePath } = { configFilePath: configPath, config: rawConfig }; const { jsPlugins, vitePlugins, rustPlugins, vitePluginAdapters } = - await resolvePlugins(userConfig, logger, mode); + await resolvePlugins(userConfig, compileMode, logger); const sortFarmJsPlugins = getSortedPlugins([ ...jsPlugins, @@ -162,19 +152,17 @@ export async function resolveConfig( const config = await resolveConfigHook(userConfig, sortFarmJsPlugins); - const mergedUserConfig = mergeFarmCliConfig(inlineOptions, config); - const resolvedUserConfig = await resolveUserConfig( - mergedUserConfig, + config, configFilePath, - mode, + compileMode, logger ); // normalize server config first cause it may be used in normalizeUserCompilationFnConfig resolvedUserConfig.server = normalizeDevServerConfig( resolvedUserConfig.server, - mode + compileMode ); // if (isHandleServerPortConflict) { @@ -190,7 +178,7 @@ export async function resolveConfig( resolvedUserConfig.jsPlugins = sortFarmJsPlugins; resolvedUserConfig.rustPlugins = rustPlugins; - // // Temporarily dealing with alias objects and arrays in js will be unified in rust in the future.] + // Temporarily dealing with alias objects and arrays in js will be unified in rust in the future.] if (vitePlugins.length) { resolvedUserConfig.compilation.resolve.alias = getAliasEntries( resolvedUserConfig.compilation.resolve.alias @@ -199,7 +187,7 @@ export async function resolveConfig( await resolveConfigResolvedHook(resolvedUserConfig, sortFarmJsPlugins); // Fix: Await the Promise and pass the resolved value to the function. - // // TODO Temporarily solve the problem of alias adaptation to vite + //TODO Temporarily solve the problem of alias adaptation to vite if (resolvedUserConfig.compilation?.resolve?.alias && vitePlugins.length) { resolvedUserConfig.compilation.resolve.alias = transformAliasWithVite( resolvedUserConfig.compilation.resolve.alias as unknown as Array @@ -236,7 +224,7 @@ export async function normalizeUserCompilationConfig( resolvedUserConfig.root = resolvedRootPath; // if normalize default config, skip check input option - const inputIndexConfig = checkCompilationInputValue( + const inputIndexConfig = await checkCompilationInputValue( resolvedUserConfig, logger ); @@ -266,9 +254,7 @@ export async function normalizeUserCompilationConfig( // eslint-disable-next-line @typescript-eslint/ban-ts-comment // @ts-ignore do not check type for this internal option if (!resolvedCompilation.assets?.publicDir) { - if (!resolvedCompilation.assets) { - resolvedCompilation.assets = {}; - } + resolvedCompilation.assets ??= {}; const userPublicDir = resolvedUserConfig.publicDir ? resolvedUserConfig.publicDir @@ -330,20 +316,15 @@ export async function normalizeUserCompilationConfig( if (!resolvedCompilation.runtime.plugins) { resolvedCompilation.runtime.plugins = []; } else { + const resolvePluginPath = (plugin: any) => { + if (path.isAbsolute(plugin)) return plugin; + return plugin.startsWith('.') + ? path.resolve(resolvedRootPath, plugin) + : require.resolve(plugin); + }; // make sure all plugin paths are absolute resolvedCompilation.runtime.plugins = - resolvedCompilation.runtime.plugins.map((plugin) => { - if (!path.isAbsolute(plugin)) { - if (!plugin.startsWith('.')) { - // resolve plugin from node_modules - return require.resolve(plugin); - } else { - return path.resolve(resolvedRootPath, plugin); - } - } - - return plugin; - }); + resolvedCompilation.runtime.plugins.map(resolvePluginPath); } // set namespace to package.json name field's hash if (!resolvedCompilation.runtime.namespace) { @@ -364,24 +345,19 @@ export async function normalizeUserCompilationConfig( if (isProduction) { resolvedCompilation.lazyCompilation = false; } else if (resolvedCompilation.lazyCompilation === undefined) { - if (isDevelopment) { - resolvedCompilation.lazyCompilation = true; - } else { - resolvedCompilation.lazyCompilation = false; - } + resolvedCompilation.lazyCompilation ??= isDevelopment; } - if (resolvedCompilation.mode === undefined) { - resolvedCompilation.mode = mode; - } + resolvedCompilation.mode ??= mode; + setProcessEnv(resolvedCompilation.mode); // TODO add targetEnv `lib-browser` and `lib-node` support const is_entry_html = - Object.keys(resolvedCompilation.input).length === 0 || - Object.values(resolvedCompilation.input) - .filter(Boolean) - .some((value) => value.endsWith('.html')); + !resolvedCompilation.input || + Object.values(resolvedCompilation.input).some( + (value) => value && value.endsWith('.html') + ); if ( resolvedCompilation.output.targetEnv !== 'node' && @@ -439,11 +415,7 @@ export async function normalizeUserCompilationConfig( } if (resolvedCompilation.treeShaking === undefined) { - if (isProduction) { - resolvedCompilation.treeShaking = true; - } else { - resolvedCompilation.treeShaking = false; - } + resolvedCompilation.treeShaking ??= isProduction; } if (resolvedCompilation.script?.plugins?.length) { @@ -469,19 +441,11 @@ export async function normalizeUserCompilationConfig( } if (resolvedCompilation.minify === undefined) { - if (isProduction) { - resolvedCompilation.minify = true; - } else { - resolvedCompilation.minify = false; - } + resolvedCompilation.minify ??= isProduction; } if (resolvedCompilation.presetEnv === undefined) { - if (isProduction) { - resolvedCompilation.presetEnv = true; - } else { - resolvedCompilation.presetEnv = false; - } + resolvedCompilation.presetEnv ??= isProduction; } // setting the custom configuration @@ -584,12 +548,20 @@ export const DEFAULT_COMPILATION_OPTIONS: Partial = { }; // eslint-disable-next-line @typescript-eslint/no-explicit-any -function tryAsFileRead(value?: any): string | Buffer { - if (typeof value === 'string' && fs.existsSync(value)) { - return fs.readFileSync(path.resolve(value.toString())); + +function tryHttpsAsFileRead(value: unknown): string | Buffer | unknown { + if (typeof value === 'string') { + try { + const resolvedPath = path.resolve(value); + const stats = fs.statSync(resolvedPath); + + if (stats.isFile()) { + return fs.readFileSync(resolvedPath); + } + } catch {} } - return value; + return Buffer.isBuffer(value) ? value : value; } export function normalizeDevServerConfig( @@ -616,10 +588,10 @@ export function normalizeDevServerConfig( https: https ? { ...https, - ca: tryAsFileRead(options.https.ca), - cert: tryAsFileRead(options.https.cert), - key: tryAsFileRead(options.https.key), - pfx: tryAsFileRead(options.https.pfx) + ca: tryHttpsAsFileRead(options.https.ca), + cert: tryHttpsAsFileRead(options.https.cert), + key: tryHttpsAsFileRead(options.https.key), + pfx: tryHttpsAsFileRead(options.https.pfx) } : undefined }) as NormalizedServerConfig; @@ -644,57 +616,56 @@ export async function readConfigFile( configEnv: any, logger: Logger ): Promise { - if (fse.existsSync(configFilePath)) { - !__FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ && - logger.info(`Using config file at ${bold(green(configFilePath))}`); - const format: Format = process.env.FARM_CONFIG_FORMAT - ? process.env.FARM_CONFIG_FORMAT === 'cjs' - ? 'cjs' - : 'esm' - : formatFromExt[path.extname(configFilePath).slice(1)] ?? 'esm'; + if (!fse.existsSync(configFilePath)) return; + if (!__FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__) { + logger.info(`Using config file at ${bold(green(configFilePath))}`); + } - // we need transform all type farm.config with __dirname and __filename - const Compiler = (await import('../compiler/index.js')).Compiler; + const format = getFormat(configFilePath); - const outputPath = path.join( - path.dirname(configFilePath), - 'node_modules', - '.farm' - ); + // we need transform all type farm.config with __dirname and __filename + const Compiler = (await import('../compiler/index.js')).Compiler; - const fileName = `farm.config.bundle-${Date.now()}-${Math.random() - .toString(16) - .split('.') - .join('')}.${formatToExt[format]}`; + const outputPath = path.join( + path.dirname(configFilePath), + 'node_modules', + '.farm' + ); - const normalizedConfig = await resolveDefaultUserConfig({ - inlineOptions, - configFilePath, - format, - outputPath, - fileName - }); - - const replaceDirnamePlugin = await rustPluginResolver( - 'farm-plugin-replace-dirname', - // normalizedConfig.root!, - process.cwd() - ); + const fileName = `farm.config.bundle-${Date.now()}-${Math.random() + .toString(16) + .split('.') + .join('')}.${formatToExt[format]}`; - const compiler = new Compiler( - { - config: normalizedConfig, - jsPlugins: [], - rustPlugins: [replaceDirnamePlugin] - }, - logger - ); + const normalizedConfig = await resolveDefaultUserConfig({ + inlineOptions, + configFilePath, + format, + outputPath, + fileName + }); + + const replaceDirnamePlugin = await rustPluginResolver( + 'farm-plugin-replace-dirname', + normalizedConfig.root + ); - const FARM_PROFILE = process.env.FARM_PROFILE; - // disable FARM_PROFILE in farm_config - if (FARM_PROFILE) { - process.env.FARM_PROFILE = ''; - } + const compiler = new Compiler( + { + config: normalizedConfig, + jsPlugins: [], + rustPlugins: [replaceDirnamePlugin] + }, + logger + ); + + const FARM_PROFILE = process.env.FARM_PROFILE; + // disable FARM_PROFILE in farm_config + if (FARM_PROFILE) { + process.env.FARM_PROFILE = ''; + } + + try { await compiler.compile(); if (FARM_PROFILE) { @@ -703,107 +674,33 @@ export async function readConfigFile( compiler.writeResourcesToDisk(); - const filePath = isWindows - ? pathToFileURL(path.join(outputPath, fileName)) - : path.join(outputPath, fileName); - + const filePath = getFilePath(outputPath, fileName); // Change to vm.module of node or loaders as far as it is stable - const userConfig = (await import(filePath as string)).default; - try { - fse.unlink(filePath, () => void 0); - } catch { - /** do nothing */ - } + const { default: userConfig } = await import(filePath); const config = await (typeof userConfig === 'function' ? userConfig(configEnv) : userConfig); - if (!config.root) { - config.root = inlineOptions.root; - } - if (!isObject(config)) { throw new Error(`config must export or return an object.`); } + + config.root ??= inlineOptions.root; + return config; + } finally { + fse.unlink(getFilePath(outputPath, fileName)).catch(() => {}); } } -export function normalizePublicDir(root: string, userPublicDir?: string) { - const publicDir = userPublicDir ?? 'public'; +export function normalizePublicDir(root: string, publicDir = 'public') { const absPublicDirPath = path.isAbsolute(publicDir) ? publicDir - : path.join(root, publicDir); + : path.resolve(root, publicDir); return absPublicDirPath; } -export function checkClearScreen( - inlineConfig: FarmCliOptions | ResolvedUserConfig -) { - if ( - inlineConfig?.clearScreen && - !__FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ - ) { - clearScreen(); - } -} - -export async function resolveMergedUserConfig( - mergedUserConfig: UserConfig, - configFilePath: string | undefined, - mode: 'development' | 'production' | string, - logger: Logger = new Logger() -): Promise { - const resolvedUserConfig = { - ...mergedUserConfig, - compilation: { - ...mergedUserConfig.compilation, - external: [] - } - } as ResolvedUserConfig; - - // set internal config - resolvedUserConfig.envMode = mode; - - if (configFilePath) { - const dependencies = await traceDependencies(configFilePath, logger); - dependencies.sort(); - resolvedUserConfig.configFileDependencies = dependencies; - resolvedUserConfig.configFilePath = configFilePath; - } - - const resolvedRootPath = resolvedUserConfig.root ?? process.cwd(); - const resolvedEnvPath = resolvedUserConfig.envDir - ? resolvedUserConfig.envDir - : resolvedRootPath; - - const userEnv = loadEnv( - resolvedUserConfig.envMode ?? mode, - resolvedEnvPath, - resolvedUserConfig.envPrefix - ); - const existsEnvFiles = getExistsEnvFiles( - resolvedUserConfig.envMode ?? mode, - resolvedEnvPath - ); - - resolvedUserConfig.envFiles = [ - ...(Array.isArray(resolvedUserConfig.envFiles) - ? resolvedUserConfig.envFiles - : []), - ...existsEnvFiles - ]; - - resolvedUserConfig.env = { - ...userEnv, - NODE_ENV: mergedUserConfig.compilation.mode ?? mode, - mode: mode - }; - - return resolvedUserConfig; -} - /** * Load config file from the specified path and return the config and config file path * @param configPath the config path, could be a directory or a file @@ -820,11 +717,11 @@ export async function loadConfigFile( const configRootPath = path.resolve(root); let resolvedPath: string | undefined; try { - if (configFile) { - resolvedPath = path.resolve(root, configFile); - } else { - resolvedPath = await getConfigFilePath(configRootPath); - } + resolvedPath = await resolveConfigFilePath( + configFile, + root, + configRootPath + ); const config = await readConfigFile( inlineOptions, @@ -860,7 +757,10 @@ export async function loadConfigFile( } } -function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { +export async function checkCompilationInputValue( + userConfig: UserConfig, + logger: Logger +) { const { compilation } = userConfig; const targetEnv = compilation?.output?.targetEnv; const inputValue = Object.values(compilation?.input).filter(Boolean); @@ -873,13 +773,15 @@ function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { if (!isEmptyObject(compilation?.input) && inputValue.length) { inputIndexConfig = compilation?.input; } else { + const rootPath = userConfig?.root ?? '.'; if (isTargetNode) { // If input is not specified, try to find index.js or index.ts const entryFiles = ['./index.js', './index.ts']; for (const entryFile of entryFiles) { try { - if (fs.statSync(path.resolve(userConfig?.root, entryFile))) { + const resolvedPath = path.resolve(rootPath, entryFile); + if (await checkFileExists(resolvedPath)) { inputIndexConfig = { index: entryFile }; break; } @@ -889,7 +791,8 @@ function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { } } else { try { - if (fs.statSync(path.resolve(userConfig?.root, defaultHtmlPath))) { + const resolvedHtmlPath = path.resolve(rootPath, defaultHtmlPath); + if (await checkFileExists(resolvedHtmlPath)) { inputIndexConfig = { index: defaultHtmlPath }; } } catch (error) { @@ -914,15 +817,16 @@ function checkCompilationInputValue(userConfig: UserConfig, logger: Logger) { export async function getConfigFilePath( configRootPath: string ): Promise { - if (fse.statSync(configRootPath).isDirectory()) { - for (const name of DEFAULT_CONFIG_NAMES) { - const resolvedPath = path.join(configRootPath, name); - const isFile = - fse.existsSync(resolvedPath) && fse.statSync(resolvedPath).isFile(); - - if (isFile) { - return resolvedPath; - } + const stat = await fse.stat(configRootPath); + if (!stat.isDirectory()) { + return undefined; + } + + for (const name of DEFAULT_CONFIG_NAMES) { + const resolvedPath = path.join(configRootPath, name); + const fileStat = await fse.stat(resolvedPath); + if (fileStat.isFile()) { + return resolvedPath; } } return undefined; @@ -930,28 +834,21 @@ export async function getConfigFilePath( export async function resolvePlugins( userConfig: UserConfig, - logger: Logger, - mode: CompilationMode + mode: CompilationMode, + logger: Logger ) { - const { jsPlugins, rustPlugins } = await resolveFarmPlugins(userConfig); - const rawJsPlugins = (await resolveAsyncPlugins(jsPlugins || [])).filter( - Boolean - ); + const { jsPlugins: rawJsPlugins, rustPlugins } = + await resolveFarmPlugins(userConfig); + const jsPlugins = await resolveAndFilterAsyncPlugins(rawJsPlugins); - let vitePluginAdapters: JsPlugin[] = []; const vitePlugins = (userConfig?.vitePlugins ?? []).filter(Boolean); - if (vitePlugins.length) { - vitePluginAdapters = await handleVitePlugins( - vitePlugins, - userConfig, - logger, - mode - ); - } + const vitePluginAdapters = vitePlugins.length + ? await handleVitePlugins(vitePlugins, userConfig, logger, mode) + : []; return { - jsPlugins: rawJsPlugins, + jsPlugins, vitePlugins, rustPlugins, vitePluginAdapters @@ -959,44 +856,7 @@ export async function resolvePlugins( } export async function resolveDefaultUserConfig(options: any) { - const { inlineOptions, format, outputPath, fileName, configFilePath } = - options; - const defaultConfig: UserConfig = { - root: path.resolve(inlineOptions.root ?? '.'), - compilation: { - input: { - [fileName]: configFilePath - }, - output: { - entryFilename: '[entryName]', - path: outputPath, - format, - targetEnv: 'node' - }, - external: [ - ...(process.env.FARM_CONFIG_FULL_BUNDLE - ? [] - : ['!^(\\./|\\.\\./|[A-Za-z]:\\\\|/).*']), - '^@farmfe/core$' - ], - partialBundling: { - enforceResources: [ - { - name: fileName, - test: ['.+'] - } - ] - }, - watch: false, - sourcemap: false, - treeShaking: false, - minify: false, - presetEnv: false, - lazyCompilation: false, - persistentCache: false, - progress: false - } - }; + const defaultConfig: UserConfig = createDefaultConfig(options); const resolvedUserConfig: ResolvedUserConfig = await resolveUserConfig( defaultConfig, @@ -1014,36 +874,32 @@ export async function resolveDefaultUserConfig(options: any) { export async function resolveUserConfig( userConfig: UserConfig, - configFilePath: string | undefined, - mode: 'development' | 'production' | string, + configFilePath?: string | undefined, + mode: 'development' | 'production' | string = 'development', logger: Logger = new Logger() ): Promise { const resolvedUserConfig = { - ...userConfig + ...userConfig, + envMode: mode } as ResolvedUserConfig; // set internal config - resolvedUserConfig.envMode = mode; - if (configFilePath) { const dependencies = await traceDependencies(configFilePath, logger); - dependencies.sort(); - resolvedUserConfig.configFileDependencies = dependencies; + resolvedUserConfig.configFileDependencies = dependencies.sort(); resolvedUserConfig.configFilePath = configFilePath; } - const resolvedRootPath = resolvedUserConfig.root ?? process.cwd(); - const resolvedEnvPath = resolvedUserConfig.envDir - ? resolvedUserConfig.envDir - : resolvedRootPath; + const resolvedRootPath = resolvedUserConfig.root; + const resolvedEnvPath = resolvedUserConfig.envDir ?? resolvedRootPath; const userEnv = loadEnv( - resolvedUserConfig.envMode ?? mode, + resolvedUserConfig.envMode, resolvedEnvPath, resolvedUserConfig.envPrefix ); const existsEnvFiles = getExistsEnvFiles( - resolvedUserConfig.envMode ?? mode, + resolvedUserConfig.envMode, resolvedEnvPath ); @@ -1056,9 +912,116 @@ export async function resolveUserConfig( resolvedUserConfig.env = { ...userEnv, - NODE_ENV: userConfig.compilation.mode ?? mode, - mode: mode + NODE_ENV: userConfig.compilation.mode, + mode }; return resolvedUserConfig; } + +export function createDefaultConfig(options: any): UserConfig { + const { inlineOptions, format, outputPath, fileName, configFilePath } = + options; + return { + root: path.resolve(inlineOptions.root ?? '.'), + compilation: { + input: { + [fileName]: configFilePath + }, + output: { + entryFilename: '[entryName]', + path: outputPath, + format, + targetEnv: 'node' + }, + external: [ + ...(process.env.FARM_CONFIG_FULL_BUNDLE + ? [] + : ['!^(\\./|\\.\\./|[A-Za-z]:\\\\|/).*']), + '^@farmfe/core$' + ], + partialBundling: { + enforceResources: [ + { + name: fileName, + test: ['.+'] + } + ] + }, + watch: false, + sourcemap: false, + treeShaking: false, + minify: false, + presetEnv: false, + lazyCompilation: false, + persistentCache: false, + progress: false + } + }; +} + +export async function resolveAndFilterAsyncPlugins( + plugins: JsPlugin[] = [] +): Promise { + return (await resolveAsyncPlugins(plugins)).filter(Boolean); +} + +export async function checkFileExists(filePath: string): Promise { + try { + await fse.stat(filePath); + return true; + } catch { + return false; + } +} + +export async function resolveConfigFilePath( + configFile: string, + root: string, + configRootPath: string +): Promise { + if (configFile) { + return path.resolve(root, configFile); + } else { + return await getConfigFilePath(configRootPath); + } +} + +export async function handleServerPortConflict( + resolvedUserConfig: ResolvedUserConfig, + logger: Logger, + mode?: CompilationMode +) { + // check port availability: auto increment the port if a conflict occurs + + try { + mode !== 'production' && + (await Server.resolvePortConflict(resolvedUserConfig.server, logger)); + // eslint-disable-next-line no-empty + } catch {} +} + +export function checkClearScreen( + inlineConfig: FarmCliOptions | ResolvedUserConfig +) { + if ( + inlineConfig?.clearScreen && + !__FARM_GLOBAL__.__FARM_RESTART_DEV_SERVER__ + ) { + clearScreen(); + } +} + +export function getFormat(configFilePath: string): Format { + return process.env.FARM_CONFIG_FORMAT === 'cjs' + ? 'cjs' + : process.env.FARM_CONFIG_FORMAT === 'esm' + ? 'esm' + : formatFromExt[path.extname(configFilePath).slice(1)] ?? 'esm'; +} + +export function getFilePath(outputPath: string, fileName: string): string { + return isWindows + ? pathToFileURL(path.join(outputPath, fileName)).toString() + : path.join(outputPath, fileName); +} diff --git a/packages/core/src/config/mergeConfig.ts b/packages/core/src/config/mergeConfig.ts index d7cfc9f18d..be05e78f59 100644 --- a/packages/core/src/config/mergeConfig.ts +++ b/packages/core/src/config/mergeConfig.ts @@ -47,7 +47,8 @@ export function mergeConfig>( export function mergeFarmCliConfig( cliOption: FarmCliOptions & UserConfig, - target: UserConfig + target: UserConfig, + mode?: 'development' | 'production' ): UserConfig { let left: UserConfig = {}; const options = initialCliOptions(cliOption); @@ -121,7 +122,7 @@ export function mergeFarmCliConfig( if (options.mode) { left = mergeConfig(left, { compilation: { - mode: options.mode as UserConfig['compilation']['mode'] + mode: mode ?? (options.mode as UserConfig['compilation']['mode']) } }); } From b0458a0aa576e2534b45b567702d963393dfc161 Mon Sep 17 00:00:00 2001 From: erkelost <1256029807@qq.com> Date: Wed, 24 Jul 2024 09:33:30 +0800 Subject: [PATCH 5/9] chore: update comment --- packages/core/src/config/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/core/src/config/index.ts b/packages/core/src/config/index.ts index 783d91af29..e10f47c363 100644 --- a/packages/core/src/config/index.ts +++ b/packages/core/src/config/index.ts @@ -187,7 +187,7 @@ export async function resolveConfig( await resolveConfigResolvedHook(resolvedUserConfig, sortFarmJsPlugins); // Fix: Await the Promise and pass the resolved value to the function. - //TODO Temporarily solve the problem of alias adaptation to vite + //TODO Temporarily solve the problem of alias adaptation to vite we should resolve this in rust side if (resolvedUserConfig.compilation?.resolve?.alias && vitePlugins.length) { resolvedUserConfig.compilation.resolve.alias = transformAliasWithVite( resolvedUserConfig.compilation.resolve.alias as unknown as Array From b0dc639d27bcf6ea7398f42435b76479acbb485c Mon Sep 17 00:00:00 2001 From: smz8023 <31838004+smz8023@users.noreply.github.com> Date: Fri, 26 Jul 2024 16:04:51 +0800 Subject: [PATCH 6/9] refactor: Define and modify field types (#1664) * refactor: Define and modify field types * refactor: Define and modify field types * chore: change the type and add jsdoc --------- Co-authored-by: shaomingzhen.smz --- packages/cli/src/types.ts | 23 ++++++++-------- packages/cli/src/utils.ts | 55 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 64 insertions(+), 14 deletions(-) diff --git a/packages/cli/src/types.ts b/packages/cli/src/types.ts index 37f668636a..dc3074b3b4 100644 --- a/packages/cli/src/types.ts +++ b/packages/cli/src/types.ts @@ -3,39 +3,40 @@ export interface GlobalCliOptions { c?: boolean | string; config?: string; configPath?: string; - m?: string; base?: string; + m?: string; mode?: 'development' | 'production' | string; - w?: boolean; - watch?: boolean; - watchPath?: string; - port?: number; - lazy?: boolean; l?: boolean; + lazy?: boolean; + port?: number; clearScreen?: boolean; } export interface CleanOptions { - path?: string; recursive?: boolean; } export interface CliServerOptions { - port?: string; + port?: number; open?: boolean; https?: boolean; hmr?: boolean; + cors?: boolean; strictPort?: boolean; } export interface CliBuildOptions { - configFile?: string | undefined; - input?: string; + o?: string; outDir?: string; + i?: string; + input?: string; + w?: boolean; + watch?: boolean; sourcemap?: boolean; minify?: boolean; treeShaking?: boolean; format?: 'cjs' | 'esm'; + configFile?: string | undefined; target?: | 'browser' | 'node' @@ -52,6 +53,6 @@ export interface CliPreviewOptions { host?: string | boolean; port?: number; open?: boolean | string; - strictPort?: boolean; outDir?: string; + strictPort?: boolean; } diff --git a/packages/cli/src/utils.ts b/packages/cli/src/utils.ts index f3840e35e8..ec9c7a0c98 100644 --- a/packages/cli/src/utils.ts +++ b/packages/cli/src/utils.ts @@ -3,10 +3,25 @@ import path from 'node:path'; import type { build, clean, preview, start, watch } from '@farmfe/core'; import { Logger } from '@farmfe/core'; -import type { CleanOptions, GlobalCliOptions } from './types.js'; +import type { + CleanOptions, + CliBuildOptions, + CliServerOptions, + GlobalCliOptions +} from './types.js'; const logger = new Logger(); +/** + * + * @returns {Promise<{ start: typeof start, build: typeof build, watch: typeof watch, preview: typeof preview, clean: typeof clean }>} + * A promise that resolves to an object containing the core functionalities: + * - `start`: Compile the project in dev mode and serve it with farm dev server'. + * - `build`: compile the project in production mode'. + * - `watch`: watch file change'. + * - `preview`: compile the project in watch mode'. + * - `clean`: Clean up the cache built incrementally'. + */ export async function resolveCore(): Promise<{ start: typeof start; build: typeof build; @@ -34,8 +49,13 @@ export function filterDuplicateOptions(options: T) { } } } - -export function cleanOptions(options: GlobalCliOptions) { +/** + * @param options The cli passes parameters + * @returns Remove parameters that are not required + */ +export function cleanOptions( + options: GlobalCliOptions & CliServerOptions & CliBuildOptions +) { const resolveOptions = { ...options }; delete resolveOptions['--']; @@ -52,6 +72,11 @@ export function cleanOptions(options: GlobalCliOptions) { return resolveOptions; } +/** + * + * @param options cli parameters + * @returns resolve command options + */ export function resolveCommandOptions( options: GlobalCliOptions ): GlobalCliOptions { @@ -60,10 +85,21 @@ export function resolveCommandOptions( return cleanOptions(resolveOptions); } +/** + * + * @param root root path + * @param configPath config path + * @returns config path absolute path + */ export function getConfigPath(root: string, configPath: string) { return path.resolve(root, configPath ?? ''); } +/** + * + * @param asyncOperation The asynchronous operation to be executed. + * @param errorMessage The error message to log if the operation fails. + */ export async function handleAsyncOperationErrors( asyncOperation: Promise, errorMessage: string @@ -76,12 +112,25 @@ export async function handleAsyncOperationErrors( } } +/** + * + * @param rootPath root path + * @returns absolute path + */ export function resolveRootPath(rootPath = '') { return rootPath && path.isAbsolute(rootPath) ? rootPath : path.resolve(process.cwd(), rootPath); } +/** + * + * @param root root path + * @param options cli parameters + * @returns + * - root root path + * - configPath + */ export function resolveCliConfig( root: string, options: GlobalCliOptions & CleanOptions From e77beb54926e8f4d417ace0c6952f5258cde44f3 Mon Sep 17 00:00:00 2001 From: ADNY <66500121+ErKeLost@users.noreply.github.com> Date: Fri, 26 Jul 2024 17:58:03 +0800 Subject: [PATCH 7/9] chore: update qrcode (#1669) --- README.md | 2 +- README.zh-CN.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 3b0411cdae..674060a571 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,7 @@ See [Contributing Guide](https://github.com/farm-fe/farm/blob/main/CONTRIBUTING. - Wechat group -
+
- QQ group diff --git a/README.zh-CN.md b/README.zh-CN.md index b4501bdd3a..c68bab2804 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -106,7 +106,7 @@ Farm 远快于业界常用的 JS 构建工具,在 benchmark 测试中,Farm - 微信交流群 -
+
- QQ 群 From 494485616bfd7bb834edab673ee1c919b3d6f8dc Mon Sep 17 00:00:00 2001 From: brightwu <1521488775@qq.com> Date: Mon, 29 Jul 2024 09:33:04 +0800 Subject: [PATCH 8/9] fix: single bundle (#1653) * feat: record * fix: import.meta.url and require compatible esm and cjs * fix: single bundle with runtime * fix: cjs or esm reexport * chore: clean code * fix: compatible with target_env changes * fix: compatible with library-node * feat: update snapshot * fix: target_env compatible --------- Co-authored-by: shulandmimi --- .changeset/thick-pandas-listen.md | 5 + crates/compiler/tests/bundle.rs | 84 ++++++++ .../library/hybrid/noexport/config.json | 6 + .../bundle/library/hybrid/noexport/index.ts | 4 + .../bundle/library/hybrid/noexport/output.js | 69 +++++++ .../bundle/library/hybrid/noexport/runtime.ts | 1 + .../bundle/library/hybrid/normal/config.json | 6 + .../bundle/library/hybrid/normal/index.ts | 13 ++ .../bundle/library/hybrid/normal/output.js | 97 +++++++++ .../bundle/library/hybrid/normal/runtime.ts | 1 + .../library/reexport/esm/default/config.json | 6 + .../library/reexport/esm/default/foo.ts | 1 + .../library/reexport/esm/default/index.ts | 1 + .../library/reexport/esm/default/output.js | 48 +++++ .../library/reexport/esm/default/runtime.ts | 1 + .../library/reexport/esm/named/config.json | 6 + .../bundle/library/reexport/esm/named/foo.ts | 2 + .../library/reexport/esm/named/index.ts | 1 + .../library/reexport/esm/named/output.js | 49 +++++ .../library/reexport/esm/named/runtime.ts | 1 + .../reexport/esm/namespace/config.json | 6 + .../library/reexport/esm/namespace/foo.ts | 5 + .../library/reexport/esm/namespace/index.ts | 1 + .../library/reexport/esm/namespace/output.js | 56 ++++++ .../library/reexport/esm/namespace/runtime.ts | 1 + .../library/reexport/esm/star/config.json | 6 + .../bundle/library/reexport/esm/star/foo.ts | 5 + .../bundle/library/reexport/esm/star/index.ts | 1 + .../library/reexport/esm/star/output.js | 57 ++++++ .../library/reexport/esm/star/runtime.ts | 1 + .../reexport_hybrid_cjs/default/config.json | 6 + .../reexport_hybrid_cjs/default/foo.ts | 2 + .../reexport_hybrid_cjs/default/index.ts | 1 + .../reexport_hybrid_cjs/default/output.js | 78 ++++++++ .../reexport_hybrid_cjs/default/runtime.ts | 1 + .../reexport_hybrid_cjs/named/config.json | 6 + .../reexport/reexport_hybrid_cjs/named/foo.ts | 4 + .../reexport_hybrid_cjs/named/index.ts | 1 + .../reexport_hybrid_cjs/named/output.js | 87 ++++++++ .../reexport_hybrid_cjs/named/runtime.ts | 1 + .../reexport_hybrid_cjs/namespace/config.json | 6 + .../reexport_hybrid_cjs/namespace/foo.ts | 7 + .../reexport_hybrid_cjs/namespace/index.ts | 1 + .../reexport_hybrid_cjs/namespace/output.js | 91 +++++++++ .../reexport_hybrid_cjs/namespace/runtime.ts | 1 + .../reexport_hybrid_cjs/star/config.json | 6 + .../reexport/reexport_hybrid_cjs/star/foo.ts | 7 + .../reexport_hybrid_cjs/star/index.ts | 1 + .../reexport_hybrid_cjs/star/output.js | 92 +++++++++ .../reexport_hybrid_cjs/star/runtime.ts | 1 + crates/core/src/config/mod.rs | 2 +- crates/plugin_bundle/src/lib.rs | 20 +- .../bundle/bundle_analyzer.rs | 187 +++++++++++++++--- .../bundle/bundle_external.rs | 11 +- .../src/resource_pot_to_bundle/bundle/mod.rs | 64 +++++- .../src/resource_pot_to_bundle/common.rs | 10 +- .../src/resource_pot_to_bundle/mod.rs | 34 +++- .../modules_analyzer/analyze.rs | 2 +- .../modules_analyzer/module_analyzer.rs | 4 +- .../resource_pot_to_bundle/polyfill/mod.rs | 51 +++++ .../resource_pot_to_bundle/targets/cjs/mod.rs | 12 +- .../targets/cjs/patch.rs | 36 ++-- .../targets/cjs/util.rs | 48 ++++- .../src/resource_pot_to_bundle/uniq_name.rs | 5 + .../src/handle_entry_resources.rs | 21 +- crates/plugin_runtime/src/lib.rs | 2 - .../plugin_script/src/import_meta_visitor.rs | 62 +++++- crates/plugin_script/src/lib.rs | 17 +- .../src/transform_import_meta_url/mod.rs | 2 +- crates/utils/src/lib.rs | 6 +- packages/core/src/utils/share.ts | 12 +- 71 files changed, 1451 insertions(+), 98 deletions(-) create mode 100644 .changeset/thick-pandas-listen.md create mode 100644 crates/compiler/tests/bundle.rs create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/normal/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/normal/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/normal/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/hybrid/normal/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/runtime.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/config.json create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/foo.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/index.ts create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/output.js create mode 100644 crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/runtime.ts diff --git a/.changeset/thick-pandas-listen.md b/.changeset/thick-pandas-listen.md new file mode 100644 index 0000000000..b2386c37e6 --- /dev/null +++ b/.changeset/thick-pandas-listen.md @@ -0,0 +1,5 @@ +--- +"@farmfe/core": patch +--- + +import.meta.url and require compatible esm and cjs diff --git a/crates/compiler/tests/bundle.rs b/crates/compiler/tests/bundle.rs new file mode 100644 index 0000000000..43cf9f648a --- /dev/null +++ b/crates/compiler/tests/bundle.rs @@ -0,0 +1,84 @@ +use std::{collections::HashMap, path::PathBuf}; + +use farmfe_core::config::{bool_or_obj::BoolOrObj, config_regex::ConfigRegex, Mode, TargetEnv}; +mod common; +use crate::common::{ + assert_compiler_result_with_config, create_compiler_with_args, AssertCompilerResultConfig, +}; + +#[allow(dead_code)] +#[cfg(test)] +fn test(file: String, crate_path: String) { + use common::get_config_field; + use farmfe_core::config::partial_bundling::PartialBundlingEnforceResourceConfig; + + use crate::common::try_read_config_from_json; + + let file_path_buf = PathBuf::from(file.clone()); + let create_path_buf = PathBuf::from(crate_path); + let cwd = file_path_buf.parent().unwrap(); + println!("testing test case: {:?}", cwd); + + let entry_name = "index".to_string(); + + let config_entry = cwd.to_path_buf().join("config.json"); + let runtime_entry = cwd.to_path_buf().join("runtime.ts"); + + let config_from_file = try_read_config_from_json(config_entry); + + let compiler = + create_compiler_with_args(cwd.to_path_buf(), create_path_buf, |mut config, plugins| { + config.mode = Mode::Production; + + if runtime_entry.is_file() { + let runtime_entry = runtime_entry.to_string_lossy().to_string(); + config.runtime.path = runtime_entry; + } + + config.input = HashMap::from_iter(vec![(entry_name.clone(), file)]); + + config.minify = Box::new(BoolOrObj::Bool(false)); + config.tree_shaking = Box::new(BoolOrObj::Bool(false)); + + config.external = vec![ConfigRegex::new("(^node:.*)"), ConfigRegex::new("^fs$")]; + config.output.target_env = TargetEnv::Node; + // config.output.format = ModuleFormat::CommonJs; + + // TODO: multiple bundle + config.partial_bundling.enforce_resources = vec![PartialBundlingEnforceResourceConfig { + test: vec![ConfigRegex::new(".+")], + name: "index".to_string(), + }]; + + if let Some(config_from_file) = config_from_file { + if let Some(mode) = get_config_field(&config_from_file, &["mode"]) { + config.mode = mode; + } + + if let Some(format) = get_config_field(&config_from_file, &["output", "format"]) { + config.output.format = format; + } + + if let Some(target_env) = get_config_field(&config_from_file, &["output", "targetEnv"]) { + config.output.target_env = target_env; + } + } + + (config, plugins) + }); + + compiler.compile().unwrap(); + + assert_compiler_result_with_config( + &compiler, + AssertCompilerResultConfig { + entry_name: Some(entry_name), + ignore_emitted_field: false, + ..Default::default() + }, + ); +} + +farmfe_testing::testing! {"tests/fixtures/bundle/library/**/index.ts", test} +// farmfe_testing::testing! {"tests/fixtures/runtime/bundle/cjs/export/entryExportStar/**/index.ts", test} +// farmfe_testing::testing! {"tests/fixtures/runtime/bundle/external/import/namespace/**/index.ts", test} diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/config.json b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/index.ts b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/index.ts new file mode 100644 index 0000000000..7979f5b776 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/index.ts @@ -0,0 +1,4 @@ +import fs from 'node:fs'; +const os = require('node:os'); + +console.log(fs.read, os.cpus); diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/output.js b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/output.js new file mode 100644 index 0000000000..a69269d0fc --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/output.js @@ -0,0 +1,69 @@ +//index.js: + import __farmNodeModule from 'module'; +globalThis.nodeRequire = __farmNodeModule.createRequire(import.meta.url);function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}import fs from "node:fs"; +var index_cjs = __commonJs((module, exports)=>{ + "use strict"; + const os = globalThis.nodeRequire('node:os'); + console.log(fs.read, os.cpus); +}); +index_cjs(); diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/noexport/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/config.json b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/index.ts b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/index.ts new file mode 100644 index 0000000000..1119c0b5c0 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/index.ts @@ -0,0 +1,13 @@ +import fs from 'node:fs'; +const os = require('node:os'); + +console.log(fs.read, os.cpus); + + +export default { + read: fs.read, + c: 1, +}; + +export const foo = 'foo'; +export const bar = 'bar'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/output.js b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/output.js new file mode 100644 index 0000000000..099beadf4d --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/output.js @@ -0,0 +1,97 @@ +//index.js: + import __farmNodeModule from 'module'; +globalThis.nodeRequire = __farmNodeModule.createRequire(import.meta.url);function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}import fs from "node:fs"; +var index_cjs = __commonJs((module, exports)=>{ + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + bar: function() { + return bar; + }, + index_default: function() { + return _default; + }, + foo: function() { + return foo; + } + }); + const os = globalThis.nodeRequire('node:os'); + console.log(fs.read, os.cpus); + var _default = { + read: fs.read, + c: 1 + }; + const foo = 'foo'; + const bar = 'bar'; +}); +var index_default = _interop_require_default(index_cjs()).index_default, bar = index_cjs()["bar"], foo = index_cjs()["foo"]; +export { bar, foo }; +export default index_default; diff --git a/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/hybrid/normal/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/foo.ts new file mode 100644 index 0000000000..5a549c58c9 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/foo.ts @@ -0,0 +1 @@ +export default 'foo'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/index.ts new file mode 100644 index 0000000000..1d4a906337 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/index.ts @@ -0,0 +1 @@ +export { default } from './foo.ts'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/output.js new file mode 100644 index 0000000000..9cf3a76324 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/output.js @@ -0,0 +1,48 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}var foo_default = 'foo'; + +export { foo_default as default }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/default/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/foo.ts new file mode 100644 index 0000000000..be46064a3f --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/foo.ts @@ -0,0 +1,2 @@ +export const foo = 'foo'; +export const bar = 'bar'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/index.ts new file mode 100644 index 0000000000..c0466d3c57 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/index.ts @@ -0,0 +1 @@ +export { foo, bar } from './foo.ts'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/output.js new file mode 100644 index 0000000000..c4feebfd58 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/output.js @@ -0,0 +1,49 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}const foo = 'foo'; +const bar = 'bar'; + +export { bar, foo }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/named/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/foo.ts new file mode 100644 index 0000000000..cb497a023f --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/foo.ts @@ -0,0 +1,5 @@ +export default 'foo'; + +export const foo = 'foo'; + +export const bar = 'bar'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/index.ts new file mode 100644 index 0000000000..71ea64596d --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/index.ts @@ -0,0 +1 @@ +export * as ns from './foo'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/output.js new file mode 100644 index 0000000000..f6110a6dfd --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/output.js @@ -0,0 +1,56 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}var foo_default = 'foo'; +const foo = 'foo'; +const bar = 'bar'; +var foo_ns = { + bar: bar, + foo: foo, + "default": foo_default, + __esModule: true +}; + +export { foo_ns as ns }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/namespace/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/foo.ts new file mode 100644 index 0000000000..cb497a023f --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/foo.ts @@ -0,0 +1,5 @@ +export default 'foo'; + +export const foo = 'foo'; + +export const bar = 'bar'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/index.ts new file mode 100644 index 0000000000..1cc5a0795b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/index.ts @@ -0,0 +1 @@ +export * from './foo'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/output.js new file mode 100644 index 0000000000..d33ca68f78 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/output.js @@ -0,0 +1,57 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}var foo_default = 'foo'; +const foo = 'foo'; +const bar = 'bar'; +var foo_ns = { + bar: bar, + foo: foo, + "default": foo_default, + __esModule: true +}; + +export { bar, foo }; +export default foo_default; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/esm/star/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/foo.ts new file mode 100644 index 0000000000..8af2ad9ac7 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/foo.ts @@ -0,0 +1,2 @@ +module.exports.cjs = true; +export default 'foo'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/index.ts new file mode 100644 index 0000000000..2f816c828c --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/index.ts @@ -0,0 +1 @@ +export { default } from './foo.ts'; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/output.js new file mode 100644 index 0000000000..e29a879d72 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/output.js @@ -0,0 +1,78 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}var foo_cjs = __commonJs((module, exports)=>{ + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + Object.defineProperty(exports, "default", { + enumerable: true, + get: function() { + return _default; + } + }); + module.exports.cjs = true; + var _default = 'foo'; +}); +var foo_default = foo_cjs()["default"]; + +export { foo_default as default }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/default/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/foo.ts new file mode 100644 index 0000000000..34c6b8f880 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/foo.ts @@ -0,0 +1,4 @@ +export const foo = 'foo'; +export const bar = 'bar'; + +module.exports.cjs = true; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/index.ts new file mode 100644 index 0000000000..d6be28456c --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/index.ts @@ -0,0 +1 @@ +export { foo, bar } from './foo.ts'; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/output.js new file mode 100644 index 0000000000..f1996fe320 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/output.js @@ -0,0 +1,87 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}var foo_cjs = __commonJs((module, exports)=>{ + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + bar: function() { + return bar; + }, + foo: function() { + return foo; + } + }); + const foo = 'foo'; + const bar = 'bar'; + module.exports.cjs = true; +}); +var bar = foo_cjs()["bar"], foo = foo_cjs()["foo"]; + +export { bar, foo }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/named/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/foo.ts new file mode 100644 index 0000000000..aea4653a0c --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/foo.ts @@ -0,0 +1,7 @@ +export default 'foo'; + +export const foo = 'foo'; + +export const bar = 'bar'; + +module.exports.cjs = true; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/index.ts new file mode 100644 index 0000000000..acd3811476 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/index.ts @@ -0,0 +1 @@ +export * as ns from './foo'; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/output.js new file mode 100644 index 0000000000..46366be2be --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/output.js @@ -0,0 +1,91 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}var foo_cjs = __commonJs((module, exports)=>{ + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + bar: function() { + return bar; + }, + default: function() { + return _default; + }, + foo: function() { + return foo; + } + }); + var _default = 'foo'; + const foo = 'foo'; + const bar = 'bar'; + module.exports.cjs = true; +}); +var foo_ns = _interop_require_wildcard(foo_cjs()); + +export { foo_ns as ns }; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/namespace/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/config.json b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/config.json new file mode 100644 index 0000000000..eb309261d4 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/config.json @@ -0,0 +1,6 @@ +{ + "output": { + "targetEnv": "library-node", + "format": "esm" + } +} \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/foo.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/foo.ts new file mode 100644 index 0000000000..4fbeb37118 --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/foo.ts @@ -0,0 +1,7 @@ +export default 'foo'; + +export const foo = 'foo'; + +export const bar = 'bar'; + +module.exports.cjs = true; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/index.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/index.ts new file mode 100644 index 0000000000..1cc5a0795b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/index.ts @@ -0,0 +1 @@ +export * from './foo'; \ No newline at end of file diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/output.js b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/output.js new file mode 100644 index 0000000000..f2320e3c3f --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/output.js @@ -0,0 +1,92 @@ +//index.js: + function _interop_require_default(obj) { + return obj && obj.__esModule ? obj : { + default: obj + }; +}function _export_star(from, to) { + Object.keys(from).forEach(function(k) { + if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { + Object.defineProperty(to, k, { + enumerable: true, + get: function() { + return from[k]; + } + }); + } + }); + return from; +}function _interop_require_wildcard(obj, nodeInterop) { + if (!nodeInterop && obj && obj.__esModule) return obj; + if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { + default: obj + }; + var cache = _getRequireWildcardCache(nodeInterop); + if (cache && cache.has(obj)) return cache.get(obj); + var newObj = { + __proto__: null + }; + var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; + for(var key in obj){ + if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { + var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; + if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); + else newObj[key] = obj[key]; + } + } + newObj.default = obj; + if (cache) cache.set(obj, newObj); + return newObj; +}function _getRequireWildcardCache(nodeInterop) { + if (typeof WeakMap !== "function") return null; + var cacheBabelInterop = new WeakMap(); + var cacheNodeInterop = new WeakMap(); + return (_getRequireWildcardCache = function(nodeInterop) { + return nodeInterop ? cacheNodeInterop : cacheBabelInterop; + })(nodeInterop); +}function __commonJs(mod) { + var module; + return () => { + if (module) { + return module.exports; + } + module = { + exports: {}, + }; + if(typeof mod === "function") { + mod(module, module.exports); + }else { + mod[Object.keys(mod)[0]](module, module.exports); + } + return module.exports; + }; +}var foo_cjs = __commonJs((module, exports)=>{ + "use strict"; + Object.defineProperty(exports, "__esModule", { + value: true + }); + function _export(target, all) { + for(var name in all)Object.defineProperty(target, name, { + enumerable: true, + get: all[name] + }); + } + _export(exports, { + bar: function() { + return bar; + }, + default: function() { + return _default; + }, + foo: function() { + return foo; + } + }); + var _default = 'foo'; + const foo = 'foo'; + const bar = 'bar'; + module.exports.cjs = true; +}); +var foo_default = _interop_require_default(foo_cjs()).default, bar = foo_cjs()["bar"], foo = foo_cjs()["foo"]; + +export { bar, foo }; +export default foo_default; diff --git a/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/runtime.ts b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/runtime.ts new file mode 100644 index 0000000000..0124c2287b --- /dev/null +++ b/crates/compiler/tests/fixtures/bundle/library/reexport/reexport_hybrid_cjs/star/runtime.ts @@ -0,0 +1 @@ +console.log('runtime'); \ No newline at end of file diff --git a/crates/core/src/config/mod.rs b/crates/core/src/config/mod.rs index d659b59d3c..41480dd94c 100644 --- a/crates/core/src/config/mod.rs +++ b/crates/core/src/config/mod.rs @@ -3,7 +3,7 @@ use std::collections::HashMap; use serde::{Deserialize, Serialize}; use swc_css_prefixer::options::Targets; -use swc_ecma_parser::{EsConfig, TsConfig}; +use swc_ecma_parser::{EsSyntax as EsConfig, TsSyntax as TsConfig}; use self::{ bool_or_obj::BoolOrObj, comments::CommentsConfig, config_regex::ConfigRegex, html::HtmlConfig, diff --git a/crates/plugin_bundle/src/lib.rs b/crates/plugin_bundle/src/lib.rs index 7410c9f28a..f2247e07a4 100644 --- a/crates/plugin_bundle/src/lib.rs +++ b/crates/plugin_bundle/src/lib.rs @@ -48,18 +48,28 @@ impl Plugin for FarmPluginBundle { resource_pots.sort_by_key(|item| item.id.clone()); - let r = resource_pots.iter().map(|item| &**item).collect::>(); + let r = resource_pots + .iter() + .filter(|item| { + context.config.output.target_env.is_library() + || matches!(item.resource_pot_type, ResourcePotType::Runtime) + }) + .map(|item| &**item) + .collect::>(); let mut shared_bundle = SharedBundle::new(r, &module_graph, context)?; - let runtime_resource_pot = resource_pots + let inject_resource_pot_id = resource_pots .iter() - .find(|item| matches!(item.resource_pot_type, ResourcePotType::Runtime)) + .find(|item| { + (context.config.output.target_env.is_library() && item.entry_module.is_some()) + || matches!(item.resource_pot_type, ResourcePotType::Runtime) + }) .map(|i| i.id.clone()); - if let Some(runtime_resource_pot_id) = runtime_resource_pot { + if let Some(resource_pot_id) = inject_resource_pot_id { let polyfill = &mut shared_bundle .bundle_map - .get_mut(&runtime_resource_pot_id) + .get_mut(&resource_pot_id) .unwrap() .polyfill; diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_analyzer.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_analyzer.rs index 3226e78729..ee8be9dbfe 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_analyzer.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_analyzer.rs @@ -1,9 +1,13 @@ use std::{ - cell::RefCell, cmp::Ordering, collections::{HashMap, HashSet}, rc::Rc, sync::Arc + cell::RefCell, + cmp::Ordering, + collections::{HashMap, HashSet}, + rc::Rc, + sync::Arc, }; use farmfe_core::{ - config::{Mode, ModuleFormat, TargetEnv}, + config::{external::ExternalConfig, Config, Mode, ModuleFormat, TargetEnv}, context::CompilationContext, enhanced_magic_string::{ bundle::{Bundle, BundleOptions}, @@ -11,7 +15,7 @@ use farmfe_core::{ }, error::{CompilationError, Result}, farm_profile_function, farm_profile_scope, - module::{module_graph::ModuleGraph, ModuleId, ModuleSystem}, + module::{module_graph::ModuleGraph, ModuleId, ModuleSystem, ModuleType}, resource::resource_pot::{ResourcePot, ResourcePotType}, swc_common::{comments::SingleThreadedComments, util::take::Take}, }; @@ -23,8 +27,11 @@ use farmfe_toolkit::{ }; use crate::resource_pot_to_bundle::{ + bundle::bundle_external::ReferenceKind, common::OptionToResult, - modules_analyzer::module_analyzer::{ExportSpecifierInfo, ImportSpecifierInfo, StmtAction}, + modules_analyzer::module_analyzer::{ + ExportSpecifierInfo, ImportSpecifierInfo, StmtAction, Variable, + }, polyfill::SimplePolyfill, targets::generate::{ generate_bundle_import_by_bundle_reference, generate_export_by_reference_export, @@ -73,6 +80,13 @@ impl<'a> BundleAnalyzer<'a> { } } + pub fn set_namespace(&mut self, resource_pot_id: &str) { + self + .bundle_variable + .borrow_mut() + .set_namespace(resource_pot_id.to_string()); + } + // step: 1 toposort fetch modules pub fn build_module_order(&mut self, order_index_map: &HashMap) { farm_profile_function!(); @@ -189,6 +203,7 @@ impl<'a> BundleAnalyzer<'a> { } // 3-3 find module relation and link local variable + // TODO: refactor bundle_reference logic pub fn link_module_relation( &mut self, module_analyzer_manager: &mut ModuleAnalyzerManager, @@ -215,6 +230,7 @@ impl<'a> BundleAnalyzer<'a> { .is_some_and(|i| i.resource_pot_id != resource_pot_id) }) }; + let mut is_contain_export = false; for statement in &module_analyzer.statements { if let Some(import) = &statement.import { @@ -414,7 +430,8 @@ impl<'a> BundleAnalyzer<'a> { } if let Some(export) = &statement.export { - if module_analyzer_manager.is_commonjs(module_id) { + is_contain_export = true; + if module_analyzer_manager.is_commonjs(module_id) && !is_reference_by_another { continue; } @@ -476,13 +493,17 @@ impl<'a> BundleAnalyzer<'a> { source.clone().into(), module_system.clone(), ); - } else if module_analyzer_manager.is_commonjs(source) { + } else if module_analyzer_manager.is_commonjs(source) + && (!module_analyzer.entry + || matches!(module_analyzer.module_type, ModuleType::Runtime)) + { reexport_commonjs(source, &mut self.bundle_reference)?; } else { let export_names = &*module_analyzer_manager.get_export_names(source); let export_type = export_names.export_type.merge(module_system.clone()); let is_hybrid_dynamic = matches!(export_type, ModuleSystem::Hybrid); + let is_commonjs = module_analyzer_manager.is_commonjs(source); { for (from, export_as) in &export_names.export.named { @@ -490,13 +511,57 @@ impl<'a> BundleAnalyzer<'a> { &ExportSpecifierInfo::Named((*from, Some(*export_as)).into()), export_type.clone(), ); + + if is_commonjs { + let is_default_key = + self.bundle_variable.borrow().is_default_key(*from); + + let imported = if is_default_key { + module_analyzer_manager + .module_global_uniq_name + .default_name_result(module_id)? + } else { + *from + }; + + self.bundle_reference.add_declare_commonjs_import( + &ImportSpecifierInfo::Named { + local: *export_as, + imported: Some(imported), + }, + export.source.clone().unwrap().into(), + &self.bundle_variable.borrow(), + )?; + } } if let Some(item) = &export_names.export.default { + let is_default_key = self.bundle_variable.borrow().is_default_key(*item); + self.bundle_reference.add_local_export( - &ExportSpecifierInfo::Default(*item), + &ExportSpecifierInfo::Default(if is_default_key { + module_analyzer_manager + .module_global_uniq_name + .default_name_result(source)? + } else { + *item + }), export_type.clone(), ); + + if is_commonjs { + self.bundle_reference.add_declare_commonjs_import( + &ImportSpecifierInfo::Default(if is_default_key { + module_analyzer_manager + .module_global_uniq_name + .default_name_result(source)? + } else { + *item + }), + source.clone().into(), + &self.bundle_variable.borrow(), + )?; + } } } @@ -552,12 +617,12 @@ impl<'a> BundleAnalyzer<'a> { // export { name as personName } // export { name as personName } from './person'; - ExportSpecifierInfo::Named(variables) => { + ExportSpecifierInfo::Named(variable) => { if let Some(source) = &export.source { let is_find_default = - self.bundle_variable.borrow().name(variables.local()) == "default"; + self.bundle_variable.borrow().name(variable.local()) == "default"; let target = self.bundle_variable.borrow_mut().find_ident_by_index( - variables.local(), + variable.local(), source, module_analyzer_manager, resource_pot_id.clone(), @@ -575,12 +640,30 @@ impl<'a> BundleAnalyzer<'a> { match target { FindModuleExportResult::Local(local, target_source, _) => { is_confirmed_import = true; + let is_default_key = self.bundle_variable.borrow().is_default_key(local); + + let name = if is_default_key { + module_analyzer_manager + .module_global_uniq_name + .default_name_result(&target_source)? + } else { + local + }; + if is_common_js { self.bundle_variable.borrow_mut().set_var_uniq_rename(local); + self.bundle_reference.add_declare_commonjs_import( - &ImportSpecifierInfo::Named { - local, - imported: None, + &if is_default_key { + ImportSpecifierInfo::Named { + local: name, + imported: Some(local), + } + } else { + ImportSpecifierInfo::Named { + local, + imported: None, + } }, target_source.into(), &self.bundle_variable.borrow(), @@ -589,7 +672,10 @@ impl<'a> BundleAnalyzer<'a> { if is_reference_by_another { self.bundle_reference.add_local_export( - &ExportSpecifierInfo::Named((local).into()), + &ExportSpecifierInfo::Named(Variable( + name, + Some(variable.export_as()), + )), module_system, ); } @@ -619,9 +705,31 @@ impl<'a> BundleAnalyzer<'a> { self .bundle_variable .borrow_mut() - .set_var_uniq_rename(variables.local()); + .set_var_uniq_rename(variable.local()); if is_reference_by_another { + if module_analyzer_manager.is_commonjs(module_id) { + let is_default_key = self + .bundle_variable + .borrow() + .is_default_key(variable.local()); + + self.bundle_reference.add_declare_commonjs_import( + &ImportSpecifierInfo::Named { + local: if is_default_key { + module_analyzer_manager + .module_global_uniq_name + .default_name_result(module_id)? + } else { + variable.local() + }, + imported: Some(variable.export_as()), + }, + ReferenceKind::Module((*module_id).clone()), + &self.bundle_variable.borrow(), + )?; + } + self .bundle_reference .add_local_export(specify, module_system.clone()); @@ -632,13 +740,14 @@ impl<'a> BundleAnalyzer<'a> { // export default n, Default(n) // export default 1 + 1, Default("default") ExportSpecifierInfo::Default(var) => { - if self.bundle_variable.borrow().name(*var) == "default" { - let rendered_name = module_analyzer_manager + let default_name = || { + module_analyzer_manager .module_global_uniq_name - .default_name(module_id) - .to_result(format!("not found module {:?} default name", module_id))?; + .default_name_result(module_id) + }; - let rendered_name = self.bundle_variable.borrow().render_name(rendered_name); + if self.bundle_variable.borrow().name(*var) == "default" { + let rendered_name = self.bundle_variable.borrow().render_name(default_name()?); self .bundle_variable @@ -649,6 +758,14 @@ impl<'a> BundleAnalyzer<'a> { } if is_reference_by_another { + if module_analyzer_manager.is_commonjs(module_id) { + self.bundle_reference.add_declare_commonjs_import( + &ImportSpecifierInfo::Default(default_name()?), + ReferenceKind::Module((*module_id).clone()), + &self.bundle_variable.borrow(), + )?; + } + self .bundle_reference .add_local_export(specify, module_system.clone()); @@ -746,6 +863,14 @@ impl<'a> BundleAnalyzer<'a> { } } } + + if !is_contain_export + && module_analyzer_manager.is_commonjs(module_id) + && module_analyzer.entry + { + let reference_kind = ReferenceKind::Module((*module_id).clone()); + self.bundle_reference.execute_module_for_cjs(reference_kind); + } } } } @@ -780,6 +905,8 @@ impl<'a> BundleAnalyzer<'a> { ) -> Result<()> { farm_profile_function!(""); let mut commonjs_import_executed: HashSet = HashSet::new(); + let external_config = ExternalConfig::from(self.context.config.as_ref()); + for module_id in &self.ordered_modules { farm_profile_scope!(format!( "bundle patch ast module: {}", @@ -794,6 +921,7 @@ impl<'a> BundleAnalyzer<'a> { &mut commonjs_import_executed, order_index_map, &mut self.polyfill, + &external_config )?; } @@ -863,7 +991,11 @@ impl<'a> BundleAnalyzer<'a> { } // step: 4 generate bundle code - pub fn codegen(&mut self, module_analyzer_manager: &mut ModuleAnalyzerManager) -> Result { + pub fn codegen( + &mut self, + module_analyzer_manager: &mut ModuleAnalyzerManager, + config: &Config, + ) -> Result { let mut bundle = Bundle::new(BundleOptions { separator: Some('\n'), intro: None, @@ -932,7 +1064,7 @@ impl<'a> BundleAnalyzer<'a> { })?; let map = Arc::new(String::from_utf8(buf).unwrap()); - source_map_chain = module.source_map_chain.clone(); + source_map_chain.clone_from(&module.source_map_chain); source_map_chain.push(map); } @@ -962,9 +1094,16 @@ impl<'a> BundleAnalyzer<'a> { { bundle.prepend("((function(){"); bundle.append("})());", None); - } + }; + + let injectable_resource_pot = (config.output.target_env.is_library() + && self.resource_pot.entry_module.is_some()) + || matches!( + self.resource_pot.resource_pot_type, + ResourcePotType::Runtime + ); - if !self.polyfill.is_empty() { + if !self.polyfill.is_empty() && injectable_resource_pot { for item in self.polyfill.to_str() { bundle.prepend(&item); } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_external.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_external.rs index 6fa03ea3d9..a676602997 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_external.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/bundle_external.rs @@ -153,12 +153,15 @@ pub struct BundleReference { /// import { xxx } from './external_bundle_module' | './other_bundle_module' pub import_map: HashMap, + /// + /// ```ts /// export { } from "./cjs_module"; /// export * as ns from "./cjs_module"; /// export { default } ns from "./cjs_module"; - /// import { } from "./cjs_module"; - /// import * as ns from "./cjs_module"; - /// import cjs from "./cjs_module"; + /// // => + /// const cjs_module_cjs = cjs_module()["default"]; + /// ``` + /// pub redeclare_commonjs_import: HashMap, // pub declare_commonjs_export: HashMap, @@ -215,7 +218,7 @@ impl BundleReference { } } - pub fn add_import_helper( + fn add_import_helper( map: &mut HashMap, import: &ImportSpecifierInfo, source: ReferenceKind, diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/mod.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/mod.rs index 8a0667b7c2..3dd381e5a7 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/mod.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/bundle/mod.rs @@ -6,6 +6,7 @@ use std::{ use bundle_external::BundleReference; use farmfe_core::{ + config::external::ExternalConfig, context::CompilationContext, error::{CompilationError, MapCompletionError, Result}, farm_profile_function, farm_profile_scope, @@ -15,7 +16,7 @@ use farmfe_core::{ swc_common::{util::take::Take, DUMMY_SP}, swc_ecma_ast::{ self, BindingIdent, CallExpr, ClassDecl, Decl, EmptyStmt, Expr, ExprStmt, FnDecl, Ident, - ModuleDecl, ModuleItem, Stmt, VarDecl, VarDeclarator, + Module, ModuleDecl, ModuleItem, Stmt, VarDecl, VarDeclarator, }, }; use farmfe_toolkit::{script::swc_try_with::try_with, swc_ecma_visit::VisitMutWith}; @@ -31,6 +32,7 @@ use crate::resource_pot_to_bundle::targets::{ use self::reference::ReferenceMap; use super::{ + common::OptionToResult, defined_idents_collector::RenameIdent, modules_analyzer::module_analyzer::{ ExportSpecifierInfo, ImportSpecifierInfo, ModuleAnalyzer, StmtAction, @@ -43,6 +45,9 @@ pub struct ModuleAnalyzerManager<'a> { pub module_map: HashMap, pub namespace_modules: HashSet, + /// + /// + /// TODO: dynamic generate /// /// ```js /// // namespace/moduleA.js @@ -116,6 +121,12 @@ impl ModuleGlobalUniqName { .and_then(|item| item.commonjs) } + pub fn default_name_result(&self, module_id: &ModuleId) -> Result { + self + .default_name(module_id) + .to_result("not found module {:?} default name") + } + fn entry_module(&mut self, module_id: &ModuleId) -> &mut ModuleGlobalName { if !self.module_map.contains_key(module_id) { self @@ -225,6 +236,7 @@ impl<'a> ModuleAnalyzerManager<'a> { Ok(()) } + #[inline] pub fn is_commonjs(&self, module_id: &ModuleId) -> bool { self .module_map @@ -233,6 +245,15 @@ impl<'a> ModuleAnalyzerManager<'a> { .unwrap_or(false) } + #[inline] + pub fn is_entry(&self, module_id: &ModuleId) -> bool { + self + .module_map + .get(module_id) + .map(|item| item.entry) + .unwrap_or(false) + } + pub fn module_system(&self, module_id: &ModuleId) -> ModuleSystem { self .module_map @@ -286,6 +307,16 @@ impl<'a> ModuleAnalyzerManager<'a> { self.module_map.get_mut(module_id).unwrap() } + #[inline] + pub fn set_ast_body(&mut self, module_id: &ModuleId, ast_body: Vec) { + self.module_analyzer_mut_unchecked(module_id).ast.body = ast_body; + } + + #[inline] + pub fn set_ast(&mut self, module_id: &ModuleId, ast_body: Module) { + self.module_analyzer_mut_unchecked(module_id).ast = ast_body; + } + pub fn module_analyzer_by_source( &self, module_id: &ModuleId, @@ -331,8 +362,6 @@ impl<'a> ModuleAnalyzerManager<'a> { module_id: &ModuleId, bundle_variable: &BundleVariable, ) -> Arc { - let mut map = ReferenceMap::new(self.module_system(module_id)); - let exports_stmts = if let Some(module_analyzer) = self.module_analyzer(module_id) { if let Some(export_names) = &module_analyzer.export_names { return export_names.clone(); @@ -347,6 +376,13 @@ impl<'a> ModuleAnalyzerManager<'a> { vec![] }; + let mut map = ReferenceMap::new(self.module_system(module_id)); + + // preventing circular references + if let Some(m) = self.module_analyzer_mut(module_id) { + m.export_names = Some(Arc::new(map.clone())); + } + for export in exports_stmts { for specify in export.specifiers.iter() { if let Some(ref source) = export.source { @@ -397,6 +433,10 @@ impl<'a> ModuleAnalyzerManager<'a> { } } + if self.is_commonjs(module_id) && self.module_analyzer(module_id).is_some_and(|m| m.entry) { + // map + } + if let Some(m) = self.module_analyzer_mut(module_id) { m.export_names = Some(Arc::new(map)); } @@ -414,6 +454,7 @@ impl<'a> ModuleAnalyzerManager<'a> { commonjs_import_executed: &mut HashSet, order_index_map: &HashMap, polyfill: &mut SimplePolyfill, + external_config: &ExternalConfig, ) -> Result<()> { farm_profile_function!(format!( "patch module analyzer ast: {}", @@ -432,6 +473,7 @@ impl<'a> ModuleAnalyzerManager<'a> { commonjs_import_executed, order_index_map, polyfill, + external_config, )?; Ok(()) @@ -611,6 +653,7 @@ impl<'a> ModuleAnalyzerManager<'a> { commonjs_import_executed: &mut HashSet, order_index_map: &HashMap, polyfill: &mut SimplePolyfill, + external_config: &ExternalConfig, ) -> Result<()> { farm_profile_function!(""); @@ -676,6 +719,9 @@ impl<'a> ModuleAnalyzerManager<'a> { module_graph, &self.module_global_uniq_name, bundle_variable, + &context.config, + polyfill, + external_config ) } @@ -695,7 +741,7 @@ impl<'a> ModuleAnalyzerManager<'a> { ast.visit_mut_with(&mut RenameIdent::new(rename_map)); - self.module_analyzer_mut(module_id).unwrap().ast = ast; + self.set_ast(module_id, ast); } }) .unwrap(); @@ -816,7 +862,15 @@ impl<'a> ModuleAnalyzerManager<'a> { .add_namespace(source, |s| bundle_variable.register_used_name_by_module_id(source, s, root)); } } - _ => {} + ExportSpecifierInfo::Named(var) => { + if bundle_variable.name(var.local()) == "default" { + self + .module_global_uniq_name + .add_default(&module_analyzer.module_id, |s| { + bundle_variable.register_used_name_by_module_id(&module_analyzer.module_id, s, root) + }); + } + } } } } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/common.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/common.rs index 97f66b0db1..6e1f85c2df 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/common.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/common.rs @@ -7,7 +7,7 @@ use farmfe_core::{ module::Module, swc_common::{comments::SingleThreadedComments, Mark}, swc_ecma_ast::{Module as EcmaAstModule, ModuleItem}, - swc_ecma_parser::{lexer::Lexer, EsConfig, Parser, StringInput, Syntax}, + swc_ecma_parser::{lexer::Lexer, EsSyntax as EsConfig, Parser, StringInput, Syntax}, }; use farmfe_toolkit::{ common::{create_swc_source_map, Source}, @@ -56,7 +56,6 @@ pub fn parse_module_item(string: &str) -> Result { pub trait OptionToResult { fn to_result(self, error: S) -> Result; - fn to_result_with_error(self, error: CompilationError) -> Result; } impl OptionToResult for std::option::Option { @@ -66,11 +65,4 @@ impl OptionToResult for std::option::Option { None => Err(CompilationError::GenericError(error.to_string())), } } - - fn to_result_with_error(self, error: CompilationError) -> Result { - match self { - Some(v) => Ok(v), - None => Err(error), - } - } } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/mod.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/mod.rs index a92c74a915..040934a262 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/mod.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/mod.rs @@ -242,14 +242,38 @@ impl<'a> SharedBundle<'a> { let bundle_analyzer = self.bundle_map.get_mut(resource_pot_id).unwrap(); - bundle_analyzer - .bundle_variable - .borrow_mut() - .set_namespace(bundle_analyzer.resource_pot.id.clone()); + bundle_analyzer.set_namespace(&bundle_analyzer.resource_pot.id); bundle_analyzer.render(&mut self.module_analyzer_manager, &self.order_index_map)?; } + let mut polyfill = SimplePolyfill::new(vec![]); + + for resource_pot_id in &self.order_resource_pot { + let bundle_analyzer = self.bundle_map.get(resource_pot_id).unwrap(); + + if matches!( + bundle_analyzer.resource_pot.resource_pot_type, + ResourcePotType::Js + ) { + polyfill.extends(&bundle_analyzer.polyfill); + } + } + + let runtime_resource_pot_id = self.order_resource_pot.iter().find(|item| { + self.bundle_map.get_mut(*item).is_some_and(|item| { + matches!( + item.resource_pot.resource_pot_type, + ResourcePotType::Runtime + ) + }) + }); + + if let Some(runtime_resource_pot_id) = runtime_resource_pot_id { + let bundle_analyzer = self.bundle_map.get_mut(runtime_resource_pot_id).unwrap(); + bundle_analyzer.polyfill.extends(&polyfill); + }; + Ok(()) } @@ -272,7 +296,7 @@ impl<'a> SharedBundle<'a> { let bundle = self.bundle_map.get_mut(resource_pot_id).unwrap(); - let bundle = bundle.codegen(&mut self.module_analyzer_manager)?; + let bundle = bundle.codegen(&mut self.module_analyzer_manager, &self.context.config)?; Ok(bundle) } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/analyze.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/analyze.rs index f0138ad673..56bd5616be 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/analyze.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/analyze.rs @@ -6,7 +6,7 @@ use farmfe_core::{ module::{module_graph::ModuleGraph, ModuleId}, swc_common::Mark, swc_ecma_ast::{ - self, Decl, DefaultDecl, ExportDecl, Expr, Ident, ImportSpecifier, ModuleDecl, + self, DefaultDecl, ExportDecl, Expr, Ident, ImportSpecifier, ModuleDecl, ModuleExportName, ModuleItem, }, }; diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/module_analyzer.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/module_analyzer.rs index 5ac0ccc4a0..d498362f58 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/module_analyzer.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/modules_analyzer/module_analyzer.rs @@ -9,7 +9,7 @@ use farmfe_core::{ context::CompilationContext, error::Result, farm_profile_function, - module::{module_graph::ModuleGraph, Module, ModuleId, ModuleSystem}, + module::{module_graph::ModuleGraph, Module, ModuleId, ModuleSystem, ModuleType}, resource::resource_pot::ResourcePotId, swc_common::{Mark, SourceMap}, swc_ecma_ast::{Id, Module as EcmaAstModule}, @@ -242,6 +242,7 @@ pub struct ModuleAnalyzer { pub cjs_module_analyzer: CjsModuleAnalyzer, pub mark: (Mark, Mark), pub module_system: ModuleSystem, + pub module_type: ModuleType, } impl Debug for ModuleAnalyzer { @@ -302,6 +303,7 @@ impl ModuleAnalyzer { cjs_module_analyzer: CjsModuleAnalyzer::new(), mark: mark.unwrap(), module_system: module.meta.as_script().module_system.clone(), + module_type: module.module_type.clone(), }) } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/polyfill/mod.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/polyfill/mod.rs index 2358d730ab..76e007b2fd 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/polyfill/mod.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/polyfill/mod.rs @@ -55,6 +55,26 @@ pub enum Polyfill { /// const fs = _interop_require_default(node_fs); /// ``` InteropRequireDefault, + /// + /// support use require in esm + /// + /// ```ts + /// // esm pre + /// import __farmNodeModule from 'module'; + /// globalThis.nodeRequire = __farmNodeModule.createRequire(import.meta.url); + /// ``` + /// + NodeEsmGlobalRequireHelper, + + /// + /// browser external load + /// ```ts + /// const events = require("events"); + /// // => + /// loadExternalRequire('events'); + /// ``` + /// + BrowserExternalRequire, } impl Polyfill { @@ -161,6 +181,34 @@ function _interop_require_default(obj) { } "#), ], + Polyfill::NodeEsmGlobalRequireHelper => vec![ + r#" +import __farmNodeModule from 'module'; +globalThis.nodeRequire = __farmNodeModule.createRequire(import.meta.url); +"#, + ], + Polyfill::BrowserExternalRequire => vec![ + r#" +function loadExternalRequire(name) { + var _g = (globalThis || window || {}); + var m = _g[name]; + var assign = function() { + var args = Array.prototype.slice.call(arguments); + var target = args.shift(); + var hasOwnProperty = Object.hasOwnProperty; + for(var i = 0; i < args.length; i ++) { + for(var key in args[i]) { + if(!hasOwnProperty.call(target, key)) { + target[key] = args[i][key]; + } + } + } + return target; + } + return m ? m.default && !m.__esModule ? assign({}, m, {__esModule: true}) : (assign({}, m)) : m; +}; + "#, + ], } .into_iter() .map(|item| item.trim().into()) @@ -188,6 +236,8 @@ function _interop_require_default(obj) { Polyfill::Wildcard => vec!["_getRequireWildcardCache", "_interop_require_wildcard"], Polyfill::ExportStar => vec!["_export_star"], Polyfill::InteropRequireDefault => vec!["_interop_require_default"], + Polyfill::NodeEsmGlobalRequireHelper => vec!["__farmNodeModule"], + Polyfill::BrowserExternalRequire => vec!["loadExternalRequire"], }) .into_iter() .map(|item| item.into()) @@ -266,6 +316,7 @@ impl SimplePolyfill { Polyfill::Wildcard, Polyfill::ExportStar, Polyfill::InteropRequireDefault, + Polyfill::NodeEsmGlobalRequireHelper, ] .into_iter() .flat_map(|polyfill| polyfill.name()) diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/mod.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/mod.rs index 92150c1c8e..e4faaefcba 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/mod.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/mod.rs @@ -5,8 +5,8 @@ use farmfe_core::{ module::{module_graph::ModuleGraph, ModuleId}, swc_common::{Mark, DUMMY_SP}, swc_ecma_ast::{ - self, BindingIdent, CallExpr, ComputedPropName, Expr, ExprOrSpread, Ident, Lit, MemberExpr, - MemberProp, Module as EcmaAstModule, ModuleItem, Pat, Stmt, VarDecl, VarDeclarator, + self, BindingIdent, CallExpr, ComputedPropName, Expr, ExprOrSpread, ExprStmt, Ident, Lit, + MemberExpr, MemberProp, Module as EcmaAstModule, ModuleItem, Pat, Stmt, VarDecl, VarDeclarator, }, }; use farmfe_toolkit::{ @@ -131,6 +131,14 @@ impl CjsModuleAnalyzer { type_args: None, }; + if reference_import.is_empty() { + result.push(ModuleItem::Stmt(Stmt::Expr(ExprStmt { + span: DUMMY_SP, + expr: Box::new(Expr::Call(cjs_caller)), + }))); + return result; + } + if let Some(default) = reference_import.default { decls.push(VarDeclarator { span: DUMMY_SP, diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/patch.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/patch.rs index 49f1520619..ac4f82c4e7 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/patch.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/patch.rs @@ -1,7 +1,7 @@ use std::sync::Arc; use farmfe_core::{ - config::Mode, + config::{external::ExternalConfig, Config, Mode}, context::CompilationContext, error::Result, module::{module_graph::ModuleGraph, ModuleId, ModuleSystem}, @@ -18,7 +18,7 @@ use farmfe_toolkit::{ modules::{ common_js, import_analysis::import_analyzer, - util::{Config, ImportInterop}, + util::{Config as SwcConfig, ImportInterop}, }, }, swc_ecma_visit::VisitMutWith, @@ -125,7 +125,7 @@ impl CjsPatch { ast.visit_mut_with(&mut common_js::<&SingleThreadedComments>( unresolved_mark, - Config { + SwcConfig { ignore_dynamic: true, preserve_import_meta: true, ..Default::default() @@ -165,20 +165,18 @@ impl CjsPatch { if module_analyzer.is_commonjs() { let ast = module_analyzer.ast.body.take(); - let new_body = CjsPatch::wrap_commonjs( + module_analyzer_manager.set_ast_body( module_id, - bundle_variable, - &module_analyzer_manager.module_global_uniq_name, - ast, - context.config.mode.clone(), - polyfill, - ) - .unwrap(); - - module_analyzer_manager - .module_analyzer_mut_unchecked(module_id) - .ast - .body = new_body; + CjsPatch::wrap_commonjs( + module_id, + bundle_variable, + &module_analyzer_manager.module_global_uniq_name, + ast, + context.config.mode.clone(), + polyfill, + ) + .unwrap(), + ); } if let Some(import) = bundle_reference @@ -202,6 +200,9 @@ impl CjsPatch { module_graph: &ModuleGraph, module_global_uniq_name: &ModuleGlobalUniqName, bundle_variable: &BundleVariable, + config: &Config, + polyfill: &mut SimplePolyfill, + external_config: &ExternalConfig, ) { let mut replacer: CJSReplace = CJSReplace { unresolved_mark: mark.0, @@ -210,6 +211,9 @@ impl CjsPatch { module_id: module_id.clone(), module_global_uniq_name, bundle_variable, + config, + polyfill, + external_config }; ast.visit_mut_with(&mut replacer); diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/util.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/util.rs index 9ccad2ab97..5260f019fb 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/util.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/targets/cjs/util.rs @@ -1,14 +1,17 @@ use farmfe_core::{ + config::{external::ExternalConfig, Config, ModuleFormat}, module::{module_graph::ModuleGraph, ModuleId}, swc_common::{Mark, DUMMY_SP}, - swc_ecma_ast::{CallExpr, Expr, ExprOrSpread, Lit}, + swc_ecma_ast::{CallExpr, Callee, Expr, ExprOrSpread, Lit, MemberExpr, MemberProp}, }; use farmfe_toolkit::{ script::is_commonjs_require, swc_ecma_visit::{VisitMut, VisitMutWith}, }; -use crate::resource_pot_to_bundle::{bundle::ModuleGlobalUniqName, uniq_name::BundleVariable}; +use crate::resource_pot_to_bundle::{ + bundle::ModuleGlobalUniqName, uniq_name::BundleVariable, Polyfill, SimplePolyfill, +}; enum ReplaceType { None, @@ -52,6 +55,9 @@ pub struct CJSReplace<'a> { pub module_id: ModuleId, pub module_global_uniq_name: &'a ModuleGlobalUniqName, pub bundle_variable: &'a BundleVariable, + pub config: &'a Config, + pub polyfill: &'a mut SimplePolyfill, + pub external_config: &'a ExternalConfig, } impl<'a> VisitMut for CJSReplace<'a> { @@ -77,10 +83,42 @@ impl<'a> VisitMut for CJSReplace<'a> { .module_graph .get_dep_by_source_optional(&self.module_id, &source, None) { - if let Some(commonjs_name) = self.module_global_uniq_name.commonjs_name(&id) { + if self.module_graph.module(&id).is_some_and(|m| m.external) { + if self.config.output.target_env.is_library() + && self.config.output.target_env.is_node() + { + // node esm + if matches!(self.config.output.format, ModuleFormat::EsModule) { + self.polyfill.add(Polyfill::NodeEsmGlobalRequireHelper); + call_expr.callee = Callee::Expr(Box::new(Expr::Member(MemberExpr { + span: DUMMY_SP, + obj: Box::new(Expr::Ident("globalThis".into())), + prop: MemberProp::Ident("nodeRequire".into()), + }))); + } + } else { + // browser + self.polyfill.add(Polyfill::BrowserExternalRequire); + + let replace_source = self + .external_config + .find_match(&source) + .map(|v| v.source(&source)) + // it's maybe from plugin + .unwrap_or(source.clone()); + + call_expr.callee = + Callee::Expr(Box::new(Expr::Ident("loadExternalRequire".into()))); + call_expr.args = vec![ExprOrSpread { + spread: None, + expr: Box::new(Expr::Lit(Lit::Str(replace_source.into()))), + }]; + call_expr.span = DUMMY_SP; + } + } else if let Some(commonjs_name) = self.module_global_uniq_name.commonjs_name(&id) { *call_expr = CallExpr { span: DUMMY_SP, - callee: farmfe_core::swc_ecma_ast::Callee::Expr(Box::new(Expr::Ident( + callee: Callee::Expr(Box::new(Expr::Ident( self .bundle_variable .render_name(commonjs_name) @@ -95,7 +133,7 @@ impl<'a> VisitMut for CJSReplace<'a> { replaced = ReplaceType::Ident(ns); } } - // TODO: other bundle | external + // TODO: other bundle } } diff --git a/crates/plugin_bundle/src/resource_pot_to_bundle/uniq_name.rs b/crates/plugin_bundle/src/resource_pot_to_bundle/uniq_name.rs index ac07c359c8..aa8bade747 100644 --- a/crates/plugin_bundle/src/resource_pot_to_bundle/uniq_name.rs +++ b/crates/plugin_bundle/src/resource_pot_to_bundle/uniq_name.rs @@ -309,6 +309,11 @@ impl BundleVariable { self.var_by_index(index).var.0.to_string() } + #[inline] + pub fn is_default_key(&self, index: usize) -> bool { + self.name(index) == "default" + } + pub fn render_name(&self, index: usize) -> String { let var = self.var_by_index(index); if let Some(rename) = var.rename.as_ref() { diff --git a/crates/plugin_runtime/src/handle_entry_resources.rs b/crates/plugin_runtime/src/handle_entry_resources.rs index 6cf71d4ec6..9d46f2fd66 100644 --- a/crates/plugin_runtime/src/handle_entry_resources.rs +++ b/crates/plugin_runtime/src/handle_entry_resources.rs @@ -292,6 +292,7 @@ pub fn handle_entry_resources( ) { let module_graph = context.module_graph.read(); let module_group_graph = context.module_group_graph.read(); + let is_library = context.config.output.target_env.is_library(); // create a runtime resource let mut runtime_code = None; @@ -385,7 +386,7 @@ pub fn handle_entry_resources( for pre in vec![ dep_resources_require_code, - if should_inject_runtime { + if should_inject_runtime && !is_library { let runtime_resource = if let Some(runtime_resource) = runtime_resource.as_ref() { runtime_resource } else { @@ -404,13 +405,15 @@ pub fn handle_entry_resources( entry_bundle.prepend(&pre); } - for post in vec![ - set_initial_loaded_resources_code, - set_dynamic_resources_map_code, - call_entry_code, - export_info_code, - ] { - entry_bundle.append(&post); + if !is_library { + for post in vec![ + set_initial_loaded_resources_code, + set_dynamic_resources_map_code, + call_entry_code, + export_info_code, + ] { + entry_bundle.append(&post); + } } let entry_bundle_code = entry_bundle.to_string(); @@ -454,7 +457,7 @@ fn create_runtime_code( resources_map: &HashMap, context: &Arc, ) -> String { - let node_specific_code = if context.config.output.target_env == TargetEnv::Node { + let node_specific_code = if context.config.output.target_env.is_node() { match context.config.output.format { ModuleFormat::EsModule => { format!( diff --git a/crates/plugin_runtime/src/lib.rs b/crates/plugin_runtime/src/lib.rs index 91ff7bf4e6..139d144a3a 100644 --- a/crates/plugin_runtime/src/lib.rs +++ b/crates/plugin_runtime/src/lib.rs @@ -59,11 +59,9 @@ impl Plugin for FarmPluginRuntime { } fn config(&self, config: &mut Config) -> farmfe_core::error::Result> { - // library bundle does not contain runtime if config.output.target_env.is_library() { return Ok(None); } - // runtime package entry file if !config.runtime.path.is_empty() { config.input.insert( diff --git a/crates/plugin_script/src/import_meta_visitor.rs b/crates/plugin_script/src/import_meta_visitor.rs index 2b5a08ef80..0148a2f99c 100644 --- a/crates/plugin_script/src/import_meta_visitor.rs +++ b/crates/plugin_script/src/import_meta_visitor.rs @@ -7,7 +7,8 @@ use farmfe_core::{ plugin::{PluginResolveHookParam, ResolveKind}, swc_common::DUMMY_SP, swc_ecma_ast::{ - CallExpr, Callee, Expr, ExprOrSpread, Ident, Lit, MemberExpr, MemberProp, MetaPropKind, Str, + CallExpr, Callee, Expr, ExprOrSpread, Ident, Lit, MemberExpr, MemberProp, MetaPropKind, + NewExpr, Str, }, }; use farmfe_toolkit::swc_ecma_visit::{VisitMut, VisitMutWith}; @@ -155,3 +156,62 @@ impl VisitMut for HmrAcceptedVisitor { } } } + +/// +/// transform when cjs and library +/// ```ts +/// import.meta.url +/// // => +/// new URL(__filename, 'file:').href +/// ``` +/// +struct ImportMetaURLVisitor {} + +impl ImportMetaURLVisitor { + fn replace_import_meta_url(&self, n: &mut Expr) -> bool { + if let Expr::Member(member) = n { + if let box Expr::MetaProp(_) = member.obj { + if let MemberProp::Ident(ident) = &member.prop { + if ident.sym == "url" { + *n = Expr::Member(MemberExpr { + span: DUMMY_SP, + obj: Box::new(Expr::New(NewExpr { + span: DUMMY_SP, + callee: Box::new(Expr::Ident("URL".into())), + args: Some(vec![ + ExprOrSpread { + spread: None, + expr: Box::new(Expr::Ident("__filename".into())), + }, + ExprOrSpread { + spread: None, + expr: Box::new(Expr::Lit(Lit::Str("file:".into()))), + }, + ]), + type_args: None, + })), + prop: MemberProp::Ident("href".into()), + }); + + return true; + } + } + } + } + + false + } +} + +impl VisitMut for ImportMetaURLVisitor { + fn visit_mut_expr(&mut self, n: &mut Expr) { + if !self.replace_import_meta_url(n) { + n.visit_mut_children_with(self); + } + } +} + +pub fn replace_import_meta_url(ast: &mut farmfe_core::swc_ecma_ast::Module) { + let mut visitor = ImportMetaURLVisitor {}; + ast.visit_mut_with(&mut visitor); +} diff --git a/crates/plugin_script/src/lib.rs b/crates/plugin_script/src/lib.rs index 99ea2b11e0..70a9863765 100644 --- a/crates/plugin_script/src/lib.rs +++ b/crates/plugin_script/src/lib.rs @@ -41,7 +41,7 @@ use farmfe_toolkit::{ swc_ecma_visit::VisitMutWith, }; -use import_meta_visitor::ImportMetaVisitor; +use import_meta_visitor::{replace_import_meta_url, ImportMetaVisitor}; #[cfg(feature = "swc_plugin")] use swc_plugins::{init_plugin_module_cache_once, transform_by_swc_plugins}; @@ -193,7 +193,9 @@ impl Plugin for FarmPluginScript { .to_string_lossy() .to_string() }; + transform_url_with_import_meta_url(ast, &comments); + transform_import_meta_glob( ast, context.config.root.clone(), @@ -249,10 +251,19 @@ impl Plugin for FarmPluginScript { // set param.module.meta.module_system set_module_system_for_module_meta(param, context); + let is_replace_import_meta_url = context.config.output.target_env.is_library() + && matches!(context.config.output.format, ModuleFormat::CommonJs); + + if is_replace_import_meta_url { + let ast = &mut param.module.meta.as_script_mut().ast; + replace_import_meta_url(ast) + }; + // find and replace `import.meta.xxx` to `module.meta.xxx` and detect hmr_accepted // skip transform import.meta when targetEnv is node - if matches!(context.config.output.target_env, TargetEnv::Browser) - || matches!(context.config.output.format, ModuleFormat::CommonJs) + if !context.config.output.target_env.is_library() + && (matches!(context.config.output.target_env, TargetEnv::Browser) + || matches!(context.config.output.format, ModuleFormat::CommonJs)) { // transform `import.meta.xxx` to `module.meta.xxx` let ast = &mut param.module.meta.as_script_mut().ast; diff --git a/crates/plugin_script/src/transform_import_meta_url/mod.rs b/crates/plugin_script/src/transform_import_meta_url/mod.rs index e342ec2555..ccb3cdb4af 100644 --- a/crates/plugin_script/src/transform_import_meta_url/mod.rs +++ b/crates/plugin_script/src/transform_import_meta_url/mod.rs @@ -69,7 +69,7 @@ fn normalized_glob_pattern(pattern: String) -> String { return pattern_builder.join("/"); } -// transform `new URL("url", import.meta.url)` to `new URL(import.meta.glob('url', { eager: true, import: 'default', query: 'url' }), import.meta.url71)` +// transform `new URL("url", import.meta.url)` to `new URL(import.meta.glob('url', { eager: true, import: 'default', query: 'url' }), import.meta.url)` struct ImportMetaURLVisitor<'a> { comments: &'a SingleThreadedComments, } diff --git a/crates/utils/src/lib.rs b/crates/utils/src/lib.rs index f51cc473e2..eb751b2ef7 100644 --- a/crates/utils/src/lib.rs +++ b/crates/utils/src/lib.rs @@ -13,7 +13,7 @@ pub const FARM_IGNORE_ACTION_COMMENT: &str = "$farm-ignore"; pub const FARM_IGNORE_ACTION_COMMENTS: [&str; 2] = [FARM_IGNORE_ACTION_COMMENT, "$vite-ignore"]; pub fn is_skip_action_by_comment(comment: &str) -> bool { - if comment.is_empty() || !comment.contains("$") { + if comment.is_empty() || !comment.contains('$') { return false; } @@ -82,8 +82,8 @@ pub fn file_url_to_path(url: &str) -> String { let url = url.replace("file://", ""); if cfg!(windows) { - if let Some(url) = url.strip_prefix("/") { - url.replace("/", "\\") + if let Some(url) = url.strip_prefix('/') { + url.replace('/', "\\") } else { url.replace("/", "\\") } diff --git a/packages/core/src/utils/share.ts b/packages/core/src/utils/share.ts index a086b26c94..9a12e1e743 100644 --- a/packages/core/src/utils/share.ts +++ b/packages/core/src/utils/share.ts @@ -26,6 +26,12 @@ export const FARM_TARGET_BROWSER_ENVS = [ 'browser-esnext' ]; +export const FARM_TARGET_LIBRARY_ENVS = [ + 'library', + 'library-node', + 'library-browser' +]; + /* eslint-disable @typescript-eslint/no-use-before-define */ export function isObject(value: unknown): value is Record { return Object.prototype.toString.call(value) === '[object Object]'; @@ -158,7 +164,11 @@ export function mapTargetEnvValue(config: Config['config']) { } else if (FARM_TARGET_BROWSER_ENVS.includes(config.output.targetEnv)) { config.output.targetEnv = 'browser'; } else { - config.output.targetEnv = 'library'; + if (FARM_TARGET_LIBRARY_ENVS.includes(config.output.targetEnv)) { + return; + } + + config.output.targetEnv = 'library-browser'; } } From eff069c41706c5a2fecfadb07f1471f5ce9e5362 Mon Sep 17 00:00:00 2001 From: ADNY <66500121+ErKeLost@users.noreply.github.com> Date: Mon, 29 Jul 2024 12:32:57 +0800 Subject: [PATCH 9/9] chore: Improve binary performance and codspeed ci (#1667) * chore: optimize binary size * chore: bump version * chore: optimize binary size * chore: add cargo test ci * chore: test codspeed * chore: test codspeed * chore: update ci * chore: update bench * chore: update bench * chore: update bench * chore: update bench * chore: update bench * chore: update workspace * chore: update workspace * chore: update bench * chore: update bench * chore: update bench * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: update ci * chore: update ci --- .changeset/weak-tables-grin.md | 5 + .github/workflows/codspeed.yml | 45 ++ .github/workflows/rust-test.yaml | 2 +- Cargo.lock | 138 ++++- Cargo.toml | 26 +- bench/benches/example.bench.ts | 25 + bench/package.json | 12 + bench/vitest.config.mts | 6 + crates/bench/Cargo.toml | 20 + crates/bench/benches/compiler_bench.rs | 56 ++ cspell.json | 10 +- examples/arco-pro/farm.config.ts | 4 +- examples/react/farm.config.js | 2 +- package.json | 9 +- packages/core/package.json | 2 +- pnpm-lock.yaml | 739 +++++++++++++++---------- pnpm-workspace.yaml | 1 + 17 files changed, 774 insertions(+), 328 deletions(-) create mode 100644 .changeset/weak-tables-grin.md create mode 100644 .github/workflows/codspeed.yml create mode 100644 bench/benches/example.bench.ts create mode 100644 bench/package.json create mode 100644 bench/vitest.config.mts create mode 100644 crates/bench/Cargo.toml create mode 100644 crates/bench/benches/compiler_bench.rs diff --git a/.changeset/weak-tables-grin.md b/.changeset/weak-tables-grin.md new file mode 100644 index 0000000000..cce25fe3dc --- /dev/null +++ b/.changeset/weak-tables-grin.md @@ -0,0 +1,5 @@ +--- +"@farmfe/core": patch +--- + +chore: Improve binary performance diff --git a/.github/workflows/codspeed.yml b/.github/workflows/codspeed.yml new file mode 100644 index 0000000000..dc53e363f2 --- /dev/null +++ b/.github/workflows/codspeed.yml @@ -0,0 +1,45 @@ +name: codspeed-benchmarks + +on: + push: + branches: + - "main" + pull_request: + # `workflow_dispatch` allows CodSpeed to trigger backtest + # performance analysis in order to generate initial data. + workflow_dispatch: + +jobs: + call-rust-build: + uses: ./.github/workflows/rust-build.yaml + + benchmarks: + needs: [call-rust-build] + runs-on: ${{ matrix.settings.os }} + strategy: + fail-fast: false + matrix: + settings: + - os: ubuntu-latest + abi: linux-x64-gnu + steps: + - uses: "actions/checkout@v3" + - uses: actions/setup-node@v3 + with: + node-version: 18 + - name: Install Dependencies + run: npm install -g pnpm@9.4.0 && pnpm i --frozen-lockfile + - name: Build CLI and Core + run: pnpm --filter @farmfe/cli run build + - uses: actions/download-artifact@v3 + id: download + with: + name: ${{ github.sha }}-${{ matrix.settings.abi }} + path: ./packages/core/binding + - name: Build Core CJS + run: cd packages/core && pnpm run build:cjs + - name: Run benchmarks + uses: CodSpeedHQ/action@v3 + with: + run: npm exec vitest bench + token: ${{ secrets.CODSPEED_TOKEN }} diff --git a/.github/workflows/rust-test.yaml b/.github/workflows/rust-test.yaml index 28df5a256b..9afb2c882e 100644 --- a/.github/workflows/rust-test.yaml +++ b/.github/workflows/rust-test.yaml @@ -55,4 +55,4 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Run cargo test - run: cargo test --release --tests + run: cargo test --profile ci-test --tests diff --git a/Cargo.lock b/Cargo.lock index a8aa175c00..fd883d7cae 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -138,6 +138,12 @@ dependencies = [ "libc", ] +[[package]] +name = "anes" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "735d4f398ca57cfa2880225c2bf81c3b9af3be5bb22e44ae70118dad38713e84" + [[package]] name = "anstream" version = "0.6.9" @@ -324,6 +330,15 @@ dependencies = [ "simd-abstraction", ] +[[package]] +name = "bench" +version = "0.0.1" +dependencies = [ + "criterion2", + "farmfe_compiler", + "farmfe_core", +] + [[package]] name = "better_scoped_tls" version = "0.1.1" @@ -434,6 +449,12 @@ dependencies = [ "objc2 0.5.2", ] +[[package]] +name = "bpaf" +version = "0.9.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3280efcf6d66bc77c2cf9b67dc8acee47a217d9be67dd590b3230dffe663724d" + [[package]] name = "browserslist-rs" version = "0.16.0" @@ -561,6 +582,12 @@ dependencies = [ "vec_map", ] +[[package]] +name = "cast" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "37b2a672a2cb129a2e41c10b1224bb368f9f37a2b16b612598138befd7b37eb5" + [[package]] name = "cc" version = "1.0.83" @@ -610,6 +637,33 @@ dependencies = [ "windows-targets 0.52.0", ] +[[package]] +name = "ciborium" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "42e69ffd6f0917f5c029256a24d0161db17cea3997d185db0d35926308770f0e" +dependencies = [ + "ciborium-io", + "ciborium-ll", + "serde", +] + +[[package]] +name = "ciborium-io" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05afea1e0a06c9be33d539b876f1ce3692f4afea2cb41f740e7743225ed1c757" + +[[package]] +name = "ciborium-ll" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57663b653d948a338bfb3eeba9bb2fd5fcfaecb9e199e87e1eda4d9e8b240fd9" +dependencies = [ + "ciborium-io", + "half 2.4.1", +] + [[package]] name = "clap" version = "4.5.9" @@ -689,6 +743,17 @@ dependencies = [ "objc", ] +[[package]] +name = "codspeed" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3a104ac948e0188b921eb3fcbdd55dcf62e542df4c7ab7e660623f6288302089" +dependencies = [ + "colored", + "libc", + "serde_json", +] + [[package]] name = "color_quant" version = "1.1.0" @@ -701,6 +766,16 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" +[[package]] +name = "colored" +version = "2.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" +dependencies = [ + "lazy_static", + "windows-sys 0.48.0", +] + [[package]] name = "combine" version = "4.6.7" @@ -951,6 +1026,25 @@ dependencies = [ "napi-derive", ] +[[package]] +name = "criterion2" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7258985df1aa8b33359ee2392cbc3b7802875242cdacdda91a17a602132c24a9" +dependencies = [ + "anes", + "bpaf", + "cast", + "ciborium", + "codspeed", + "colored", + "num-traits", + "oorandom", + "serde", + "serde_json", + "walkdir", +] + [[package]] name = "critical-section" version = "1.1.2" @@ -1000,6 +1094,12 @@ version = "0.8.19" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "248e3bacc7dc6baa3b21e405ee045c3047101a49145e7e9eca583ab4c2ca5345" +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + [[package]] name = "crypto-common" version = "0.1.6" @@ -2249,6 +2349,16 @@ version = "1.8.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "eabb4a44450da02c90444cf74558da904edde8fb4e9035a9a6a4e15445af0bd7" +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", +] + [[package]] name = "hash32" version = "0.2.1" @@ -3245,9 +3355,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" dependencies = [ "autocfg", ] @@ -3459,6 +3569,12 @@ version = "1.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +[[package]] +name = "oorandom" +version = "11.1.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b410bbe7e14ab526a0e86877eb47c6996a2bd7746f027ba551028c925390e4e9" + [[package]] name = "option-ext" version = "0.2.0" @@ -4286,9 +4402,9 @@ checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" [[package]] name = "serde" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fb1c873e1b9b056a4dc4c0c198b24c3ffa059243875552b2bd0933b1aee4ce2" +checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" dependencies = [ "serde_derive", ] @@ -4310,15 +4426,15 @@ version = "0.11.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2bef2ebfde456fb76bbcf9f59315333decc4fda0b2b44b420243c11e0f5ec1f5" dependencies = [ - "half", + "half 1.8.2", "serde", ] [[package]] name = "serde_derive" -version = "1.0.197" +version = "1.0.204" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b" +checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" dependencies = [ "proc-macro2", "quote", @@ -4327,9 +4443,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.115" +version = "1.0.120" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "12dc5c46daa8e9fdf4f5e71b6cf9a53f2487da0e86e55808e2d35539666497dd" +checksum = "4e0d21c9a8cae1235ad58a00c11cb40d4b1e5c784f1ef2c537876ed6ffd8b7c5" dependencies = [ "indexmap 2.2.6", "itoa", @@ -6319,9 +6435,9 @@ checksum = "f3c4517f54858c779bbcbf228f4fca63d121bf85fbecb2dc578cdf4a39395690" [[package]] name = "walkdir" -version = "2.4.0" +version = "2.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d71d857dc86794ca4c280d616f7da00d2dbfd8cd788846559a6813e6aa4b54ee" +checksum = "29790946404f91d9c5d06f9874efddea1dc06c5efe94541a7d6863108e3a5e4b" dependencies = [ "same-file", "winapi-util", diff --git a/Cargo.toml b/Cargo.toml index 87782fe381..8704946b2e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,23 @@ [workspace] -members = [ - "crates/*", - "packages/create-farm", - "rust-plugins/*", -] +members = ["crates/*", "packages/create-farm", "rust-plugins/*"] resolver = "2" + +[workspace.package] +edition = "2021" +homepage = "https://farmfe.org" +license = "MIT" +repository = "https://github.com/farm-fe/farm" + +[profile.release] +codegen-units = 1 +lto = "fat" +opt-level = 3 +strip = true +panic = "abort" + +[profile.ci-test] +inherits = "release" +opt-level = 0 +debug = 2 +lto = false +codegen-units = 16 diff --git a/bench/benches/example.bench.ts b/bench/benches/example.bench.ts new file mode 100644 index 0000000000..8193c5965a --- /dev/null +++ b/bench/benches/example.bench.ts @@ -0,0 +1,25 @@ +import path from 'node:path'; +import { bench, describe } from 'vitest'; +import { build } from '@farmfe/core'; + +async function build_react_example() { + await build({ + root: path.resolve(process.cwd(), './examples/react'), + configPath: path.resolve('./examples/react'), + compilation: { input: {}, output: {} } + }); +} + +describe('react_example_bench', () => { + let hasRun = false; + bench( + 'build_react_example', + async () => { + if (!hasRun) { + await build_react_example(); + hasRun = true; + } + }, + { warmupIterations: 0 } + ); +}); diff --git a/bench/package.json b/bench/package.json new file mode 100644 index 0000000000..64a21a4b8d --- /dev/null +++ b/bench/package.json @@ -0,0 +1,12 @@ +{ + "name": "bench", + "version": "1.0.0", + "description": "", + "scripts": {}, + "dependencies": { + "@farmfe/core": "workspace:*" + }, + "keywords": [], + "author": "", + "license": "ISC" +} diff --git a/bench/vitest.config.mts b/bench/vitest.config.mts new file mode 100644 index 0000000000..81970d7aff --- /dev/null +++ b/bench/vitest.config.mts @@ -0,0 +1,6 @@ +import { defineConfig } from 'vitest/config'; +import codspeedPlugin from '@codspeed/vitest-plugin'; + +export default defineConfig({ + plugins: [codspeedPlugin()] +}); diff --git a/crates/bench/Cargo.toml b/crates/bench/Cargo.toml new file mode 100644 index 0000000000..ddc2d9a241 --- /dev/null +++ b/crates/bench/Cargo.toml @@ -0,0 +1,20 @@ +[package] +name = "bench" +version = "0.0.1" + +edition = { workspace = true } +homepage = { workspace = true } +license = { workspace = true } +repository = { workspace = true } + +[dependencies] +criterion2 = { version = "0.11.0", default-features = false } +farmfe_core = { path = "../core", version = "0.6.4" } +farmfe_compiler = { path = "../compiler", version = "0.0.11" } + +[[bench]] +name = "compiler_bench" +harness = false + +[features] +codspeed = ["criterion2/codspeed"] diff --git a/crates/bench/benches/compiler_bench.rs b/crates/bench/benches/compiler_bench.rs new file mode 100644 index 0000000000..44182b613d --- /dev/null +++ b/crates/bench/benches/compiler_bench.rs @@ -0,0 +1,56 @@ +use criterion::{black_box, criterion_group, criterion_main, Criterion}; +// use codspeed_criterion_compat::{black_box, criterion_group, criterion_main, Criterion}; + +use farmfe_compiler::Compiler; +use farmfe_core::{ + config::{Config, RuntimeConfig}, + relative_path::RelativePath, +}; + +fn setup_compiler() -> Compiler { + let relative_root = RelativePath::new("./index.ts"); + let cwd = std::env::current_dir().unwrap(); + let react_examples_root = relative_root.to_logical_path(cwd.clone()); + + Compiler::new( + Config { + root: react_examples_root.to_string_lossy().to_string(), + runtime: Box::new(RuntimeConfig { + path: cwd + .join("packages") + .join("runtime") + .join("src") + .join("index.ts") + .to_string_lossy() + .to_string(), + plugins: vec![], + swc_helpers_path: cwd + .join("packages") + .join("core") + .join("node_modules") + .join("@swc") + .join("helpers") + .read_link() + .unwrap() + .to_string_lossy() + .to_string(), + ..Default::default() + }), + ..Default::default() + }, + vec![], + ) + .unwrap() +} + +fn bench_compiler_compile(c: &mut Criterion) { + let mut compiler = setup_compiler(); + c.bench_function("compiler_compile", |b| { + b.iter(|| { + black_box(compiler.compile().unwrap()); + }) + }); +} + +criterion_group!(benches, bench_compiler_compile); +criterion_main!(benches); diff --git a/cspell.json b/cspell.json index 24cc0c7c4d..1179a10de9 100644 --- a/cspell.json +++ b/cspell.json @@ -33,6 +33,7 @@ "codeframe", "codegen", "Codepen", + "codspeed", "commitlint", "compat", "concurrentify", @@ -60,6 +61,7 @@ "execa", "fargs", "farmfe", + "fibo", "flac", "fnames", "Fock", @@ -76,6 +78,7 @@ "importee", "Inctive", "indicatif", + "instanceof", "Instantiator", "jfif", "JIDA", @@ -182,12 +185,7 @@ "wasmer", "wechat", "xlink", - "Yuxi", - "wasmer", - "primevue", - "shulan", - "globset", - "instanceof" + "Yuxi" ], "ignorePaths": [ "pnpm-lock.yaml", diff --git a/examples/arco-pro/farm.config.ts b/examples/arco-pro/farm.config.ts index c0e59e8a32..6f4b761603 100644 --- a/examples/arco-pro/farm.config.ts +++ b/examples/arco-pro/farm.config.ts @@ -3,7 +3,7 @@ import { defineConfig } from '@farmfe/core'; import farmJsPluginLess from '@farmfe/js-plugin-less'; import farmJsPluginSvgr from '@farmfe/js-plugin-svgr'; -export default defineConfig(async (env) => { +export default defineConfig((env) => { return { compilation: { input: { @@ -22,7 +22,7 @@ export default defineConfig(async (env) => { }, minify: false, mode: 'development', - persistentCache: false, + // persistentCache: false, output: { path: './build', filename: 'assets/[resourceName].[contentHash].[ext]', diff --git a/examples/react/farm.config.js b/examples/react/farm.config.js index cd0c68071c..09ae49b6f3 100644 --- a/examples/react/farm.config.js +++ b/examples/react/farm.config.js @@ -4,7 +4,7 @@ export default defineConfig(() => { return { compilation: { sourcemap: true, - persistentCache: false, + // persistentCache: false, presetEnv: false, progress: false // output: { diff --git a/package.json b/package.json index 4b845d7bfd..7b8170fc7a 100644 --- a/package.json +++ b/package.json @@ -23,12 +23,15 @@ "prepare": "husky" }, "devDependencies": { + "@farmfe/core": "workspace:*", + "@farmfe/cli": "workspace:*", "@biomejs/biome": "1.7.2", "@changesets/cli": "^2.26.0", + "@codspeed/vitest-plugin": "^3.1.1", "@commitlint/cli": "^17.0.3", "@commitlint/config-conventional": "^17.0.3", - "@types/node": "^18.0.1", - "@vitest/coverage-v8": "^0.33.0", + "@types/node": "20.14.12", + "@vitest/coverage-v8": "2.0.4", "cross-env": "^7.0.3", "cspell": "^6.2.2", "execa": "^7.1.1", @@ -40,7 +43,7 @@ "rollup": "^3.29.4", "typescript": "^4.9.4", "vite": "^5.2.6", - "vitest": "^1.4.0" + "vitest": "2.0.4" }, "lint-staged": { "packages/**/*.ts": [ diff --git a/packages/core/package.json b/packages/core/package.json index f3aac22a2d..9ee091f7f5 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -58,7 +58,7 @@ "build:cjs": "node scripts/build-cjs.mjs", "build": "tsc -p tsconfig.build.json && npm run build:cjs", "build:rs": "npm run build:rs:debug -- --release", - "build:rs:publish": "cross-env CARGO_PROFILE_RELEASE_LTO=fat CARGO_PROFILE_RELEASE_STRIP=symbols CARGO_PROFILE_RELEASE_PANIC=abort CARGO_PROFILE_RELEASE_OPT_LEVEL=s npm run build:rs:debug -- --release", + "build:rs:publish": "npm run build:rs:debug -- --release", "build:rs:debug": "napi build --platform --cargo-name farmfe_node -p farmfe_node --cargo-cwd ../../ binding --js binding.cjs --dts binding.d.ts", "build:rs:profile": "cross-env FARM_PROFILE=1 npm run build:rs -- --features profile", "prepublishOnly": "napi prepublish -t npm && FARM_PUBLISH=true npm run build:cjs", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index f1815ef651..3f7a08f913 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -19,18 +19,27 @@ importers: '@changesets/cli': specifier: ^2.26.0 version: 2.26.2 + '@codspeed/vitest-plugin': + specifier: ^3.1.1 + version: 3.1.1(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vitest@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) '@commitlint/cli': specifier: ^17.0.3 version: 17.8.1 '@commitlint/config-conventional': specifier: ^17.0.3 version: 17.8.1 + '@farmfe/cli': + specifier: workspace:* + version: link:packages/cli + '@farmfe/core': + specifier: workspace:* + version: link:packages/core '@types/node': - specifier: ^18.0.1 - version: 18.18.8 + specifier: 20.14.12 + version: 20.14.12 '@vitest/coverage-v8': - specifier: ^0.33.0 - version: 0.33.0(vitest@1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + specifier: 2.0.4 + version: 2.0.4(vitest@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) cross-env: specifier: ^7.0.3 version: 7.0.3 @@ -63,10 +72,16 @@ importers: version: 4.9.5 vite: specifier: ^5.2.6 - version: 5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + version: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vitest: - specifier: ^1.4.0 - version: 1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + specifier: 2.0.4 + version: 2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + + bench: + dependencies: + '@farmfe/core': + specifier: workspace:* + version: link:../packages/core examples/arco-pro: dependencies: @@ -649,7 +664,7 @@ importers: version: 5.1.3(@types/eslint@8.56.10)(eslint-config-prettier@9.1.0(eslint@8.57.0))(eslint@8.57.0)(prettier@3.3.2) farmup: specifier: latest - version: 0.0.12 + version: 0.1.0 jest: specifier: ^29.5.0 version: 29.7.0(@types/node@20.12.12)(babel-plugin-macros@3.1.0)(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)) @@ -776,7 +791,7 @@ importers: version: 6.0.0(postcss@8.4.31) tailwindcss: specifier: ^3.3.2 - version: 3.3.5(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)) + version: 3.3.5(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)) examples/public-dir: dependencies: @@ -1013,7 +1028,7 @@ importers: version: 0.14.0 vite-plugin-pages: specifier: ^0.32.0 - version: 0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) examples/react-sass-js: dependencies: @@ -1300,7 +1315,7 @@ importers: version: 0.5.3(solid-js@1.8.5) vite-plugin-solid: specifier: ^2.7.0 - version: 2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) examples/static-assets: dependencies: @@ -1362,7 +1377,7 @@ importers: version: 0.14.0 tailwindcss: specifier: ^3.3.2 - version: 3.3.5(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)) + version: 3.3.5(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)) examples/target-env: dependencies: @@ -1452,7 +1467,7 @@ importers: version: 1.15.3(babel-plugin-macros@3.1.0) '@vanilla-extract/vite-plugin': specifier: ^4.0.13 - version: 4.0.13(@types/node@20.12.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 4.0.13(@types/node@20.14.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) devDependencies: '@farmfe/cli': specifier: workspace:* @@ -1465,7 +1480,7 @@ importers: version: 5.4.5 vite: specifier: ^5.2.6 - version: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + version: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) examples/vite-adapter-react: dependencies: @@ -1508,7 +1523,7 @@ importers: version: 0.14.0 vite-plugin-pages: specifier: ^0.32.0 - version: 0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) examples/vite-adapter-solid: dependencies: @@ -1533,7 +1548,7 @@ importers: version: 5.2.2 vite-plugin-solid: specifier: ^2.7.0 - version: 2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) examples/vite-adapter-svelte: devDependencies: @@ -1545,7 +1560,7 @@ importers: version: link:../../packages/core '@sveltejs/vite-plugin-svelte': specifier: ^3.0.1 - version: 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) '@tsconfig/svelte': specifier: ^5.0.2 version: 5.0.2 @@ -1566,7 +1581,7 @@ importers: dependencies: vite-tsconfig-paths: specifier: ^4.3.1 - version: 4.3.1(typescript@5.4.5)(vite@5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + version: 4.3.1(typescript@5.4.5)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) devDependencies: '@farmfe/cli': specifier: workspace:* @@ -1643,10 +1658,10 @@ importers: version: 2.4.5 '@vitejs/plugin-vue': specifier: ^4.6.2 - version: 4.6.2(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) + version: 4.6.2(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) '@vitejs/plugin-vue-jsx': specifier: ^3.1.0 - version: 3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) + version: 3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) postcss: specifier: ^8.4.32 version: 8.4.32 @@ -1692,10 +1707,10 @@ importers: version: link:../../rust-plugins/sass '@vitejs/plugin-vue': specifier: ^5.0.4 - version: 5.0.4(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5)) + version: 5.0.4(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5)) '@vitejs/plugin-vue-jsx': specifier: ^3.1.0 - version: 3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5)) + version: 3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5)) prettier: specifier: ^3.2.5 version: 3.2.5 @@ -1714,7 +1729,7 @@ importers: version: link:../../packages/core '@vitejs/plugin-vue': specifier: ^5.0.3 - version: 5.0.3(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5)) + version: 5.0.3(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5)) core-js: specifier: ^3.35.1 version: 3.35.1 @@ -1723,10 +1738,10 @@ importers: dependencies: tdesign-icons-vue: specifier: latest - version: 0.2.2(vue@2.6.14) + version: 0.2.4(vue@2.6.14) tdesign-vue: specifier: latest - version: 1.9.3(vue@2.6.14) + version: 1.9.8(vue@2.6.14) vite-plugin-vue2-svg: specifier: ^0.4.0 version: 0.4.0(ejs@3.1.10)(lodash@4.17.21)(vue-template-compiler@2.6.14(vue@2.6.14)) @@ -1748,7 +1763,7 @@ importers: version: 3.36.1 vite-plugin-vue2: specifier: ^2.0.3 - version: 2.0.3(ejs@3.1.10)(lodash@4.17.21)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue-template-compiler@2.6.14(vue@2.6.14))(vue@2.6.14) + version: 2.0.3(ejs@3.1.10)(lodash@4.17.21)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue-template-compiler@2.6.14(vue@2.6.14))(vue@2.6.14) vue-template-compiler: specifier: 2.6.14 version: 2.6.14(vue@2.6.14) @@ -1757,10 +1772,10 @@ importers: dependencies: tdesign-icons-vue: specifier: latest - version: 0.2.2(vue@2.7.16) + version: 0.2.4(vue@2.7.16) tdesign-vue: specifier: latest - version: 1.9.3(vue@2.7.16) + version: 1.9.8(vue@2.7.16) vite-plugin-vue2-svg: specifier: ^0.4.0 version: 0.4.0(ejs@3.1.10)(lodash@4.17.21)(vue-template-compiler@2.7.16(vue@2.7.16)) @@ -1776,7 +1791,7 @@ importers: version: link:../../packages/core '@vitejs/plugin-vue2': specifier: ^2.3.1 - version: 2.3.1(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@2.7.16) + version: 2.3.1(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@2.7.16) core-js: specifier: ^3.30.1 version: 3.36.1 @@ -1850,7 +1865,7 @@ importers: version: link:../../js-plugins/less '@vitejs/plugin-vue': specifier: ^5.0.4 - version: 5.0.4(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) + version: 5.0.4(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) xlsx-js-style: specifier: ^1.2.0 version: 1.2.0 @@ -1869,10 +1884,10 @@ importers: version: link:../../packages/core '@vitejs/plugin-vue': specifier: ^5.0.4 - version: 5.0.4(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) + version: 5.0.4(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) '@vitejs/plugin-vue-jsx': specifier: ^3.1.0 - version: 3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) + version: 3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5)) examples/vue-ssr: dependencies: @@ -1903,7 +1918,7 @@ importers: version: link:../../packages/core '@vitejs/plugin-vue': specifier: ^4.4.0 - version: 4.4.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.12(typescript@5.4.5)) + version: 4.4.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.12(typescript@5.4.5)) examples/x-data-spreadsheet: dependencies: @@ -2019,7 +2034,7 @@ importers: version: 16.0.1(postcss@8.4.31) postcss-load-config: specifier: ^4.0.1 - version: 4.0.1(postcss@8.4.31)(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)) + version: 4.0.1(postcss@8.4.31)(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)) postcss-url: specifier: ^10.1.3 version: 10.1.3(postcss@8.4.31) @@ -2169,7 +2184,7 @@ importers: version: 2.13.10 '@vitejs/plugin-vue': specifier: ^4.4.0 - version: 4.6.2(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5)) + version: 4.6.2(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5)) autoprefixer: specifier: ^10.4.14 version: 10.4.16(postcss@8.4.35) @@ -2181,7 +2196,7 @@ importers: version: 8.4.35 tailwindcss: specifier: ^3.3.2 - version: 3.3.5(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)) + version: 3.3.5(ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5)) js-plugins/vue: devDependencies: @@ -2504,6 +2519,10 @@ packages: resolution: {integrity: sha512-lFMjJTrFL3j7L9yBxwYfCq2k6qqwHyzuUl/XBnif78PWTJYyL/dfowQHWE3sp6U6ZzqWiiIZnpTMO96zhkjwtg==} engines: {node: '>=6.0.0'} + '@ampproject/remapping@2.3.0': + resolution: {integrity: sha512-30iZtAPgz+LTIYoeivqYo853f02jBYSd5uGnGpkFV0M3xOt9aN73erkgYAmZU43x4VfqcnLxW9Kpg3R5LC4YYw==} + engines: {node: '>=6.0.0'} + '@angular-devkit/core@17.3.8': resolution: {integrity: sha512-Q8q0voCGudbdCgJ7lXdnyaxKHbNQBARH68zPQV72WT8NWy+Gw/tys870i6L58NWbBaCJEUcIj/kb6KoakSRu+Q==} engines: {node: ^18.13.0 || >=20.9.0, npm: ^6.11.0 || ^7.5.6 || >=8.0.0, yarn: '>= 1.13.0'} @@ -3194,6 +3213,15 @@ packages: bundledDependencies: - is-unicode-supported + '@codspeed/core@3.1.1': + resolution: {integrity: sha512-ONhERVDAtkm0nc+FYPivDozoMOlNUP2BWRBFDJYATGA18Iap5Kd2mZ1/Lwz54RB5+g+3YDOpsvotHa4hd3Q+7Q==} + + '@codspeed/vitest-plugin@3.1.1': + resolution: {integrity: sha512-/PJUgxIfuRqpBSbaD8bgWXtbXxCqgnW89dzr3220fMkx/LA6z6oUb4tJGjeVsOWAzAgu0VBdSA+8hC+7D9BIuQ==} + peerDependencies: + vite: ^4.2.0 || ^5.0.0 + vitest: '>=1.2.2' + '@colors/colors@1.5.0': resolution: {integrity: sha512-ooWCrlZP11i8GImSjTHYHLkvFDP48nS4+204nGb1RiX/WXYHmJA2III9/e2DWVabCESdW7hBAEzHRqUn9OUVvQ==} engines: {node: '>=0.1.90'} @@ -5018,6 +5046,9 @@ packages: '@types/node@20.12.12': resolution: {integrity: sha512-eWLDGF/FOSPtAvEqeRAQ4C8LSA7M1I7i0ky1I8U7kD1J5ITyW3AsRhQrKVoWf5pFKZ2kILsEGJhsI9r93PYnOw==} + '@types/node@20.14.12': + resolution: {integrity: sha512-r7wNXakLeSsGT0H1AU863vS2wa5wBOK4bWMjZz2wj+8nBx+m5PeIn0k8AloSLpRuiwdRQZwarZqHE4FNArPuJQ==} + '@types/node@20.5.1': resolution: {integrity: sha512-4tT2UrL5LBqDwoed9wZ6N3umC4Yhz3W3FloMmiiG4JwmUJWpie0c7lcnUNd4gtMKuDEO4wRVS8B6Xa0uMRsMKg==} @@ -5255,25 +5286,28 @@ packages: vite: ^5.0.0 vue: ^3.2.25 - '@vitest/coverage-v8@0.33.0': - resolution: {integrity: sha512-Rj5IzoLF7FLj6yR7TmqsfRDSeaFki6NAJ/cQexqhbWkHEV2htlVGrmuOde3xzvFsCbLCagf4omhcIaVmfU8Okg==} + '@vitest/coverage-v8@2.0.4': + resolution: {integrity: sha512-i4lx/Wpg5zF1h2op7j0wdwuEQxaL/YTwwQaKuKMHYj7MMh8c7I4W7PNfOptZBCSBZI0z1qwn64o0pM/pA8Tz1g==} peerDependencies: - vitest: '>=0.32.0 <1' + vitest: 2.0.4 + + '@vitest/expect@2.0.4': + resolution: {integrity: sha512-39jr5EguIoanChvBqe34I8m1hJFI4+jxvdOpD7gslZrVQBKhh8H9eD7J/LJX4zakrw23W+dITQTDqdt43xVcJw==} - '@vitest/expect@1.4.0': - resolution: {integrity: sha512-Jths0sWCJZ8BxjKe+p+eKsoqev1/T8lYcrjavEaz8auEJ4jAVY0GwW3JKmdVU4mmNPLPHixh4GNXP7GFtAiDHA==} + '@vitest/pretty-format@2.0.4': + resolution: {integrity: sha512-RYZl31STbNGqf4l2eQM1nvKPXE0NhC6Eq0suTTePc4mtMQ1Fn8qZmjV4emZdEdG2NOWGKSCrHZjmTqDCDoeFBw==} - '@vitest/runner@1.4.0': - resolution: {integrity: sha512-EDYVSmesqlQ4RD2VvWo3hQgTJ7ZrFQ2VSJdfiJiArkCerDAGeyF1i6dHkmySqk573jLp6d/cfqCN+7wUB5tLgg==} + '@vitest/runner@2.0.4': + resolution: {integrity: sha512-Gk+9Su/2H2zNfNdeJR124gZckd5st4YoSuhF1Rebi37qTXKnqYyFCd9KP4vl2cQHbtuVKjfEKrNJxHHCW8thbQ==} - '@vitest/snapshot@1.4.0': - resolution: {integrity: sha512-saAFnt5pPIA5qDGxOHxJ/XxhMFKkUSBJmVt5VgDsAqPTX6JP326r5C/c9UuCMPoXNzuudTPsYDZCoJ5ilpqG2A==} + '@vitest/snapshot@2.0.4': + resolution: {integrity: sha512-or6Mzoz/pD7xTvuJMFYEtso1vJo1S5u6zBTinfl+7smGUhqybn6VjzCDMhmTyVOFWwkCMuNjmNNxnyXPgKDoPw==} - '@vitest/spy@1.4.0': - resolution: {integrity: sha512-Ywau/Qs1DzM/8Uc+yA77CwSegizMlcgTJuYGAi0jujOteJOUf1ujunHThYo243KG9nAyWT3L9ifPYZ5+As/+6Q==} + '@vitest/spy@2.0.4': + resolution: {integrity: sha512-uTXU56TNoYrTohb+6CseP8IqNwlNdtPwEO0AWl+5j7NelS6x0xZZtP0bDWaLvOfUbaYwhhWp1guzXUxkC7mW7Q==} - '@vitest/utils@1.4.0': - resolution: {integrity: sha512-mx3Yd1/6e2Vt/PUC98DcqTirtfxUyAZ32uK82r8rZzbtBeBo+nqgnjx/LvqQdWsrvNtm14VmurNgcf4nqY5gJg==} + '@vitest/utils@2.0.4': + resolution: {integrity: sha512-Zc75QuuoJhOBnlo99ZVUkJIuq4Oj0zAkrQ2VzCqNCx6wAwViHEh5Fnp4fiJTE9rA+sAoXRf00Z9xGgfEzV6fzQ==} '@vue-macros/common@1.10.0': resolution: {integrity: sha512-4DZsPeQA/nBQDw2RkYAmH7KrFjJVrMdAhJhO1JCl1bbbFXCGeoGjXfkg9wHPppj47s2HpAB3GrqNwqVGbi12NQ==} @@ -5837,8 +5871,9 @@ packages: resolution: {integrity: sha512-NfJ4UzBCcQGLDlQq7nHxH+tv3kyZ0hHQqF5BO6J7tNJeP5do1llPr8dZ8zHonfhAu0PHAdMkSo+8o0wxg9lZWw==} engines: {node: '>=0.8'} - assertion-error@1.1.0: - resolution: {integrity: sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==} + assertion-error@2.0.1: + resolution: {integrity: sha512-Izi8RQcffqCeNVgFigKli1ssklIbpHnCYc6AknXGYoB6grJqyeby7jv12JUQgmTAnIDnbck1uxksT4dzN3PWBA==} + engines: {node: '>=12'} assign-symbols@1.0.0: resolution: {integrity: sha512-Q+JC7Whu8HhmTdBph/Tq59IoRtoy6KAm5zzPv00WdujX82lbAL8K7WVjne7vdCsAmbF4AYaDOPyO3k0kl8qIrw==} @@ -6211,9 +6246,9 @@ packages: resolution: {integrity: sha512-KfdUZsSOw19/ObEWasvBP/Ac4reZvAGauZhs6S/gqNhXhI7cKwvlH7ulj+dOEYnca4bm4SGo8C1bTAQvnTjgQA==} engines: {node: '>=0.8'} - chai@4.3.10: - resolution: {integrity: sha512-0UXG04VuVbruMUYbJ6JctvH0YnC/4q3/AkT18q4NaITo91CUm0liMS9VqzT9vZhVQ/1eqPanMWjBM+Juhfb/9g==} - engines: {node: '>=4'} + chai@5.1.1: + resolution: {integrity: sha512-pT1ZgP8rPNqUgieVaEY+ryQr6Q4HXNg8Ei9UnLUrjN4IA7dvQC5JB+/kxVcPNDHyBcc/26CXPkbNzq3qwrOEKA==} + engines: {node: '>=12'} chalk-template@0.4.0: resolution: {integrity: sha512-/ghrgmhfY8RaSdeo43hNXxpoHAtxdbskUHjPpfqUWGttFgycUhYPGx3YZBCnUCvOa7Doivn1IZec3DEGFoMgLg==} @@ -6249,8 +6284,9 @@ packages: chardet@0.7.0: resolution: {integrity: sha512-mT8iDcrh03qDGRRmoA2hmBJnxpllMR+0/0qlzjqZES6NdiWDcZkCNAk4rPFZ9Q85r27unkiNNg8ZOiwZXBHwcA==} - check-error@1.0.3: - resolution: {integrity: sha512-iKEoDYaRmd1mxM90a2OEfWhjsjPpYPuQ+lMYsoxB126+t8fw7ySEO48nmDg5COTjxDI65/Y2OWpeEHk3ZOe8zg==} + check-error@2.1.1: + resolution: {integrity: sha512-OAlb+T7V4Op9OwdkjmguYRqncdlx5JiofwOAUkmTF+jNdHwzTaTs4sRAGpzLF3oOz5xAyDGrPgeIDFQmDOTiJw==} + engines: {node: '>= 16'} chokidar@3.5.3: resolution: {integrity: sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==} @@ -7233,6 +7269,15 @@ packages: supports-color: optional: true + debug@4.3.5: + resolution: {integrity: sha512-pt0bNEmneDIvdL1Xsd9oDQ/wrQRkXDT4AUWlNZNPKvW5x/jyO9VFXkJUP07vQ2upmw5PlaITaPKc31jK13V+jg==} + engines: {node: '>=6.0'} + peerDependencies: + supports-color: '*' + peerDependenciesMeta: + supports-color: + optional: true + decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} engines: {node: '>=0.10.0'} @@ -7257,8 +7302,8 @@ packages: babel-plugin-macros: optional: true - deep-eql@4.1.3: - resolution: {integrity: sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==} + deep-eql@5.0.2: + resolution: {integrity: sha512-h5k/5U50IJJFpzfL6nO9jaaumfjO/f2NjK/oYB2Djzm4p9L+3T9qWpZqZ2hAbLPuuYq9wrU08WQyBTL5GbPk5Q==} engines: {node: '>=6'} deep-equal@1.0.1: @@ -7972,8 +8017,8 @@ packages: farm-plugin-replace-dirname@0.2.1: resolution: {integrity: sha512-aJ4euQzxoq0sVu4AwXrNQflHJrSZdrdApGEyVRtN6KiCop3CHXnTg9ydlyCNXN2unQB283aNjojvCd5E/32KgA==} - farmup@0.0.12: - resolution: {integrity: sha512-B8RMixABXp/ILgadg2wQ1BAXwcdOqKdF1K4aq6rYur+7MsrRRlj6g/Wvifil0Xs1zvAUKBGEdCGIcu9TL29Brg==} + farmup@0.1.0: + resolution: {integrity: sha512-+xQuuQFGmHZsy9p/vDDwKOepdD7id4/THKorHmzvX3AeescqFQGJenksyhZab3cMJMYSqfJ8vbr1RkLIKgs7mg==} hasBin: true fast-deep-equal@3.1.3: @@ -8085,6 +8130,10 @@ packages: resolution: {integrity: sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==} engines: {node: '>=10'} + find-up@6.3.0: + resolution: {integrity: sha512-v2ZsoEuVHYy8ZIlYqwPe/39Cy+cFDzp4dXPaxNvkEuouymu+2Jbz0PxpKarJHYJTmv2HWT3O382qY8l4jMWthw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + find-yarn-workspace-root2@1.2.16: resolution: {integrity: sha512-hr6hb1w8ePMpPVUK39S4RlwJzi+xPLuVuG8XlwXU3KD5Yn3qgBWVfy3AzNlDhWvE1EORCE65/Qm26rFQt3VLVA==} @@ -8342,6 +8391,7 @@ packages: glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + deprecated: Glob versions prior to v9 are no longer supported glob@8.1.0: resolution: {integrity: sha512-r8hpEjiQEYlF2QU0df3dS+nxxSIreXQS1qRhMJM0Q5NDdR386C7jb7Hwwod8Fgiuex+k0GFjgft18yvxm5XoCQ==} @@ -8982,6 +9032,10 @@ packages: resolution: {integrity: sha512-eOeJ5BHCmHYvQK7xt9GkdHuzuCGS1Y6g9Gvnx3Ym33fz/HpLRYxiS0wHNr+m/MBC8B647Xt608vCDEvhl9c6Mw==} engines: {node: '>=8'} + istanbul-lib-coverage@3.2.2: + resolution: {integrity: sha512-O8dpsF+r0WV/8MNRKfnmrtCWhuKjxrq2w+jpzBL5UZKTi2LeVWnWOmWRxFlesJONmc+wLAGvKQZEOanko0LFTg==} + engines: {node: '>=8'} + istanbul-lib-instrument@5.2.1: resolution: {integrity: sha512-pzqtp31nLv/XFOzXGuvhCb8qhjmTVo5vjVk19XE4CRlSWz0KoeJ3bw9XsA7nOp9YBf4qHjwBxkDzKcME/J29Yg==} engines: {node: '>=8'} @@ -8998,10 +9052,18 @@ packages: resolution: {integrity: sha512-n3s8EwkdFIJCG3BPKBYvskgXGoy88ARzvegkitk60NxRdwltLOTaH7CUiMRXvwYorl0Q712iEjcWB+fK/MrWVw==} engines: {node: '>=10'} + istanbul-lib-source-maps@5.0.6: + resolution: {integrity: sha512-yg2d+Em4KizZC5niWhQaIomgf5WlL4vOOjZ5xGCmF8SnPE/mDWWXgvRExdcpCgh9lLRRa1/fSYp2ymmbJ1pI+A==} + engines: {node: '>=10'} + istanbul-reports@3.1.6: resolution: {integrity: sha512-TLgnMkKg3iTDsQ9PbPTdpfAK2DzjF9mqUG7RMgcQl8oFjad8ob4laGxv5XV5U9MAfx8D6tSJiUyuAwzLicaxlg==} engines: {node: '>=8'} + istanbul-reports@3.1.7: + resolution: {integrity: sha512-BewmUXImeuRk2YY0PVbxgKAysvhRPUQE0h5QRM++nVWyubKGV0l8qQ5op8+B2DOmwSe63Jivj0BjkPQVf8fP5g==} + engines: {node: '>=8'} + iterare@1.2.1: resolution: {integrity: sha512-RKYVTCjAnRthyJes037NX/IiqeidgN1xc3j1RjFfECFp28A1GVwK9nA+i0rJPaHqSZwygLzRnFlzUuHFoWWy+Q==} engines: {node: '>=6'} @@ -9164,9 +9226,6 @@ packages: js-tokens@4.0.0: resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==} - js-tokens@8.0.3: - resolution: {integrity: sha512-UfJMcSJc+SEXEl9lH/VLHSZbThQyLpw1vLO1Lb+j4RWDvG3N2f7yj3PVQA3cmkTBNldJ9eFnM+xEXxHIXrYiJw==} - js-yaml@3.14.1: resolution: {integrity: sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==} hasBin: true @@ -9448,6 +9507,10 @@ packages: resolution: {integrity: sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==} engines: {node: '>=10'} + locate-path@7.2.0: + resolution: {integrity: sha512-gvVijfZvn7R+2qyPX8mAuKcFGDf6Nc61GdvGafQsHL0sBIxfKzA+usWn4GFC/bk+QdwPUD4kWFJLhElipq+0VA==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + lodash-es@4.17.21: resolution: {integrity: sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==} @@ -9523,8 +9586,8 @@ packages: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true - loupe@2.3.7: - resolution: {integrity: sha512-zSMINGVYkdpYSOBmLi0D1Uo7JU9nVdQKrHxC8eYlV+9YKK9WePqAlL7lSlorG/U2Fw1w0hTBmaa/jrQ3UbPHtA==} + loupe@3.1.1: + resolution: {integrity: sha512-edNu/8D5MKVfGVFRhFf8aAxiTM6Wumfz5XsaatSxlD3w4R1d/WEKUTydCdPGbl9K7QG/Ca3GnDV2sIKIpXRQcw==} lower-case@2.0.2: resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} @@ -9570,6 +9633,9 @@ packages: resolution: {integrity: sha512-ISQTe55T2ao7XtlAStud6qwYPZjE4GK1S/BeVPus4jrq6JuOnQ00YKQC581RWhR122W7msZV263KzVeLoqidyQ==} engines: {node: '>=12'} + magicast@0.3.4: + resolution: {integrity: sha512-TyDF/Pn36bBji9rWKHlZe+PZb6Mx5V8IHCSxk7X4aljM4e/vyDvZZYwHewdVaqiA0nb3ghfHU/6AUpDxWoER2Q==} + make-dir@2.1.0: resolution: {integrity: sha512-LS9X+dc8KLxXCb8dni79fLIIUA5VyZoyjSMCwTluaXA0o27cCK0bhXkpgw+sTXVpPy/lSO57ilRixqk0vDmtRA==} engines: {node: '>=6'} @@ -10176,9 +10242,9 @@ packages: resolution: {integrity: sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==} engines: {node: '>=10'} - p-limit@5.0.0: - resolution: {integrity: sha512-/Eaoq+QyLSiXQ4lyYV23f14mZRQcXnxfHrN0vCai+ak9G0pp9iEQukIIZq5NccEvwRB8PUnZT0KsOoDCINS1qQ==} - engines: {node: '>=18'} + p-limit@4.0.0: + resolution: {integrity: sha512-5b0R4txpzjPWVw/cXXUResoD4hb6U/x9BH08L7nw+GN1sezDzPdxeRvpc9c433fZhBan/wusjbCsqwqm4EIBIQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} p-locate@2.0.0: resolution: {integrity: sha512-nQja7m7gSKuewoVRen45CtVfODR3crN3goVQ0DDZ9N3yHxgpkuBhZqsaiotSQRrADUrne346peY7kT3TSACykg==} @@ -10192,6 +10258,10 @@ packages: resolution: {integrity: sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==} engines: {node: '>=10'} + p-locate@6.0.0: + resolution: {integrity: sha512-wPrq66Llhl7/4AGC6I+cqxT07LhXvWL08LNXz1fENOw0Ap4sRZZ/gZpTTJ5jpurzzzfS2W/Ge9BY3LgLjCShcw==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + p-map@2.1.0: resolution: {integrity: sha512-y3b8Kpd8OAN444hxfBbFfj1FY/RjtTd8tzYwhUqNYXx0fXx2iX4maP4Qr6qhIKbQXI02wTLAda4fYUbDagTUFw==} engines: {node: '>=6'} @@ -10268,6 +10338,10 @@ packages: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} + path-exists@5.0.0: + resolution: {integrity: sha512-RjhtfwJOxzcFmNOi6ltcbcu4Iu+FL3zEj83dk4kAS+fVpTxXLO1b38RvJgT/0QwvV/L3aY9TAnyv0EOqW4GoMQ==} + engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} + path-is-absolute@1.0.1: resolution: {integrity: sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==} engines: {node: '>=0.10.0'} @@ -10317,8 +10391,12 @@ packages: pathe@1.1.1: resolution: {integrity: sha512-d+RQGp0MAYTIaDBIMmOfMwz3E+LOZnxx1HZd5R18mmCZY0QBlK0LDZfPc8FW8Ed2DlvsuE6PRjroDY+wg4+j/Q==} - pathval@1.1.1: - resolution: {integrity: sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==} + pathe@1.1.2: + resolution: {integrity: sha512-whLdWMYL2TwI08hn8/ZqAbrVemu0LNaNNJZX73O6qaIdCTfXutsLhMkjdENX0qhsQ9uIimo4/aQOmXkoon2nDQ==} + + pathval@2.0.0: + resolution: {integrity: sha512-vE7JKRyES09KiunauX7nd2Q9/L7lhok4smP9RZTDeD4MVs72Dp2qNFVz39Nz5a0FVEW0BJR6C0DYrq6unoziZA==} + engines: {node: '>= 14.16'} pdfast@0.2.0: resolution: {integrity: sha512-cq6TTu6qKSFUHwEahi68k/kqN2mfepjkGrG9Un70cgdRRKLKY6Rf8P8uvP2NvZktaQZNF3YE7agEkLj0vGK9bA==} @@ -11314,14 +11392,17 @@ packages: rimraf@2.6.3: resolution: {integrity: sha512-mwqeW5XsA2qAejG46gYdENaxXjx9onRNCfn7L0duuP4hCuTIi/QO7PDK07KJfp1d+izWPrzEJDcSqBa0OZQriA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true rimraf@2.7.1: resolution: {integrity: sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true rimraf@3.0.2: resolution: {integrity: sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==} + deprecated: Rimraf versions prior to v4 are no longer supported hasBin: true roarr@2.15.4: @@ -11911,9 +11992,6 @@ packages: resolution: {integrity: sha512-RwNA9Z/7PrK06rYLIzFMlaF+l73iwpzsqRIFgbMLbTcLD6cOao82TaWefPXQvB2fOC4AjuYSEndS7N/mTCbkdQ==} engines: {node: '>= 0.8'} - std-env@3.4.3: - resolution: {integrity: sha512-f9aPhy8fYBuMN+sNfakZV18U39PbalgjXG3lLB9WkaYTxijru61wb57V9wxxNthXM5Sd88ETBWi29qLAsHO52Q==} - std-env@3.7.0: resolution: {integrity: sha512-JPbdCEQLj1w5GilpiHAx3qJvFndqybBysA3qUOnznweH4QbNYUsW/ea8QzSrnh0vNsezMMw5bcVool8lM0gwzg==} @@ -12026,9 +12104,6 @@ packages: strip-literal@1.3.0: resolution: {integrity: sha512-PugKzOsyXpArk0yWmUwqOZecSO0GH0bPoctLcqNDH9J04pVW3lflYE0ujElBGTloevcxF5MofAOZ7C5l2b+wLg==} - strip-literal@2.0.0: - resolution: {integrity: sha512-f9vHgsCWBq2ugHAkGMiiYY+AYG0D/cbloKKg0nhaaaSNsujdGIpVXCNsrJpCKr5M0f4aI31mr13UjY6GAuXCKA==} - strip-outer@1.0.1: resolution: {integrity: sha512-k55yxKHwaXnpYGsOzg4Vl8+tDrWylxDEpknGjhTiZB8dFRU5rTo9CAzeycivxV3s+zlTKwrs6WxMxR95n26kwg==} engines: {node: '>=0.10.0'} @@ -12176,13 +12251,13 @@ packages: resolution: {integrity: sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==} engines: {node: '>=10'} - tdesign-icons-vue@0.2.2: - resolution: {integrity: sha512-aAHrd5K2O9pQSUZb09A58qIH9b6fOP9pUapvxzvByuc5Ri3YLLgoz+6/XZcRu5S8insx7OzfhH951qjKxfzLtg==} + tdesign-icons-vue@0.2.4: + resolution: {integrity: sha512-rgBVBW/Tes+ZFXtmkN0crmQuIszLeL+MqkmDme41dxwObxjFQ+SBkPWn8m+IUrTZ9CX/uNGjFG+QTaC8qcm90g==} peerDependencies: vue: ^2.6.12 - tdesign-vue@1.9.3: - resolution: {integrity: sha512-PoKSvQsrL3kiu8+geSFWamu7m2TubeU7/MtsRxLkqOwQJK/LDIsKtLLrxi5fBKOEZpN5NOGPz9Q1YXJQpd241Q==} + tdesign-vue@1.9.8: + resolution: {integrity: sha512-8kdsbb/AChhpvopfMs9lAK9Uxy8jvxu+ZQk35MjRFuQlZ5PW2CdfctEnsnz7yUGlFBGOJB4+08KxhPi6xDkH6A==} peerDependencies: vue: ~2.6.10 @@ -12222,6 +12297,10 @@ packages: resolution: {integrity: sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==} engines: {node: '>=8'} + test-exclude@7.0.1: + resolution: {integrity: sha512-pFYqmTw68LXVjeWJMST4+borgQP2AyMNbg1BpZh9LbyhUeNkeaPF9gzfPGUAnSMV3qPYdWUwDIjjCLiSDOl7vg==} + engines: {node: '>=18'} + text-extensions@1.9.0: resolution: {integrity: sha512-wiBrwC1EhBelW12Zy26JeOUkQ5mRu+5o8rpsJk5+2t+Y5vE7e842qtZDQ2g1NpX/29HdyFeJ4nSIhI47ENSxlQ==} engines: {node: '>=0.10'} @@ -12258,8 +12337,8 @@ packages: tiny-warning@1.0.3: resolution: {integrity: sha512-lBN9zLN/oAf68o3zNXYrdCt1kP8WsiGW8Oo2ka41b2IM5JL/S1CTyX1rW0mb/zSuJun0ZUrDxx4sqvYS2FWzPA==} - tinybench@2.5.1: - resolution: {integrity: sha512-65NKvSuAVDP/n4CqH+a9w2kTlLReS9vhsAP06MWx+/89nMinJyB2icyl58RIcqCmIggpojIGeuJGhjU1aGMBSg==} + tinybench@2.8.0: + resolution: {integrity: sha512-1/eK7zUnIklz4JUUlL+658n58XO2hHLQfSk1Zf2LKieUjxidN16eKFEoDEfjHc3ohofSSqK3X5yO6VGb6iW8Lw==} tinycolor2@1.6.0: resolution: {integrity: sha512-XPaBkWQJdsf3pLKJV9p4qN/S+fm2Oj8AIPo1BTUhg5oxkvm9+SVEGFdhyOz7tTdUTfvxMiAs4sp6/eZO2Ew+pw==} @@ -12267,15 +12346,19 @@ packages: tinygradient@1.1.5: resolution: {integrity: sha512-8nIfc2vgQ4TeLnk2lFj4tRLvvJwEfQuabdsmvDdQPT0xlk9TaNtpGd6nNRxXoK6vQhN6RSzj+Cnp5tTQmpxmbw==} - tinypool@0.8.2: - resolution: {integrity: sha512-SUszKYe5wgsxnNOVlBYO6IC+8VGWdVGZWAqUxp3UErNBtptZvWbwyUOyzNL59zigz2rCA92QiL3wvG+JDSdJdQ==} - engines: {node: '>=14.0.0'} + tinypool@1.0.0: + resolution: {integrity: sha512-KIKExllK7jp3uvrNtvRBYBWBOAXSX8ZvoaD8T+7KB/QHIuoJW3Pmr60zucywjAlMb5TeXUkcs/MWeWLu0qvuAQ==} + engines: {node: ^18.0.0 || >=20.0.0} tinyqueue@2.0.3: resolution: {integrity: sha512-ppJZNDuKGgxzkHihX8v9v9G5f+18gzaTfrukGrq6ueg0lmH4nqVnA2IPG0AEH3jKEk2GRJCUhDoqpoiw3PHLBA==} - tinyspy@2.2.0: - resolution: {integrity: sha512-d2eda04AN/cPOR89F7Xv5bK/jrQEhmcLFe6HFldoeO9AJtps+fqEnh486vnT/8y4bw38pSyxDcTCAq+Ks2aJTg==} + tinyrainbow@1.2.0: + resolution: {integrity: sha512-weEDEq7Z5eTHPDh4xjX789+fHfF+P8boiFB+0vbWzpbnbsEr/GRaohi/uMKxg8RZMXnl1ItAi/IUHWMsjDV7kQ==} + engines: {node: '>=14.0.0'} + + tinyspy@3.0.0: + resolution: {integrity: sha512-q5nmENpTHgiPVd1cJDDc9cVoYN5x4vCvwT3FMilvKPKneCBZAxn2YWQjDF0UMcE9k0Cay1gBiDfTMU0g+mPMQA==} engines: {node: '>=14.0.0'} titleize@3.0.0: @@ -12781,6 +12864,11 @@ packages: engines: {node: ^18.0.0 || >=20.0.0} hasBin: true + vite-node@2.0.4: + resolution: {integrity: sha512-ZpJVkxcakYtig5iakNeL7N3trufe3M6vGuzYAr4GsbCTwobDeyPJpE4cjDhhPluv8OvQCFzu2LWp6GkoKRITXA==} + engines: {node: ^18.0.0 || >=20.0.0} + hasBin: true + vite-plugin-pages@0.32.0: resolution: {integrity: sha512-OxS3n0zUo5wsfgNCAuw2FiG/KD1ipgQV+2Flst4RyeI2iPv+m0YueVq+nx41k5NOWJj/zhqEas6I0b7HXveXjA==} peerDependencies: @@ -12856,15 +12944,15 @@ packages: vite: optional: true - vitest@1.4.0: - resolution: {integrity: sha512-gujzn0g7fmwf83/WzrDTnncZt2UiXP41mHuFYFrdwaLRVQ6JYQEiME2IfEjU3vcFL3VKa75XhI3lFgn+hfVsQw==} + vitest@2.0.4: + resolution: {integrity: sha512-luNLDpfsnxw5QSW4bISPe6tkxVvv5wn2BBs/PuDRkhXZ319doZyLOBr1sjfB5yCEpTiU7xCAdViM8TNVGPwoog==} engines: {node: ^18.0.0 || >=20.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@types/node': ^18.0.0 || >=20.0.0 - '@vitest/browser': 1.4.0 - '@vitest/ui': 1.4.0 + '@vitest/browser': 2.0.4 + '@vitest/ui': 2.0.4 happy-dom: '*' jsdom: '*' peerDependenciesMeta: @@ -12887,19 +12975,8 @@ packages: vscode-uri@3.0.8: resolution: {integrity: sha512-AyFQ0EVmsOZOlAnxoFOGOq1SQDWAB7C6aqMGS23svWAllfOaxbuFvcT8D1i8z3Gyn8fraVeZNNmN6e9bxxXkKw==} - vue-demi@0.14.7: - resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} - engines: {node: '>=12'} - hasBin: true - peerDependencies: - '@vue/composition-api': ^1.0.0-rc.1 - vue: ^3.0.0-0 || ^2.6.0 - peerDependenciesMeta: - '@vue/composition-api': - optional: true - - vue-demi@0.14.8: - resolution: {integrity: sha512-Uuqnk9YE9SsWeReYqK2alDI5YzciATE0r2SkA6iMAtuXvNTMNACJLJEXNXaEy94ECuBe4Sk6RzRU80kjdbIo1Q==} + vue-demi@0.14.10: + resolution: {integrity: sha512-nMZBOwuzabUO0nLgIcc6rycZEebF6eeUfaiQx9+WSk8e29IbLvPU9feI6tqW4kTo3hvoYAJkMh8n8D0fuISphg==} engines: {node: '>=12'} hasBin: true peerDependencies: @@ -12909,8 +12986,8 @@ packages: '@vue/composition-api': optional: true - vue-demi@0.14.9: - resolution: {integrity: sha512-dC1TJMODGM8lxhP6wLToncaDPPNB3biVxxRDuNCYpuXwi70ou7NsGd97KVTJ2omepGId429JZt8oaZKeXbqxwg==} + vue-demi@0.14.7: + resolution: {integrity: sha512-EOG8KXDQNwkJILkx/gPcoL/7vH+hORoBaKgGe+6W7VFMvCYJfmF2dGbvgDroVnI8LU7/kTu8mbjRZGBU1z9NTA==} engines: {node: '>=12'} hasBin: true peerDependencies: @@ -13072,8 +13149,8 @@ packages: engines: {node: '>= 8'} hasBin: true - why-is-node-running@2.2.2: - resolution: {integrity: sha512-6tSwToZxTOcotxHeA+qGCq1mVzKR3CwcJGmVcY+QE8SHy6TnpFnh8PAvPNHYr7EcuVeG0QSMxtYCuO1ta/G/oA==} + why-is-node-running@2.3.0: + resolution: {integrity: sha512-hUrmaWBdVDcxvYqnyh09zunKzROWjbZTiNy8dBEjkS7ehEDQibXJ7XvlmtbwuTclUiIyN+CyXQD4Vmko8fNm8w==} engines: {node: '>=8'} hasBin: true @@ -13268,6 +13345,11 @@ snapshots: '@jridgewell/gen-mapping': 0.3.5 '@jridgewell/trace-mapping': 0.3.25 + '@ampproject/remapping@2.3.0': + dependencies: + '@jridgewell/gen-mapping': 0.3.5 + '@jridgewell/trace-mapping': 0.3.25 + '@angular-devkit/core@17.3.8(chokidar@3.6.0)': dependencies: ajv: 8.12.0 @@ -14419,6 +14501,23 @@ snapshots: picocolors: 1.0.0 sisteransi: 1.0.5 + '@codspeed/core@3.1.1': + dependencies: + axios: 1.7.2 + find-up: 6.3.0 + form-data: 4.0.0 + node-gyp-build: 4.7.1 + transitivePeerDependencies: + - debug + + '@codspeed/vitest-plugin@3.1.1(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vitest@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': + dependencies: + '@codspeed/core': 3.1.1 + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vitest: 2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + transitivePeerDependencies: + - debug + '@colors/colors@1.5.0': optional: true @@ -15249,7 +15348,7 @@ snapshots: dependencies: '@monaco-editor/loader': 1.4.0 vue: 3.4.15(typescript@5.4.5) - vue-demi: 0.14.9(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)) optionalDependencies: '@vue/composition-api': 1.7.2(vue@3.4.15(typescript@5.4.5)) @@ -16009,26 +16108,26 @@ snapshots: dependencies: solid-js: 1.8.5 - '@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': + '@sveltejs/vite-plugin-svelte-inspector@2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': dependencies: - '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + '@sveltejs/vite-plugin-svelte': 3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) debug: 4.3.4 svelte: 4.0.0 - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - supports-color - '@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': + '@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': dependencies: - '@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + '@sveltejs/vite-plugin-svelte-inspector': 2.0.0(@sveltejs/vite-plugin-svelte@3.0.1(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)))(svelte@4.0.0)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) debug: 4.3.4 deepmerge: 4.3.1 kleur: 4.1.5 magic-string: 0.30.5 svelte: 4.0.0 svelte-hmr: 0.15.3(svelte@4.0.0) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - vitefu: 0.2.5(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vitefu: 0.2.5(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) transitivePeerDependencies: - supports-color @@ -17238,6 +17337,10 @@ snapshots: dependencies: undici-types: 5.26.5 + '@types/node@20.14.12': + dependencies: + undici-types: 5.26.5 + '@types/node@20.5.1': {} '@types/normalize-package-data@2.4.3': {} @@ -17479,7 +17582,7 @@ snapshots: transitivePeerDependencies: - babel-plugin-macros - '@vanilla-extract/integration@7.1.7(@types/node@20.12.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)': + '@vanilla-extract/integration@7.1.7(@types/node@20.14.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)': dependencies: '@babel/core': 7.24.3 '@babel/plugin-syntax-typescript': 7.24.1(@babel/core@7.24.3) @@ -17491,8 +17594,8 @@ snapshots: find-up: 5.0.0 javascript-stringify: 2.1.0 mlly: 1.4.2 - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - vite-node: 1.4.0(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite-node: 1.4.0(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -17506,10 +17609,10 @@ snapshots: '@vanilla-extract/private@1.0.5': {} - '@vanilla-extract/vite-plugin@4.0.13(@types/node@20.12.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': + '@vanilla-extract/vite-plugin@4.0.13(@types/node@20.14.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': dependencies: - '@vanilla-extract/integration': 7.1.7(@types/node@20.12.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + '@vanilla-extract/integration': 7.1.7(@types/node@20.14.12)(babel-plugin-macros@3.1.0)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - '@types/node' - babel-plugin-macros @@ -17521,116 +17624,121 @@ snapshots: - supports-color - terser - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': + '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': dependencies: '@babel/core': 7.24.3 '@babel/plugin-transform-typescript': 7.24.1(@babel/core@7.24.3) '@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.3) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1) vue: 3.3.7(typescript@5.4.5) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': + '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': dependencies: '@babel/core': 7.24.3 '@babel/plugin-transform-typescript': 7.24.1(@babel/core@7.24.3) '@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.3) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.3.7(typescript@5.4.5) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5))': + '@vitejs/plugin-vue-jsx@3.1.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5))': dependencies: '@babel/core': 7.24.3 '@babel/plugin-transform-typescript': 7.24.1(@babel/core@7.24.3) '@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.3) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.4.27(typescript@5.4.5) transitivePeerDependencies: - supports-color - '@vitejs/plugin-vue2@2.3.1(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@2.7.16)': + '@vitejs/plugin-vue2@2.3.1(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@2.7.16)': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 2.7.16 - '@vitejs/plugin-vue@4.4.0(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.12(typescript@5.4.5))': + '@vitejs/plugin-vue@4.4.0(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.12(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.3.12(typescript@5.4.5) - '@vitejs/plugin-vue@4.6.2(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': + '@vitejs/plugin-vue@4.6.2(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1) vue: 3.3.7(typescript@5.4.5) - '@vitejs/plugin-vue@4.6.2(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5))': + '@vitejs/plugin-vue@4.6.2(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.4.15(typescript@5.4.5) - '@vitejs/plugin-vue@5.0.3(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5))': + '@vitejs/plugin-vue@5.0.3(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.15(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.4.15(typescript@5.4.5) - '@vitejs/plugin-vue@5.0.4(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': + '@vitejs/plugin-vue@5.0.4(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.3.7(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.3.7(typescript@5.4.5) - '@vitejs/plugin-vue@5.0.4(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5))': + '@vitejs/plugin-vue@5.0.4(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue@3.4.27(typescript@5.4.5))': dependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue: 3.4.27(typescript@5.4.5) - '@vitest/coverage-v8@0.33.0(vitest@1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': + '@vitest/coverage-v8@2.0.4(vitest@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))': dependencies: - '@ampproject/remapping': 2.2.1 + '@ampproject/remapping': 2.3.0 '@bcoe/v8-coverage': 0.2.3 - istanbul-lib-coverage: 3.2.0 + debug: 4.3.5 + istanbul-lib-coverage: 3.2.2 istanbul-lib-report: 3.0.1 - istanbul-lib-source-maps: 4.0.1 - istanbul-reports: 3.1.6 - magic-string: 0.30.5 - picocolors: 1.0.0 - std-env: 3.4.3 - test-exclude: 6.0.0 - v8-to-istanbul: 9.1.3 - vitest: 1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + istanbul-lib-source-maps: 5.0.6 + istanbul-reports: 3.1.7 + magic-string: 0.30.10 + magicast: 0.3.4 + std-env: 3.7.0 + test-exclude: 7.0.1 + tinyrainbow: 1.2.0 + vitest: 2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - supports-color - '@vitest/expect@1.4.0': + '@vitest/expect@2.0.4': dependencies: - '@vitest/spy': 1.4.0 - '@vitest/utils': 1.4.0 - chai: 4.3.10 + '@vitest/spy': 2.0.4 + '@vitest/utils': 2.0.4 + chai: 5.1.1 + tinyrainbow: 1.2.0 - '@vitest/runner@1.4.0': + '@vitest/pretty-format@2.0.4': dependencies: - '@vitest/utils': 1.4.0 - p-limit: 5.0.0 - pathe: 1.1.1 + tinyrainbow: 1.2.0 - '@vitest/snapshot@1.4.0': + '@vitest/runner@2.0.4': dependencies: + '@vitest/utils': 2.0.4 + pathe: 1.1.2 + + '@vitest/snapshot@2.0.4': + dependencies: + '@vitest/pretty-format': 2.0.4 magic-string: 0.30.10 - pathe: 1.1.1 - pretty-format: 29.7.0 + pathe: 1.1.2 - '@vitest/spy@1.4.0': + '@vitest/spy@2.0.4': dependencies: - tinyspy: 2.2.0 + tinyspy: 3.0.0 - '@vitest/utils@1.4.0': + '@vitest/utils@2.0.4': dependencies: - diff-sequences: 29.6.3 + '@vitest/pretty-format': 2.0.4 estree-walker: 3.0.3 - loupe: 2.3.7 - pretty-format: 29.7.0 + loupe: 3.1.1 + tinyrainbow: 1.2.0 '@vue-macros/common@1.10.0(rollup@4.14.1)(vue@3.3.7(typescript@5.4.5))': dependencies: @@ -17996,7 +18104,7 @@ snapshots: '@vue/compiler-core': 3.3.7 '@vue/shared': 3.3.7 estree-walker: 2.0.2 - magic-string: 0.30.5 + magic-string: 0.30.10 '@vue/reactivity@3.3.12': dependencies: @@ -18097,7 +18205,7 @@ snapshots: '@types/web-bluetooth': 0.0.16 '@vueuse/metadata': 9.13.0 '@vueuse/shared': 9.13.0(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)) - vue-demi: 0.14.8(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -18106,7 +18214,7 @@ snapshots: '@vueuse/shared@9.13.0(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5))': dependencies: - vue-demi: 0.14.9(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)) + vue-demi: 0.14.10(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)) transitivePeerDependencies: - '@vue/composition-api' - vue @@ -18579,13 +18687,13 @@ snapshots: assert-plus@1.0.0: optional: true - assertion-error@1.1.0: {} + assertion-error@2.0.1: {} assign-symbols@1.0.0: {} ast-kit@0.11.3(rollup@4.14.1): dependencies: - '@babel/parser': 7.24.1 + '@babel/parser': 7.24.5 '@rollup/pluginutils': 5.1.0(rollup@4.14.1) pathe: 1.1.1 transitivePeerDependencies: @@ -18593,7 +18701,7 @@ snapshots: ast-kit@0.9.5(rollup@4.14.1): dependencies: - '@babel/parser': 7.24.1 + '@babel/parser': 7.24.5 '@rollup/pluginutils': 5.1.0(rollup@4.14.1) pathe: 1.1.1 transitivePeerDependencies: @@ -19136,15 +19244,13 @@ snapshots: adler-32: 1.3.1 crc-32: 1.2.2 - chai@4.3.10: + chai@5.1.1: dependencies: - assertion-error: 1.1.0 - check-error: 1.0.3 - deep-eql: 4.1.3 - get-func-name: 2.0.2 - loupe: 2.3.7 - pathval: 1.1.1 - type-detect: 4.0.8 + assertion-error: 2.0.1 + check-error: 2.1.1 + deep-eql: 5.0.2 + loupe: 3.1.1 + pathval: 2.0.0 chalk-template@0.4.0: dependencies: @@ -19179,9 +19285,7 @@ snapshots: chardet@0.7.0: {} - check-error@1.0.3: - dependencies: - get-func-name: 2.0.2 + check-error@2.1.1: {} chokidar@3.5.3: dependencies: @@ -19903,6 +20007,10 @@ snapshots: dependencies: ms: 2.1.2 + debug@4.3.5: + dependencies: + ms: 2.1.2 + decamelize-keys@1.1.1: dependencies: decamelize: 1.2.0 @@ -19920,9 +20028,7 @@ snapshots: optionalDependencies: babel-plugin-macros: 3.1.0 - deep-eql@4.1.3: - dependencies: - type-detect: 4.0.8 + deep-eql@5.0.2: {} deep-equal@1.0.1: {} @@ -20272,7 +20378,7 @@ snapshots: electron@30.0.7: dependencies: '@electron/get': 2.0.3 - '@types/node': 20.12.12 + '@types/node': 20.14.12 extract-zip: 2.0.1 transitivePeerDependencies: - supports-color @@ -20887,7 +20993,7 @@ snapshots: farm-plugin-replace-dirname-win32-ia32-msvc: 0.2.1 farm-plugin-replace-dirname-win32-x64-msvc: 0.2.1 - farmup@0.0.12: + farmup@0.1.0: dependencies: '@farmfe/core': link:packages/core @@ -21013,6 +21119,11 @@ snapshots: locate-path: 6.0.0 path-exists: 4.0.0 + find-up@6.3.0: + dependencies: + locate-path: 7.2.0 + path-exists: 5.0.0 + find-yarn-workspace-root2@1.2.16: dependencies: micromatch: 4.0.5 @@ -21956,6 +22067,8 @@ snapshots: istanbul-lib-coverage@3.2.0: {} + istanbul-lib-coverage@3.2.2: {} + istanbul-lib-instrument@5.2.1: dependencies: '@babel/core': 7.24.3 @@ -21978,7 +22091,7 @@ snapshots: istanbul-lib-report@3.0.1: dependencies: - istanbul-lib-coverage: 3.2.0 + istanbul-lib-coverage: 3.2.2 make-dir: 4.0.0 supports-color: 7.2.0 @@ -21990,11 +22103,24 @@ snapshots: transitivePeerDependencies: - supports-color + istanbul-lib-source-maps@5.0.6: + dependencies: + '@jridgewell/trace-mapping': 0.3.25 + debug: 4.3.5 + istanbul-lib-coverage: 3.2.2 + transitivePeerDependencies: + - supports-color + istanbul-reports@3.1.6: dependencies: html-escaper: 2.0.2 istanbul-lib-report: 3.0.1 + istanbul-reports@3.1.7: + dependencies: + html-escaper: 2.0.2 + istanbul-lib-report: 3.0.1 + iterare@1.2.1: {} jackspeak@3.1.2: @@ -22366,8 +22492,6 @@ snapshots: js-tokens@4.0.0: {} - js-tokens@8.0.3: {} - js-yaml@3.14.1: dependencies: argparse: 1.0.10 @@ -22676,6 +22800,10 @@ snapshots: dependencies: p-locate: 5.0.0 + locate-path@7.2.0: + dependencies: + p-locate: 6.0.0 + lodash-es@4.17.21: {} lodash-unified@1.0.3(@types/lodash-es@4.17.12)(lodash-es@4.17.21)(lodash@4.17.21): @@ -22735,7 +22863,7 @@ snapshots: dependencies: js-tokens: 4.0.0 - loupe@2.3.7: + loupe@3.1.1: dependencies: get-func-name: 2.0.2 @@ -22782,6 +22910,12 @@ snapshots: dependencies: '@jridgewell/sourcemap-codec': 1.4.15 + magicast@0.3.4: + dependencies: + '@babel/parser': 7.24.5 + '@babel/types': 7.24.0 + source-map-js: 1.2.0 + make-dir@2.1.0: dependencies: pify: 4.0.1 @@ -23414,7 +23548,7 @@ snapshots: dependencies: yocto-queue: 0.1.0 - p-limit@5.0.0: + p-limit@4.0.0: dependencies: yocto-queue: 1.0.0 @@ -23430,6 +23564,10 @@ snapshots: dependencies: p-limit: 3.1.0 + p-locate@6.0.0: + dependencies: + p-limit: 4.0.0 + p-map@2.1.0: {} p-map@4.0.0: @@ -23485,6 +23623,8 @@ snapshots: path-exists@4.0.0: {} + path-exists@5.0.0: {} + path-is-absolute@1.0.1: {} path-is-inside@1.0.2: {} @@ -23520,7 +23660,9 @@ snapshots: pathe@1.1.1: {} - pathval@1.1.1: {} + pathe@1.1.2: {} + + pathval@2.0.0: {} pdfast@0.2.0: {} @@ -23638,29 +23780,29 @@ snapshots: camelcase-css: 2.0.1 postcss: 8.4.39 - postcss-load-config@4.0.1(postcss@8.4.31)(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)): + postcss-load-config@4.0.1(postcss@8.4.31)(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)): dependencies: lilconfig: 2.1.0 yaml: 2.3.4 optionalDependencies: postcss: 8.4.31 - ts-node: 10.9.1(@types/node@18.18.8)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@20.14.12)(typescript@4.9.5) - postcss-load-config@4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)): + postcss-load-config@4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)): dependencies: lilconfig: 2.1.0 yaml: 2.3.4 optionalDependencies: postcss: 8.4.39 - ts-node: 10.9.1(@types/node@18.18.8)(typescript@4.9.5) + ts-node: 10.9.1(@types/node@20.14.12)(typescript@4.9.5) - postcss-load-config@4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)): + postcss-load-config@4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5)): dependencies: lilconfig: 2.1.0 yaml: 2.3.4 optionalDependencies: postcss: 8.4.39 - ts-node: 10.9.1(@types/node@20.12.12)(typescript@5.4.5) + ts-node: 10.9.1(@types/node@20.14.12)(typescript@5.4.5) postcss-merge-rules@7.0.2(postcss@8.4.39): dependencies: @@ -25258,8 +25400,6 @@ snapshots: statuses@2.0.1: {} - std-env@3.4.3: {} - std-env@3.7.0: {} stop-iteration-iterator@1.0.0: @@ -25366,10 +25506,6 @@ snapshots: dependencies: acorn: 8.11.2 - strip-literal@2.0.0: - dependencies: - js-tokens: 8.0.3 - strip-outer@1.0.1: dependencies: escape-string-regexp: 1.0.5 @@ -25476,7 +25612,7 @@ snapshots: '@babel/core': 7.24.3 less: 4.2.0 postcss: 8.4.39 - postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)) + postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5)) sass: 1.74.1 typescript: 5.4.5 @@ -25535,7 +25671,7 @@ snapshots: '@pkgr/core': 0.1.1 tslib: 2.6.2 - tailwindcss@3.3.5(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)): + tailwindcss@3.3.5(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -25554,7 +25690,7 @@ snapshots: postcss: 8.4.39 postcss-import: 15.1.0(postcss@8.4.39) postcss-js: 4.0.1(postcss@8.4.39) - postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5)) + postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5)) postcss-nested: 6.0.1(postcss@8.4.39) postcss-selector-parser: 6.0.13 resolve: 1.22.8 @@ -25562,7 +25698,7 @@ snapshots: transitivePeerDependencies: - ts-node - tailwindcss@3.3.5(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)): + tailwindcss@3.3.5(ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5)): dependencies: '@alloc/quick-lru': 5.2.0 arg: 5.0.2 @@ -25581,7 +25717,7 @@ snapshots: postcss: 8.4.39 postcss-import: 15.1.0(postcss@8.4.39) postcss-js: 4.0.1(postcss@8.4.39) - postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5)) + postcss-load-config: 4.0.1(postcss@8.4.39)(ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5)) postcss-nested: 6.0.1(postcss@8.4.39) postcss-selector-parser: 6.0.13 resolve: 1.22.8 @@ -25619,19 +25755,19 @@ snapshots: mkdirp: 1.0.4 yallist: 4.0.0 - tdesign-icons-vue@0.2.2(vue@2.6.14): + tdesign-icons-vue@0.2.4(vue@2.6.14): dependencies: '@babel/runtime': 7.23.2 classnames: 2.3.2 vue: 2.6.14 - tdesign-icons-vue@0.2.2(vue@2.7.16): + tdesign-icons-vue@0.2.4(vue@2.7.16): dependencies: '@babel/runtime': 7.23.2 classnames: 2.3.2 vue: 2.7.16 - tdesign-vue@1.9.3(vue@2.6.14): + tdesign-vue@1.9.8(vue@2.6.14): dependencies: '@babel/runtime': 7.23.2 '@popperjs/core': 2.11.8 @@ -25648,12 +25784,12 @@ snapshots: mitt: 3.0.1 raf: 3.4.1 sortablejs: 1.15.2 - tdesign-icons-vue: 0.2.2(vue@2.6.14) + tdesign-icons-vue: 0.2.4(vue@2.6.14) tinycolor2: 1.6.0 validator: 13.11.0 vue: 2.6.14 - tdesign-vue@1.9.3(vue@2.7.16): + tdesign-vue@1.9.8(vue@2.7.16): dependencies: '@babel/runtime': 7.23.2 '@popperjs/core': 2.11.8 @@ -25670,7 +25806,7 @@ snapshots: mitt: 3.0.1 raf: 3.4.1 sortablejs: 1.15.2 - tdesign-icons-vue: 0.2.2(vue@2.7.16) + tdesign-icons-vue: 0.2.4(vue@2.7.16) tinycolor2: 1.6.0 validator: 13.11.0 vue: 2.7.16 @@ -25710,6 +25846,12 @@ snapshots: glob: 7.2.3 minimatch: 3.1.2 + test-exclude@7.0.1: + dependencies: + '@istanbuljs/schema': 0.1.3 + glob: 10.4.2 + minimatch: 9.0.5 + text-extensions@1.9.0: {} text-table@0.2.0: {} @@ -25739,7 +25881,7 @@ snapshots: tiny-warning@1.0.3: {} - tinybench@2.5.1: {} + tinybench@2.8.0: {} tinycolor2@1.6.0: {} @@ -25748,11 +25890,13 @@ snapshots: '@types/tinycolor2': 1.4.5 tinycolor2: 1.6.0 - tinypool@0.8.2: {} + tinypool@1.0.0: {} tinyqueue@2.0.3: {} - tinyspy@2.2.0: {} + tinyrainbow@1.2.0: {} + + tinyspy@3.0.0: {} titleize@3.0.0: {} @@ -25876,14 +26020,32 @@ snapshots: '@ts-morph/common': 0.23.0 code-block-writer: 13.0.1 - ts-node@10.9.1(@types/node@18.18.8)(typescript@4.9.5): + ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 18.18.8 + '@types/node': 20.12.12 + acorn: 8.12.0 + acorn-walk: 8.3.2 + arg: 4.1.3 + create-require: 1.1.1 + diff: 4.0.2 + make-error: 1.3.6 + typescript: 5.4.5 + v8-compile-cache-lib: 3.0.1 + yn: 3.1.1 + + ts-node@10.9.1(@types/node@20.14.12)(typescript@4.9.5): + dependencies: + '@cspotcode/source-map-support': 0.8.1 + '@tsconfig/node10': 1.0.9 + '@tsconfig/node12': 1.0.11 + '@tsconfig/node14': 1.0.3 + '@tsconfig/node16': 1.0.4 + '@types/node': 20.14.12 acorn: 8.12.0 acorn-walk: 8.3.2 arg: 4.1.3 @@ -25895,14 +26057,14 @@ snapshots: yn: 3.1.1 optional: true - ts-node@10.9.1(@types/node@20.12.12)(typescript@5.4.5): + ts-node@10.9.1(@types/node@20.14.12)(typescript@5.4.5): dependencies: '@cspotcode/source-map-support': 0.8.1 '@tsconfig/node10': 1.0.9 '@tsconfig/node12': 1.0.11 '@tsconfig/node14': 1.0.3 '@tsconfig/node16': 1.0.4 - '@types/node': 20.12.12 + '@types/node': 20.14.12 acorn: 8.12.0 acorn-walk: 8.3.2 arg: 4.1.3 @@ -25912,6 +26074,7 @@ snapshots: typescript: 5.4.5 v8-compile-cache-lib: 3.0.1 yn: 3.1.1 + optional: true ts-node@10.9.1(@types/node@20.5.1)(typescript@5.4.5): dependencies: @@ -26274,7 +26437,7 @@ snapshots: v8-to-istanbul@9.1.3: dependencies: - '@jridgewell/trace-mapping': 0.3.20 + '@jridgewell/trace-mapping': 0.3.25 '@types/istanbul-lib-coverage': 2.0.5 convert-source-map: 2.0.0 @@ -26300,13 +26463,13 @@ snapshots: extsprintf: 1.4.1 optional: true - vite-node@1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): + vite-node@1.4.0(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): dependencies: cac: 6.7.14 debug: 4.3.4 pathe: 1.1.1 picocolors: 1.0.0 - vite: 5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - '@types/node' - less @@ -26317,13 +26480,13 @@ snapshots: - supports-color - terser - vite-node@1.4.0(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): + vite-node@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): dependencies: cac: 6.7.14 - debug: 4.3.4 - pathe: 1.1.1 - picocolors: 1.0.0 - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + debug: 4.3.5 + pathe: 1.1.2 + tinyrainbow: 1.2.0 + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - '@types/node' - less @@ -26334,7 +26497,7 @@ snapshots: - supports-color - terser - vite-plugin-pages@0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): + vite-plugin-pages@0.32.0(@vue/compiler-sfc@3.4.27)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): dependencies: '@types/debug': 4.1.12 debug: 4.3.4 @@ -26344,14 +26507,14 @@ snapshots: json5: 2.2.3 local-pkg: 0.5.0 picocolors: 1.0.0 - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) yaml: 2.3.4 optionalDependencies: '@vue/compiler-sfc': 3.4.27 transitivePeerDependencies: - supports-color - vite-plugin-solid@2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): + vite-plugin-solid@2.7.2(solid-js@1.8.5)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): dependencies: '@babel/core': 7.23.2 '@babel/preset-typescript': 7.23.2(@babel/core@7.23.2) @@ -26360,8 +26523,8 @@ snapshots: merge-anything: 5.1.7 solid-js: 1.8.5 solid-refresh: 0.5.3(solid-js@1.8.5) - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - vitefu: 0.2.5(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vitefu: 0.2.5(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)) transitivePeerDependencies: - supports-color @@ -26485,7 +26648,7 @@ snapshots: - walrus - whiskers - vite-plugin-vue2@2.0.3(ejs@3.1.10)(lodash@4.17.21)(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue-template-compiler@2.6.14(vue@2.6.14))(vue@2.6.14): + vite-plugin-vue2@2.0.3(ejs@3.1.10)(lodash@4.17.21)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1))(vue-template-compiler@2.6.14(vue@2.6.14))(vue@2.6.14): dependencies: '@babel/core': 7.24.3 '@babel/parser': 7.24.1 @@ -26515,7 +26678,7 @@ snapshots: rollup: 2.79.1 slash: 3.0.0 source-map: 0.7.4 - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) vue-template-babel-compiler: 1.2.0(vue-template-compiler@2.6.14(vue@2.6.14)) vue-template-compiler: 2.6.14(vue@2.6.14) transitivePeerDependencies: @@ -26580,84 +26743,70 @@ snapshots: svgo: 3.2.0 vue: 3.3.7(typescript@5.4.5) - vite-tsconfig-paths@4.3.1(typescript@5.4.5)(vite@5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): + vite-tsconfig-paths@4.3.1(typescript@5.4.5)(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): dependencies: debug: 4.3.4 globrex: 0.1.2 tsconfck: 3.0.1(typescript@5.4.5) optionalDependencies: - vite: 5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) transitivePeerDependencies: - supports-color - typescript - vite@5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): - dependencies: - esbuild: 0.20.2 - postcss: 8.4.39 - rollup: 4.14.1 - optionalDependencies: - '@types/node': 18.18.8 - fsevents: 2.3.3 - less: 4.2.0 - lightningcss: 1.25.1 - sass: 1.74.1 - terser: 5.31.1 - - vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1): + vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.69.5)(terser@5.31.1): dependencies: esbuild: 0.20.2 postcss: 8.4.39 rollup: 4.14.1 optionalDependencies: - '@types/node': 20.12.12 + '@types/node': 20.14.12 fsevents: 2.3.3 less: 4.2.0 lightningcss: 1.25.1 sass: 1.69.5 terser: 5.31.1 - vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): + vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): dependencies: esbuild: 0.20.2 postcss: 8.4.39 rollup: 4.14.1 optionalDependencies: - '@types/node': 20.12.12 + '@types/node': 20.14.12 fsevents: 2.3.3 less: 4.2.0 lightningcss: 1.25.1 sass: 1.74.1 terser: 5.31.1 - vitefu@0.2.5(vite@5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): + vitefu@0.2.5(vite@5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1)): optionalDependencies: - vite: 5.2.8(@types/node@20.12.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - - vitest@1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): - dependencies: - '@vitest/expect': 1.4.0 - '@vitest/runner': 1.4.0 - '@vitest/snapshot': 1.4.0 - '@vitest/spy': 1.4.0 - '@vitest/utils': 1.4.0 - acorn-walk: 8.3.2 - chai: 4.3.10 - debug: 4.3.4 + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + + vitest@2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1): + dependencies: + '@ampproject/remapping': 2.3.0 + '@vitest/expect': 2.0.4 + '@vitest/pretty-format': 2.0.4 + '@vitest/runner': 2.0.4 + '@vitest/snapshot': 2.0.4 + '@vitest/spy': 2.0.4 + '@vitest/utils': 2.0.4 + chai: 5.1.1 + debug: 4.3.5 execa: 8.0.1 - local-pkg: 0.5.0 - magic-string: 0.30.5 - pathe: 1.1.1 - picocolors: 1.0.0 + magic-string: 0.30.10 + pathe: 1.1.2 std-env: 3.7.0 - strip-literal: 2.0.0 - tinybench: 2.5.1 - tinypool: 0.8.2 - vite: 5.2.8(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - vite-node: 1.4.0(@types/node@18.18.8)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) - why-is-node-running: 2.2.2 + tinybench: 2.8.0 + tinypool: 1.0.0 + tinyrainbow: 1.2.0 + vite: 5.2.8(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + vite-node: 2.0.4(@types/node@20.14.12)(less@4.2.0)(lightningcss@1.25.1)(sass@1.74.1)(terser@5.31.1) + why-is-node-running: 2.3.0 optionalDependencies: - '@types/node': 18.18.8 + '@types/node': 20.14.12 transitivePeerDependencies: - less - lightningcss @@ -26671,25 +26820,19 @@ snapshots: vscode-uri@3.0.8: {} - vue-demi@0.14.7(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)): - dependencies: - vue: 3.4.15(typescript@5.4.5) - optionalDependencies: - '@vue/composition-api': 1.7.2(vue@3.4.15(typescript@5.4.5)) - - vue-demi@0.14.8(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)): + vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)): dependencies: vue: 3.3.7(typescript@5.4.5) optionalDependencies: '@vue/composition-api': 1.7.2(vue@3.3.7(typescript@5.4.5)) - vue-demi@0.14.9(@vue/composition-api@1.7.2(vue@3.3.7(typescript@5.4.5)))(vue@3.3.7(typescript@5.4.5)): + vue-demi@0.14.10(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)): dependencies: - vue: 3.3.7(typescript@5.4.5) + vue: 3.4.15(typescript@5.4.5) optionalDependencies: - '@vue/composition-api': 1.7.2(vue@3.3.7(typescript@5.4.5)) + '@vue/composition-api': 1.7.2(vue@3.4.15(typescript@5.4.5)) - vue-demi@0.14.9(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)): + vue-demi@0.14.7(@vue/composition-api@1.7.2(vue@3.4.15(typescript@5.4.5)))(vue@3.4.15(typescript@5.4.5)): dependencies: vue: 3.4.15(typescript@5.4.5) optionalDependencies: @@ -26909,7 +27052,7 @@ snapshots: dependencies: isexe: 2.0.0 - why-is-node-running@2.2.2: + why-is-node-running@2.3.0: dependencies: siginfo: 2.0.0 stackback: 0.0.2 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 13d6523ccc..a72279fc73 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -4,3 +4,4 @@ packages: - crates/* - rust-plugins/* - js-plugins/* + - bench/