2023-10-29 05:09:41 +00:00
|
|
|
// tsup doesn't replace npm dependency aliases in the dist files, so we have to do it manually
|
|
|
|
|
|
2025-06-20 13:27:20 +00:00
|
|
|
const fs = require('fs');
|
|
|
|
|
const glob = require('glob');
|
|
|
|
|
|
|
|
|
|
function replaceSync({ file, from, to }) {
|
|
|
|
|
const paths = glob.sync(file, { ignore: [], nodir: true });
|
|
|
|
|
|
|
|
|
|
paths.forEach(path => {
|
|
|
|
|
const contents = fs.readFileSync(path, { encoding: 'utf-8' });
|
|
|
|
|
|
|
|
|
|
const newContents = contents.replace(from, to);
|
|
|
|
|
|
|
|
|
|
if (newContents !== contents) {
|
|
|
|
|
fs.writeFileSync(path, newContents, { encoding: 'utf-8' });
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-10-29 05:09:41 +00:00
|
|
|
|
2023-11-21 23:11:56 +00:00
|
|
|
// tsup incorrectly resolve to legacy types, make a fix here
|
|
|
|
|
console.log('Replacing @tanstack/react-query-v5/build/legacy/types');
|
2025-06-20 13:27:20 +00:00
|
|
|
replaceSync({
|
|
|
|
|
file: 'dist/runtime-v5/react*(.d.ts|.d.mts)',
|
2023-11-21 23:11:56 +00:00
|
|
|
from: /@tanstack\/react-query-v5\/build\/legacy\/types/g,
|
|
|
|
|
to: '@tanstack/react-query',
|
|
|
|
|
});
|
|
|
|
|
|
2023-10-29 05:09:41 +00:00
|
|
|
console.log('Replacing @tanstack/react-query-v5');
|
2025-06-20 13:27:20 +00:00
|
|
|
replaceSync({
|
|
|
|
|
file: 'dist/runtime-v5/react*(.d.ts|.d.mts|.js|.mjs)',
|
2023-10-29 05:09:41 +00:00
|
|
|
from: /@tanstack\/react-query-v5/g,
|
|
|
|
|
to: '@tanstack/react-query',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log('Replacing @tanstack/svelte-query-v5');
|
2025-06-20 13:27:20 +00:00
|
|
|
replaceSync({
|
|
|
|
|
file: 'dist/runtime-v5/svelte*(.d.ts|.d.mts|.js|.mjs)',
|
2023-10-29 05:09:41 +00:00
|
|
|
from: /@tanstack\/svelte-query-v5/g,
|
|
|
|
|
to: '@tanstack/svelte-query',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
console.log('Replacing @tanstack/vue-query-v5');
|
2025-06-20 13:27:20 +00:00
|
|
|
replaceSync({
|
|
|
|
|
file: 'dist/runtime-v5/vue*(.d.ts|.d.mts|.js|.mjs)',
|
2023-10-29 05:09:41 +00:00
|
|
|
from: /@tanstack\/vue-query-v5/g,
|
|
|
|
|
to: '@tanstack/vue-query',
|
|
|
|
|
});
|
2025-08-09 12:54:47 +00:00
|
|
|
|
|
|
|
|
console.log('Replacing @tanstack/angular-query-v5');
|
|
|
|
|
replaceSync({
|
|
|
|
|
file: 'dist/runtime-v5/angular*(.d.ts|.d.mts|.js|.mjs)',
|
|
|
|
|
from: /@tanstack\/angular-query-v5/g,
|
|
|
|
|
to: '@tanstack/angular-query-experimental',
|
|
|
|
|
});
|