Skip to content

Commit

Permalink
Fix start scripts (#1053)
Browse files Browse the repository at this point in the history
* Rename cjs-package.mjs to package-cjs.mjs

* package-cjs to create dir if needed

* Move scripts around start script continues to work in watch mode

* rush change
  • Loading branch information
GerardasB authored Sep 27, 2024
1 parent ef5c8ca commit ebf8b59
Show file tree
Hide file tree
Showing 10 changed files with 54 additions and 11 deletions.
4 changes: 2 additions & 2 deletions apps/test-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
"homepage": "http://localhost:3000/",
"scripts": {
"build": "npm run build:backend && npm run build:frontend",
"build:backend": "tsc -p tsconfig.backend.json && npm run build:backend:post",
"build:backend:post": "node ../../common/scripts/cjs-package.mjs ./lib",
"build:backend": "npm run package:cjs && tsc -p tsconfig.backend.json",
"build:frontend": "npm run copy:webfont && npm run pseudolocalize && vite build",
"package:cjs": "node ../../common/scripts/package-cjs.mjs ./lib",
"preview": "vite preview --port 3000",
"clean": "rimraf lib build dist .rush/temp/package-deps*.json",
"electron": "run-p start:webserver start:electron",
Expand Down
10 changes: 10 additions & 0 deletions common/changes/@itwin/appui-react/fix-start_2024-09-27-08-21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/appui-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/appui-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/components-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/components-react"
}
10 changes: 10 additions & 0 deletions common/changes/@itwin/core-react/fix-start_2024-09-27-08-21.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/core-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/core-react"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"changes": [
{
"packageName": "@itwin/imodel-components-react",
"comment": "",
"type": "none"
}
],
"packageName": "@itwin/imodel-components-react"
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ const packageDir = path.join(process.cwd(), relativeDir);
const filePath = path.join(packageDir, "package.json");

try {
fs.writeFileSync(filePath, '{ "type": "commonjs" }');
if (!fs.existsSync(packageDir)) {
fs.mkdirSync(packageDir, { recursive: true });
}
fs.writeFileSync(filePath, '{ "type": "commonjs" }', {});
} catch (e) {
console.error("Cannot create package.json", e);
}
4 changes: 2 additions & 2 deletions ui/appui-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"scripts": {
"start": "run-p -l \"build:** -- -w\" \"copy:** -- -w\"",
"build": "npm run -s copy:locale && npm run -s build:cjs && npm run -s build:esm",
"build:cjs": "npm run -s copy:cjs && tsc -p tsconfig.cjs.json && npm run -s build:cjs:post",
"build:cjs:post": "node ../../common/scripts/cjs-package.mjs ./lib/cjs",
"build:cjs": "npm run -s copy:cjs && npm run -s package:cjs && tsc -p tsconfig.cjs.json",
"build:esm": "npm run -s copy:esm && tsc -p tsconfig.esm.json",
"package:cjs": "node ../../common/scripts/package-cjs.mjs ./lib/cjs",
"copy:cjs": "cpx \"./src/**/*.{*css,json,svg}\" \"./lib/cjs\"",
"copy:esm": "cpx \"./src/**/*.{*css,json,svg}\" \"./lib/esm\"",
"copy:locale": "cpx ./src/appui-react/UiFramework.json ./lib/public/locales/en",
Expand Down
4 changes: 2 additions & 2 deletions ui/components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"scripts": {
"start": "run-p -l \"build:** -- -w\" \"copy:** -- -w\"",
"build": "npm run -s copy:locale && npm run -s build:cjs && npm run -s build:esm",
"build:cjs": "npm run -s copy:cjs && tsc 1>&2 --outDir lib/cjs && npm run -s build:cjs:post",
"build:cjs:post": "node ../../common/scripts/cjs-package.mjs ./lib/cjs",
"build:cjs": "npm run -s copy:cjs && npm run -s package:cjs && tsc 1>&2 --outDir lib/cjs",
"build:esm": "npm run -s copy:esm && tsc 1>&2 --module ES2020 --outDir lib/esm",
"package:cjs": "node ../../common/scripts/package-cjs.mjs ./lib/cjs",
"copy:cjs": "cpx \"./src/**/*.*css\" ./lib/cjs",
"copy:esm": "cpx \"./src/**/*.*css\" ./lib/esm",
"copy:locale": "cpx ./src/components-react/UiComponents.json ./lib/public/locales/en",
Expand Down
4 changes: 2 additions & 2 deletions ui/core-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"scripts": {
"start": "run-p -l \"build:** -- -w\" \"copy:** -- -w\"",
"build": "npm run -s copy:locale && npm run -s build:cjs && npm run -s build:esm",
"build:cjs": "npm run -s copy:cjs && tsc 1>&2 --outDir lib/cjs && npm run -s build:cjs:post",
"build:cjs:post": "node ../../common/scripts/cjs-package.mjs ./lib/cjs",
"build:cjs": "npm run -s copy:cjs && npm run -s package:cjs && tsc 1>&2 --outDir lib/cjs",
"build:esm": "npm run -s copy:esm && tsc 1>&2 --module ES2020 --outDir lib/esm",
"package:cjs": "node ../../common/scripts/package-cjs.mjs ./lib/cjs",
"copy:cjs": "cpx \"./src/**/*.{*css,svg}\" ./lib/cjs",
"copy:esm": "cpx \"./src/**/*.{*css,svg}\" ./lib/esm",
"copy:locale": "cpx ./src/core-react/UiCore.json ./lib/public/locales/en",
Expand Down
4 changes: 2 additions & 2 deletions ui/imodel-components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@
"scripts": {
"start": "run-p -l \"build:** -- -w\" \"copy:** -- -w\"",
"build": "npm run -s copy:locale && npm run -s build:cjs && npm run -s build:esm",
"build:cjs": "npm run -s copy:cjs && tsc 1>&2 --outDir lib/cjs && npm run -s build:cjs:post",
"build:cjs:post": "node ../../common/scripts/cjs-package.mjs ./lib/cjs",
"build:cjs": "npm run -s copy:cjs && npm run -s package:cjs && tsc 1>&2 --outDir lib/cjs",
"build:esm": "npm run -s copy:esm && tsc 1>&2 --module ES2020 --outDir lib/esm",
"package:cjs": "node ../../common/scripts/package-cjs.mjs ./lib/cjs",
"copy:cjs": "cpx \"./src/**/*.*css\" ./lib/cjs",
"copy:esm": "cpx \"./src/**/*.*css\" ./lib/esm",
"copy:locale": "cpx ./src/imodel-components-react/UiIModelComponents.json ./lib/public/locales/en",
Expand Down

0 comments on commit ebf8b59

Please sign in to comment.