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

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",

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,
],
});

View File

@@ -3,7 +3,7 @@
"compilerOptions": {
"composite": true,
"module": "ESNext",
"moduleResolution": "Node",
"moduleResolution": "bundler",
"outDir": "lib"
},
"include": ["src"],