Skip to content

Commit a447ef6

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 852444a commit a447ef6

File tree

9 files changed

+413
-1200
lines changed

9 files changed

+413
-1200
lines changed

.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: 360 additions & 1191 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@
66
"type": "git",
77
"url": "git+https://github.com/edx/frontend-app-learner-dashboard.git"
88
},
9-
"main": "src/index.ts",
9+
"exports": {
10+
".": "./dist/index.js",
11+
"./app.scss": "./dist/app.scss"
12+
},
1013
"files": [
11-
"/src"
14+
"/dist"
1215
],
1316
"browserslist": [
1417
"extends @edx/browserslist-config"
@@ -18,10 +21,13 @@
1821
"*.scss"
1922
],
2023
"scripts": {
24+
"build": "make build",
25+
"clean": "make clean",
2126
"dev": "PORT=1996 PUBLIC_PATH=/learner-dashboard openedx dev",
2227
"i18n_extract": "openedx formatjs extract",
2328
"lint": "openedx lint .",
2429
"lint:fix": "openedx lint --fix .",
30+
"prepack": "npm run build",
2531
"test": "openedx test --coverage --passWithNoTests"
2632
},
2733
"author": "Open edX",
@@ -65,10 +71,11 @@
6571
"jest-when": "^3.6.0",
6672
"react-dev-utils": "^12.0.0",
6773
"react-test-renderer": "^18.3.1",
68-
"redux-mock-store": "^1.5.4"
74+
"redux-mock-store": "^1.5.4",
75+
"tsc-alias": "^1.8.16"
6976
},
7077
"peerDependencies": {
71-
"@openedx/frontend-base": "^1.0.0-alpha.11",
78+
"@openedx/frontend-base": "^1.0.0-alpha.12",
7279
"@openedx/paragon": "^23",
7380
"@tanstack/react-query": "^5",
7481
"@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: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
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+
"paths": {
7+
"@src/*": ["./src/*"]
8+
},
69
},
710
"include": [
811
"src/**/*",

0 commit comments

Comments
 (0)