Skip to content

Commit 0d4480d

Browse files
committed
workaround
1 parent a252569 commit 0d4480d

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
"format": "npm run prettier -- --write",
2222
"format:check": "npm run prettier -- -l",
2323
"clean": "rm -rf dist/*",
24-
"prebuild": "npm run format:check && npm run clean",
24+
"copy-rollup": "node ./scripts/vite-workaround-for-rollup.mjs",
25+
"prebuild": "npm run format:check && npm run clean && npm run copy-rollup",
2526
"build": "tsc -p . && tsc -p ./tsconfig.cjs.json && echo \"{\\\"type\\\": \\\"commonjs\\\"}\" > dist/cjs/package.json",
2627
"docs": "vuepress dev docs",
2728
"docs:build": "vuepress build docs",
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import fs from 'node:fs';
2+
import path from 'node:path';
3+
import { fileURLToPath } from 'node:url';
4+
import { dirname } from 'node:path';
5+
6+
const __filename = fileURLToPath(import.meta.url);
7+
const __dirname = dirname(__filename);
8+
9+
const rollupDir = path.join(__dirname, '..', 'node_modules', 'rollup', 'dist');
10+
const destDir = path.join(__dirname, '..', 'node_modules', 'rollup');
11+
12+
const filesToCopy = ['parseAst.d.ts', 'parseAst.js'];
13+
14+
filesToCopy.forEach(file => {
15+
const srcPath = path.join(rollupDir, file);
16+
const destPath = path.join(destDir, file);
17+
18+
fs.copyFileSync(srcPath, destPath);
19+
console.log(`[Workaround] Copied ${srcPath} to ${destPath}`);
20+
21+
if (file === 'parseAst.d.ts') {
22+
const data = fs.readFileSync(destPath, 'utf8');
23+
const result = data.replace("from './rollup';", "from './';");
24+
fs.writeFileSync(destPath, result, 'utf8');
25+
console.log(`[Workaround] Updated import in ${destPath}`);
26+
}
27+
});

tsconfig.cjs.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"sourceMap": true,
66
"declarationMap": true,
77
"declaration": true,
8-
"rootDirs": ["lib"],
9-
"skipLibCheck": true
8+
"rootDirs": ["lib"]
109
},
1110
"include": [
1211
"lib/**/*.ts",

0 commit comments

Comments
 (0)