Skip to content

Commit 5b70c59

Browse files
committed
feat: Force build before publishing
To avoid the common mistake of publishing before building, add `npm run build` to the `prepack` stage. This takes care of building before both `npm publish` and `npm pack`. Also rename the pack/nodemon npm scripts for consistency.
1 parent e7d135b commit 5b70c59

6 files changed

Lines changed: 18 additions & 14 deletions

File tree

.github/workflows/ci.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,7 @@ jobs:
2323
- name: Install dependencies
2424
run: |
2525
npm ci
26-
npm run build
27-
npm run pack:local
26+
npm run pack
2827
cd test-site
2928
npm i ../pack/openedx-frontend-base.tgz
3029
npm ci

docs/decisions/0010-typescript-compilation-and-local-dev-workflow.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -121,8 +121,8 @@ Local development workflow
121121
To develop a local dependency (e.g., ``@openedx/frontend-base``) against a
122122
consuming project:
123123

124-
1. In the dependency: ``npm run build`` (or use a watcher like ``nodemon`` with
125-
``npm run pack:local``)
124+
1. In the dependency: ``npm run pack`` (or use a watcher like ``nodemon`` with
125+
``npm run pack:watch``)
126126
2. In the consumer: install from the tarball and run the dev server (or use the
127127
`autoinstall tool`_ from the ``frontend-dev-utils`` package)
128128

docs/how_tos/migrate-frontend-app.md

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,10 +129,12 @@ With the exception of any custom scripts, replace the `scripts` section of your
129129
```json
130130
"scripts": {
131131
"build": "make build",
132+
"clean": "make clean",
132133
"dev": "PORT=YOUR_PORT PUBLIC_PATH=/YOUR_APP_NAME openedx dev",
133134
"i18n_extract": "openedx formatjs extract",
134135
"lint": "openedx lint .",
135136
"lint:fix": "openedx lint --fix .",
137+
"prepack": "npm run build",
136138
"snapshot": "openedx test --updateSnapshot",
137139
"test": "openedx test --coverage --passWithNoTests"
138140
},
@@ -154,10 +156,13 @@ Also:
154156
> **Why change `fedx-scripts` to `openedx`?**
155157
> A few reasons. One, the Open edX project shouldn't be using the name of an internal community of practice at edX for its frontend tooling. Two, some dependencies of your MFE invariably still use frontend-build for their own build needs. This means that they already installed `fedx-scripts` into your `node_modules/.bin` folder. Only one version can be in there, so we need a new name. Seemed like a great time for a naming refresh. |
156158
157-
Last but not least, add a `build:` target to your `Makefile`. This target compiles TypeScript to JavaScript, uses `tsc-alias` to rewrite `@src` path aliases to relative paths, and copies all SCSS files from `src/` into `dist/` preserving directory structure:
159+
Last but not least, add `clean:` and `build:` targets to your `Makefile`. The build target compiles TypeScript to JavaScript, uses `tsc-alias` to rewrite `@src` path aliases to relative paths, and copies all SCSS files from `src/` into `dist/` preserving directory structure:
158160

159161
```makefile
160-
build:
162+
clean:
163+
rm -rf dist
164+
165+
build: clean
161166
tsc --project tsconfig.build.json
162167
tsc-alias -p tsconfig.build.json
163168
find src -type f -name '*.scss' -exec sh -c '\

nodemon.pack.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,5 +3,5 @@
33
"ext": "ts,tsx,js,jsx,json,scss,css",
44
"ignore": ["node_modules/**", ".git/**", "pack/**"],
55
"delay": "250ms",
6-
"exec": "npm run build:pack"
6+
"exec": "npm run pack"
77
}

package.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@
2828
"docs:watch": "nodemon -w runtime -w docs/template -w README.md -e js,jsx,ts,tsx --exec npm run docs",
2929
"lint": "eslint .; npm run lint:tools; npm --prefix ./test-site run lint",
3030
"lint:tools": "cd ./tools && eslint . && cd ..",
31-
"test": "jest",
32-
"pack:local": "mkdir -p pack && npm pack --silent --pack-destination pack >/dev/null && mv \"$(ls -t pack/*.tgz | head -n 1)\" pack/openedx-frontend-base.tgz",
33-
"build:pack": "make build && npm run pack:local",
34-
"dev:pack": "nodemon --config nodemon.pack.json"
31+
"pack": "mkdir -p pack && npm pack --silent --pack-destination pack >/dev/null && mv \"$(ls -t pack/*.tgz | head -n 1)\" pack/openedx-frontend-base.tgz",
32+
"pack:watch": "nodemon --config nodemon.pack.json",
33+
"prepack": "npm run build",
34+
"test": "jest"
3535
},
3636
"repository": {
3737
"type": "git",

test-site/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
"main": "src/index.jsx",
66
"scripts": {
77
"build": "openedx build",
8-
"lint": "openedx lint .",
98
"dev": "openedx dev",
10-
"serve": "openedx serve",
11-
"dev:autoinstall": "node ./tools/autoinstall/dev-with-autoinstall.mjs"
9+
"dev:autoinstall": "node ./tools/autoinstall/dev-with-autoinstall.mjs",
10+
"lint": "openedx lint .",
11+
"serve": "openedx serve"
1212
},
1313
"keywords": [],
1414
"author": "Open edX Community",

0 commit comments

Comments
 (0)