Skip to content

Commit 0ea91ee

Browse files
arbrandesclaude
andcommitted
feat!: compile to JS before publishing
Configure the package to compile TypeScript and copy SCSS files 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 92208a0 commit 0ea91ee

File tree

10 files changed

+238
-16
lines changed

10 files changed

+238
-16
lines changed

.github/workflows/ci.yml

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

38+
- name: Build
39+
run: npm run build
40+
3841
- name: Run Code Coverage
3942
uses: codecov/codecov-action@v5
4043
with:

Makefile

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,19 @@ precommit:
1313
requirements:
1414
npm ci
1515

16+
clean:
17+
rm -rf dist
18+
19+
build: clean
20+
tsc --project tsconfig.build.json
21+
tsc-alias -p tsconfig.build.json
22+
find src -type f -name '*.scss' -exec sh -c '\
23+
for f in "$$@"; do \
24+
d="dist/$${f#src/}"; \
25+
mkdir -p "$$(dirname "$$d")"; \
26+
cp "$$f" "$$d"; \
27+
done' sh {} +
28+
1629
i18n.extract:
1730
# Pulling display strings from .jsx files into .json files...
1831
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: 185 additions & 7 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
@@ -9,9 +9,12 @@
99
"type": "git",
1010
"url": "git+https://github.com/openedx/frontend-app-authn.git"
1111
},
12-
"main": "src/index.ts",
12+
"exports": {
13+
".": "./dist/index.js",
14+
"./app.scss": "./dist/app.scss"
15+
},
1316
"files": [
14-
"/src"
17+
"/dist"
1518
],
1619
"browserslist": [
1720
"extends @edx/browserslist-config"
@@ -21,11 +24,14 @@
2124
"*.scss"
2225
],
2326
"scripts": {
27+
"build": "make build",
28+
"clean": "make clean",
2429
"dev": "PORT=1999 PUBLIC_PATH=/authn openedx dev",
2530
"i18n_extract": "openedx formatjs extract",
2631
"lint": "openedx lint .",
2732
"lint:fix": "openedx lint --fix .",
2833
"snapshot": "openedx test --updateSnapshot",
34+
"prepublishOnly": "npm run build",
2935
"test": "openedx test --coverage --passWithNoTests"
3036
},
3137
"author": "Open edX",
@@ -68,10 +74,11 @@
6874
"eslint-plugin-import": "2.31.0",
6975
"jest": "^29.7.0",
7076
"react-test-renderer": "^18.3.1",
71-
"ts-jest": "^29.4.0"
77+
"ts-jest": "^29.4.0",
78+
"tsc-alias": "^1.8.16"
7279
},
7380
"peerDependencies": {
74-
"@openedx/frontend-base": "^1.0.0-alpha.8",
81+
"@openedx/frontend-base": "^1.0.0-alpha.12",
7582
"@openedx/paragon": "^23",
7683
"react": "^18",
7784
"react-dom": "^18",

src/app.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
@use "@openedx/frontend-base/shell/app.scss";
2-
@use "sass/style";
2+
@use "./sass/style";

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: 4 additions & 1 deletion
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": ".",
55
"outDir": "dist",
6+
"paths": {
7+
"@src/*": ["./src/*"]
8+
},
69
},
710
"include": [
811
"src/**/*",

0 commit comments

Comments
 (0)