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>
This commit is contained in:
Adolfo R. Brandes
2026-02-06 13:40:16 -03:00
committed by Adolfo R. Brandes
parent 35283dfdd3
commit 70576cf373
9 changed files with 1794 additions and 2007 deletions

View File

@@ -33,6 +33,9 @@ jobs:
- name: Test
run: npm run test
- name: Build
run: npm run build
- name: Run Coverage
uses: codecov/codecov-action@v5
with:

View File

@@ -24,6 +24,19 @@ test.npm.%: validate-no-uncommitted-package-lock-changes
requirements: ## install ci requirements
npm ci
clean:
rm -rf dist
build: clean
tsc --project tsconfig.build.json
tsc-alias -p tsconfig.build.json
find src -type f \( -name '*.scss' -o -name '*.png' -o -name '*.svg' \) -exec sh -c '\
for f in "$$@"; do \
d="dist/$${f#src/}"; \
mkdir -p "$$(dirname "$$d")"; \
cp "$$f" "$$d"; \
done' sh {} +
i18n.extract:
# Pulling display strings from .jsx files into .json files...
rm -rf $(transifex_temp)

View File

@@ -1,3 +1,3 @@
const { createConfig } = require('@openedx/frontend-base/config');
const { createConfig } = require('@openedx/frontend-base/tools');
module.exports = createConfig('babel');

View File

@@ -1,6 +1,6 @@
// @ts-check
const { createLintConfig } = require('@openedx/frontend-base/config');
const { createLintConfig } = require('@openedx/frontend-base/tools');
module.exports = createLintConfig(
{

View File

@@ -1,4 +1,4 @@
const { createConfig } = require('@openedx/frontend-base/config');
const { createConfig } = require('@openedx/frontend-base/tools');
module.exports = createConfig('test', {
setupFilesAfterEnv: [

3739
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -6,9 +6,12 @@
"type": "git",
"url": "git+https://github.com/edx/frontend-app-learner-dashboard.git"
},
"main": "src/index.ts",
"exports": {
".": "./dist/index.js",
"./app.scss": "./dist/app.scss"
},
"files": [
"/src"
"/dist"
],
"browserslist": [
"extends @edx/browserslist-config"
@@ -18,10 +21,13 @@
"*.scss"
],
"scripts": {
"build": "make build",
"clean": "make clean",
"dev": "PORT=1996 PUBLIC_PATH=/learner-dashboard openedx dev",
"i18n_extract": "openedx formatjs extract",
"lint": "openedx lint .",
"lint:fix": "openedx lint --fix .",
"prepack": "npm run build",
"test": "openedx test --coverage --passWithNoTests"
},
"author": "Open edX",
@@ -65,10 +71,11 @@
"jest-when": "^3.6.0",
"react-dev-utils": "^12.0.0",
"react-test-renderer": "^18.3.1",
"redux-mock-store": "^1.5.4"
"redux-mock-store": "^1.5.4",
"tsc-alias": "^1.8.16"
},
"peerDependencies": {
"@openedx/frontend-base": "^1.0.0-alpha.11",
"@openedx/frontend-base": "^1.0.0-alpha.13",
"@openedx/paragon": "^23",
"@tanstack/react-query": "^5",
"@types/react": "^18",

18
tsconfig.build.json Normal file
View File

@@ -0,0 +1,18 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"rootDir": "src",
"outDir": "dist",
"noEmit": false
},
"include": [
"src/**/*"
],
"exclude": [
"src/**/*.test.*",
"src/**/*.spec.*",
"src/**/tests/**/*",
"src/__mocks__/**/*",
"src/setupTest.*"
]
}

View File

@@ -1,8 +1,11 @@
{
"extends": "@openedx/frontend-base/config/tsconfig.json",
"extends": "@openedx/frontend-base/tools/tsconfig.json",
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
"outDir": "dist",
"paths": {
"@src/*": ["./src/*"]
},
},
"include": [
"src/**/*",