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

This commit is contained in:
Alex Yang
2023-09-25 21:49:23 -05:00
committed by GitHub
parent 2e1acec3c0
commit 127a84b4e1
4 changed files with 16 additions and 36 deletions
+1 -1
View File
@@ -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",
+4 -33
View File
@@ -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,
],
});
+1 -1
View File
@@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "bundler",
"outDir": "lib"
},
"include": ["src"],
+10 -1
View File
@@ -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"