Skip to content

Commit 05832dd

Browse files
arbrandesclaude
andcommitted
feat!: compile to JS before publishing
Configure the package to compile TypeScript and copy SCSS and image assets (PNG, SVG) to dist/ before publishing, rather than publishing raw source files. This allows us to use tsc-alias for @src imports. Also use a more modern export map to decouple the internal file structure from the package's API, and add a build step to CI. BREAKING CHANGE: Consuming projects may need to update their imports or SASS @use lines. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4f117df commit 05832dd

9 files changed

Lines changed: 457 additions & 1201 deletions

File tree

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ jobs:
3333
- name: Test
3434
run: npm run test
3535

36+
- name: Build
37+
run: npm run build
38+
3639
- name: Run Coverage
3740
uses: codecov/codecov-action@v5
3841
with:

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,19 @@ test.npm.%: validate-no-uncommitted-package-lock-changes
2424
requirements: ## install ci requirements
2525
npm ci
2626

27+
clean:
28+
rm -rf dist
29+
30+
build: clean
31+
tsc --project tsconfig.build.json
32+
tsc-alias -p tsconfig.build.json
33+
find src -type f \( -name '*.scss' -o -name '*.png' -o -name '*.svg' \) -exec sh -c '\
34+
for f in "$$@"; do \
35+
d="dist/$${f#src/}"; \
36+
mkdir -p "$$(dirname "$$d")"; \
37+
cp "$$f" "$$d"; \
38+
done' sh {} +
39+
2740
i18n.extract:
2841
# Pulling display strings from .jsx files into .json files...
2942
rm -rf $(transifex_temp)

babel.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
const { createConfig } = require('@openedx/frontend-base/config');
1+
const { createConfig } = require('@openedx/frontend-base/tools');
22

33
module.exports = createConfig('babel');

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// @ts-check
22

3-
const { createLintConfig } = require('@openedx/frontend-base/config');
3+
const { createLintConfig } = require('@openedx/frontend-base/tools');
44

55
module.exports = createLintConfig(
66
{

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { createConfig } = require('@openedx/frontend-base/config');
1+
const { createConfig } = require('@openedx/frontend-base/tools');
22

33
module.exports = createConfig('test', {
44
setupFilesAfterEnv: [

package-lock.json

Lines changed: 400 additions & 1192 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,16 @@
66
"type": "git",
77
"url": "git+https://github.com/edx/frontend-app-learner-dashboard.git"
88
},
9-
"main": "src/index.ts",
9+
"exports": {
10+
".": {
11+
"types": "./dist/index.d.ts",
12+
"import": "./dist/index.js",
13+
"default": "./dist/index.js"
14+
},
15+
"./app.scss": "./dist/app.scss"
16+
},
1017
"files": [
11-
"/src"
18+
"/dist"
1219
],
1320
"browserslist": [
1421
"extends @edx/browserslist-config"
@@ -18,6 +25,8 @@
1825
"*.scss"
1926
],
2027
"scripts": {
28+
"build": "make build",
29+
"clean": "make clean",
2130
"dev": "PORT=1996 PUBLIC_PATH=/learner-dashboard openedx dev",
2231
"i18n_extract": "openedx formatjs extract",
2332
"lint": "openedx lint .",
@@ -65,10 +74,11 @@
6574
"jest-when": "^3.6.0",
6675
"react-dev-utils": "^12.0.0",
6776
"react-test-renderer": "^18.3.1",
68-
"redux-mock-store": "^1.5.4"
77+
"redux-mock-store": "^1.5.4",
78+
"tsc-alias": "^1.8.16"
6979
},
7080
"peerDependencies": {
71-
"@openedx/frontend-base": "^1.0.0-alpha.11",
81+
"@openedx/frontend-base": "file:../frontend-base/pack/openedx-frontend-base.tgz",
7282
"@openedx/paragon": "^23",
7383
"@tanstack/react-query": "^5",
7484
"@types/react": "^18",

tsconfig.build.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": "./tsconfig.json",
3+
"compilerOptions": {
4+
"rootDir": "src",
5+
"outDir": "dist",
6+
"noEmit": false
7+
},
8+
"include": [
9+
"src/**/*"
10+
],
11+
"exclude": [
12+
"src/**/*.test.*",
13+
"src/**/*.spec.*",
14+
"src/**/tests/**/*",
15+
"src/__mocks__/**/*",
16+
"src/setupTest.*"
17+
]
18+
}

tsconfig.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
2-
"extends": "@openedx/frontend-base/config/tsconfig.json",
2+
"extends": "@openedx/frontend-base/tools/tsconfig.json",
33
"compilerOptions": {
44
"rootDir": ".",
5-
"outDir": "dist"
5+
"outDir": "dist",
6+
"baseUrl": ".",
7+
"paths": {
8+
"@src/*": ["./src/*"]
9+
},
610
},
711
"include": [
812
"src/**/*",

0 commit comments

Comments
 (0)