Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

refactor(plugin-cli): use `@plugxjs/vite-plugin` (#4501)

Alex Yang127a84b4e17c
diff --git a/packages/plugin-cli/package.json b/packages/plugin-cli/package.json
index 2826200edf..21007ae066 100644
--- a/packages/plugin-cli/package.json
+++ b/packages/plugin-cli/package.json
@@ -10,7 +10,7 @@
"tsconfig.json"
],
"dependencies": {
- "@endo/static-module-record": "^0.8.2",
+ "@plugxjs/vite-plugin": "0.0.2",
"@swc/core": "^1.3.81",
"@toeverything/infra": "workspace:^",
"@vanilla-extract/rollup-plugin": "^1.3.0",
diff --git a/packages/plugin-cli/src/af.ts b/packages/plugin-cli/src/af.ts
index 9915bccefc..ec9aac1ce9 100644
--- a/packages/plugin-cli/src/af.ts
+++ b/packages/plugin-cli/src/af.ts
@@ -4,7 +4,7 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import { parseArgs } from 'node:util';
-import { StaticModuleRecord } from '@endo/static-module-record';
+import plugx from '@plugxjs/vite-plugin';
import {
packageJsonInputSchema,
packageJsonOutputSchema,
@@ -185,38 +185,9 @@ await build({
vanillaExtractPlugin(),
vue(),
react(),
- {
- name: 'parse-bundle',
- renderChunk(code, chunk) {
- if (chunk.fileName.endsWith('js')) {
- const record = new StaticModuleRecord(code, chunk.fileName);
- const reexports = record.__reexportMap__ as Record<
- string,
- [localName: string, exportedName: string][]
- >;
- const exports = Object.assign(
- {},
- record.__fixedExportMap__,
- record.__liveExportMap__
- );
- this.emitFile({
- type: 'asset',
- fileName: `${chunk.fileName}.json`,
- source: JSON.stringify(
- {
- exports: exports,
- imports: record.imports,
- reexports: reexports,
- },
- null,
- 2
- ),
- });
- return record.__syncModuleProgram__;
- }
- return code;
- },
- },
+ plugx({
+ staticJsonSuffix: '.json',
+ }),
generatePackageJson,
],
});
diff --git a/packages/plugin-cli/tsconfig.json b/packages/plugin-cli/tsconfig.json
index 526b46bc0f..90feca1c79 100644
--- a/packages/plugin-cli/tsconfig.json
+++ b/packages/plugin-cli/tsconfig.json
@@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"module": "ESNext",
- "moduleResolution": "Node",
+ "moduleResolution": "bundler",
"outDir": "lib"
},
"include": ["src"],
diff --git a/yarn.lock b/yarn.lock
index fb7983e8d0..ad38148496 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -623,7 +623,7 @@ __metadata:
version: 0.0.0-use.local
resolution: "@affine/plugin-cli@workspace:packages/plugin-cli"
dependencies:
- "@endo/static-module-record": ^0.8.2
+ "@plugxjs/vite-plugin": 0.0.2
"@swc/core": ^1.3.81
"@toeverything/infra": "workspace:^"
"@vanilla-extract/rollup-plugin": ^1.3.0
@@ -8757,6 +8757,15 @@ __metadata:
languageName: node
linkType: hard
+"@plugxjs/vite-plugin@npm:0.0.2":
+ version: 0.0.2
+ resolution: "@plugxjs/vite-plugin@npm:0.0.2"
+ dependencies:
+ "@endo/static-module-record": ^0.8.2
+ checksum: 12add55abfca3b29d0a709dd852ec69f335013b78bf06d4b27e9851d9c8ade097ac875f8d509ac5915abe74f9b457c89fa17587dc1bd534e11d76846ba643717
+ languageName: node
+ linkType: hard
+
"@pmmmwh/react-refresh-webpack-plugin@npm:^0.5.11":
version: 0.5.11
resolution: "@pmmmwh/react-refresh-webpack-plugin@npm:0.5.11"