Skip to content

Commit

Permalink
Merge branch 'dev' into task/TUI-388--creating-a-tapis-ui-AE-label-data
Browse files Browse the repository at this point in the history
  • Loading branch information
nathandf authored Jul 9, 2024
2 parents 34f909b + 1fd221f commit 6849411
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 7 deletions.
3 changes: 2 additions & 1 deletion lib/icicle-tapisui-extension/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"outDir": "dist",
"lib": ["dom", "esnext", "dom.iterable"],
"types": ["node"],
"typeRoots": ["./types", "node_modules/@types"]
"typeRoots": ["./types", "node_modules/@types"],
"incremental": true
},
"include": ["src"],
"exclude": ["node_modules", "dist", "bundle.ts", "tasks.ts"]
Expand Down
3 changes: 2 additions & 1 deletion lib/tapisui-api/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"jsx": "react-jsx"
"jsx": "react-jsx",
"incremental": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
Expand Down
3 changes: 2 additions & 1 deletion lib/tapisui-common/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"isolatedModules": true,
"noEmit": false,
"types": ["node"],
"outDir": "./dist"
"outDir": "./dist",
"incremental": true
},
"exclude": [
"dist",
Expand Down
3 changes: 2 additions & 1 deletion lib/tapisui-extensions-core/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"outDir": "dist",
"lib": ["es6", "dom"],
"types": ["node"],
"typeRoots": ["./types", "node_modules/@types"]
"typeRoots": ["./types", "node_modules/@types"],
"incremental": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
Expand Down
3 changes: 2 additions & 1 deletion lib/tapisui-hooks/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": false,
"jsx": "react-jsx"
"jsx": "react-jsx",
"incremental": true
},
"include": ["src"],
"exclude": ["node_modules", "dist"]
Expand Down
7 changes: 5 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
"homepage": "https://tapis-project.github.io/tapis-ui",
"scripts": {
"start": "vite --config ./vite/vite.local.config.mts",
"dev": "npm run watcher & npm run start",
"deploy": "vite --config ./vite/vite.config.mts",
"build": "tsc && vite build",
"build": "tsc && vite build --config ./vite/vite.config.mts",
"watcher": "node ./scripts/watcher.js",
"preview": "vite preview",
"test": "chmod +x ./scripts/test-all.sh && ./scripts/test-all.sh",
"lint": "eslint --max-warnings=0 . && prettier --single-quote --check src",
Expand Down Expand Up @@ -112,7 +114,8 @@
"path": "^0.12.7",
"prettier": "^2.3.2",
"ts-jest": "^29.1.4",
"typescript": "^5.5.3"
"chokidar": "^3.6.0",
"typescript": "^5.4.5"
},
"jest": {
"globals": {
Expand Down
52 changes: 52 additions & 0 deletions scripts/watcher.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* Watcher which triggers incremental build for select libs via tsx
* Also copies changed css/scss files to the dist folder when needed
* All for hot-reloading. Run `npm run watcher` alongside `npm run start` to enable.
* **npm runs could be combined, idk how though ;)
*/
const chokidar = require('chokidar');
const { exec } = require('child_process');
const fs = require('fs');
const path = require('path');

const libsToWatch = [
'lib/tapisui-hooks',
'lib/tapisui-common',
'lib/tapisui-extensions-core',
'lib/tapisui-api',
'lib/icicle-tapisui-extension',
// Add other libraries you want watched and rebuilt here
];

libsToWatch.forEach((libPath) => {
console.log(`Watching: ${libPath}`);
const watcher = chokidar.watch(`${libPath}/src`, { ignoreInitial: true });

watcher.on('all', (event, filePath) => {
if (filePath.endsWith('.css') || filePath.endsWith('.scss')) {
// Handle CSS and SCSS files separately
const destPath = filePath.replace('/src/', '/dist/');
fs.copyFile(filePath, destPath, (err) => {
if (err) {
console.error(`Error copying file ${filePath}: ${err}`);
return;
}
console.log(`Copying: ${filePath}`);
});
} else {
// rebuild is incremental due to the lib/libname/tsconfig.json > compilerOptions
// > incremental: true, meaning only changed files are recompiled
console.log(`Rebuilding: ${libPath}`);
exec(
`cd ${libPath} && npx tsc --build ./tsconfig.json`,
(error, stdout, stderr) => {
if (error) {
console.error(`Error rebuilding ${libPath}: ${error}\n${stdout}`);
return;
}
console.log(`Changed: ${filePath}`);
}
);
}
});
});

0 comments on commit 6849411

Please sign in to comment.