Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat!: typescript configuration and jest v29 upgrade #429

Merged
merged 130 commits into from
Apr 19, 2024
Merged
Show file tree
Hide file tree
Changes from 123 commits
Commits
Show all changes
130 commits
Select commit Hold shift + click to select a range
2fab543
fix: update the README to trigger alpha release (#335)
adamstankiewicz Apr 13, 2023
12dfae5
Merge pull request #336 from openedx/master
edx-requirements-bot Apr 14, 2023
8e64e9e
feat: Re-enable typescript for production builds
marlonkeating Apr 14, 2023
cd1e726
fix(deps): update dependency cssnano to v6 (#344)
renovate[bot] Apr 25, 2023
4b5d84a
fix(deps): update dependency html-webpack-plugin to v5.5.1
renovate[bot] Apr 25, 2023
200a8ac
fix(deps): update dependency postcss to v8.4.23
renovate[bot] Apr 25, 2023
177d154
fix(deps): update dependency webpack-cli to v5.0.2
renovate[bot] Apr 25, 2023
2af8b42
fix(deps): update dependency webpack-dev-server to v4.13.3
renovate[bot] Apr 25, 2023
0edf13f
fix(deps): update dependency sass to v1.62.1
renovate[bot] Apr 26, 2023
9908041
fix: disable dot rule in historyApiFallback in webpack.dev.config.js …
adamstankiewicz May 2, 2023
602b7a0
fix(deps): update eslint (#351)
renovate[bot] May 4, 2023
357334c
fix(deps): update dependency clean-webpack-plugin to v4 (#341)
renovate[bot] May 4, 2023
1c81573
fix(deps): update dependency @svgr/webpack to v7 (#340)
renovate[bot] May 4, 2023
e298637
fix(deps): update babel monorepo
renovate[bot] May 4, 2023
68457f1
fix(deps): update dependency cssnano to v6.0.1
renovate[bot] May 4, 2023
0519c40
fix(deps): update dependency webpack to v5.82.0 (#355)
renovate[bot] May 5, 2023
5500920
fix(deps): update dependency dotenv-webpack to v8 (#357)
renovate[bot] May 5, 2023
632a667
fix(deps): update dependency postcss-loader to v7 (#358)
renovate[bot] May 5, 2023
4a5d559
chore(deps): update dependency typescript to v5 (#338)
renovate[bot] May 5, 2023
5e4f2c2
chore(deps): update peter-evans/enable-pull-request-automerge action …
renovate[bot] May 5, 2023
1dcd666
fix(deps): update dependency @edx/new-relic-source-map-webpack-plugin…
renovate[bot] May 5, 2023
30887b1
fix(deps): update dependency postcss-rtlcss to v4 (#359)
renovate[bot] May 5, 2023
70b01a5
fix(deps): update dependency @svgr/webpack to v8 (#364)
renovate[bot] May 26, 2023
fa974a3
fix(deps): update dependency webpack-cli to v5.1.1 (#363)
renovate[bot] May 26, 2023
0e20e2b
fix(deps): update dependency postcss-loader to v7.3.1 (#367)
renovate[bot] May 26, 2023
d7d790c
fix(deps): update dependency webpack-dev-server to v4.15.0 (#362)
renovate[bot] May 26, 2023
e05d46b
fix(deps): update dependency eslint to v8.41.0 (#361)
renovate[bot] May 26, 2023
23954c4
fix(deps): update dependency style-loader to v3.3.3 (#368)
renovate[bot] May 26, 2023
a105af8
fix(deps): update dependency sass-loader to v13 (#360)
renovate[bot] May 26, 2023
1980b75
fix(deps): update dependency webpack-merge to v5.9.0 (#371)
renovate[bot] May 26, 2023
8df0d32
fix(deps): update dependency webpack to v5.84.1 (#370)
renovate[bot] May 26, 2023
6931415
fix(deps): update dependency @edx/new-relic-source-map-webpack-plugin…
renovate[bot] May 26, 2023
37313b2
fix(deps): update dependency postcss-loader to v7.3.2
renovate[bot] May 28, 2023
d3a4c0f
fix(deps): update dependency postcss to v8.4.24
renovate[bot] May 28, 2023
93a04eb
fix(deps): update dependency sass-loader to v13.3.1
renovate[bot] May 28, 2023
3a6db3f
fix(deps): update dependency webpack-cli to v5.1.2
renovate[bot] Jun 4, 2023
b6169a8
fix(deps): update dependency webpack-cli to v5.1.3
renovate[bot] Jun 4, 2023
b759a41
fix(deps): update dependency webpack-cli to v5.1.4
renovate[bot] Jun 7, 2023
10c56c1
fix(deps): update dependency webpack to v5.86.0 (#376)
renovate[bot] Jun 8, 2023
d52a18a
fix(deps): update dependency sass to v1.63.2 (#382)
renovate[bot] Jun 8, 2023
54c1f51
fix(deps): update dependency webpack-bundle-analyzer to v4.9.0 (#377)
renovate[bot] Jun 9, 2023
5e4658d
fix(deps): update babel monorepo to v7.22.5 (#372)
renovate[bot] Jun 9, 2023
466e4a0
fix(deps): update eslint (#378)
renovate[bot] Jun 9, 2023
8e0f7e4
fix(deps): update dependency html-webpack-plugin to v5.5.2
renovate[bot] Jun 9, 2023
97d45e7
fix(deps): update dependency sass to v1.63.3
renovate[bot] Jun 9, 2023
f37b842
fix(deps): update dependency webpack-dev-server to v4.15.1
renovate[bot] Jun 9, 2023
d10c1c6
fix(deps): update dependency sass-loader to v13.3.2
renovate[bot] Jun 10, 2023
8a88f62
fix(deps): update dependency postcss-loader to v7.3.3
renovate[bot] Jun 10, 2023
733ea4f
fix(deps): update dependency html-webpack-plugin to v5.5.3
renovate[bot] Jun 10, 2023
4241f47
fix(deps): update dependency postcss-custom-media to v9.1.4
renovate[bot] Jun 13, 2023
0cb6885
chore(deps): update react monorepo
renovate[bot] Jun 13, 2023
6ca555f
fix(deps): update dependency sharp to v0.32.1
renovate[bot] Jun 13, 2023
488686d
fix(deps): update dependency sass to v1.63.4
renovate[bot] Jun 14, 2023
8674978
chore(deps): update actions/setup-node action to v3 (#396)
renovate[bot] Jun 22, 2023
05edd10
chore(deps): update actions/checkout action to v3 (#395)
renovate[bot] Jun 22, 2023
c07fa91
fix(deps): update dependency image-minimizer-webpack-plugin to v3.8.3
renovate[bot] Jun 22, 2023
5b86133
fix(deps): update dependency postcss-custom-media to v9.1.5
renovate[bot] Jun 22, 2023
69899aa
fix(deps): update dependency sass to v1.63.6
renovate[bot] Jun 22, 2023
06eee29
fix(deps): update eslint (#402)
renovate[bot] Jul 6, 2023
ee71d3e
fix(deps): update dependency postcss to v8.4.25
renovate[bot] Jul 6, 2023
71ee361
fix(deps): update dependency babel-loader to v9.1.3
renovate[bot] Jul 7, 2023
cc50692
fix: updated jest to resolve word-wrap ReDoS vulnerability (#411)
BilalQamar95 Jul 11, 2023
3299605
fix(deps): update dependency sharp to v0.32.2
renovate[bot] Jul 11, 2023
64fe89f
fix: bump semver from 5.7.1 to 5.7.2 (#414)
dependabot[bot] Jul 12, 2023
85b3c54
fix(deps): update dependency @babel/eslint-parser to v7.22.9
renovate[bot] Jul 12, 2023
909fd27
fix(deps): update dependency postcss to v8.4.26
renovate[bot] Jul 13, 2023
b28e6bc
fix(deps): update dependency sharp to v0.32.3
renovate[bot] Jul 14, 2023
a5c307b
fix(deps): update dependency webpack to v5.88.1 (#403)
renovate[bot] Jul 17, 2023
cd408cd
fix(deps): update dependency webpack to v5.88.2
renovate[bot] Jul 18, 2023
088793c
feat: add fedx-scripts serve (#404)
adamstankiewicz Jul 18, 2023
a49ad49
fix(deps): update dependency postcss-custom-media to v9.1.5
renovate[bot] Jul 18, 2023
012c4ee
fix(deps): update dependency sharp to v0.32.3
renovate[bot] Jul 18, 2023
bbf58fe
fix: ensure .env.development PORT works (#423)
adamstankiewicz Jul 18, 2023
2529a1e
fix: silence sass compiler warnings (#425)
adamstankiewicz Jul 19, 2023
589b78e
fix: reverted jest upgrade (#427)
BilalQamar95 Jul 25, 2023
ca26dca
fix: update webpack common config to fix errors (#428)
solababs Aug 2, 2023
6245a84
feat: Re-enable typescript for production builds
marlonkeating Apr 14, 2023
536bff7
Merge pull request #431 from openedx/bw/alpha_to_master
muselesscreator Aug 7, 2023
deacfed
fix: remove tsconfig for commitlint job
muselesscreator Aug 7, 2023
3b8f66a
fix: fis jest config for ts-jest access
muselesscreator Aug 7, 2023
a0f24df
fix: remove extraneous dependency
muselesscreator Aug 7, 2023
efed83d
Merge pull request #430 from openedx/bw/alpha_bump
muselesscreator Aug 7, 2023
b682f25
fix: install ts-jest as dev dependency to ensure winds up in consumin…
muselesscreator Aug 7, 2023
73ec49a
Merge pull request #432 from openedx/bw/alpha_ts_jest
muselesscreator Aug 7, 2023
4f794d2
fix: revert ts jest transform back to imported one
muselesscreator Aug 7, 2023
d67776d
Merge pull request #434 from openedx/bw/alpha_jest_config
muselesscreator Aug 8, 2023
c756d4d
fix: make ts-jest a dependency to try and ensure it makes it to consu…
muselesscreator Aug 8, 2023
709e3d1
chore: use static versions
muselesscreator Aug 8, 2023
8e7e068
Merge pull request #435 from openedx/bw/alpha_jest_config
muselesscreator Aug 8, 2023
7fbbe26
fix(deps): update eslint (#351)
renovate[bot] May 4, 2023
66d1f43
fix(deps): update dependency @svgr/webpack to v7 (#340)
renovate[bot] May 4, 2023
7cbdcaa
chore(deps): update dependency typescript to v5 (#338)
renovate[bot] May 5, 2023
2040f67
fix: updated jest to resolve word-wrap ReDoS vulnerability (#411)
BilalQamar95 Jul 11, 2023
e56ef6e
feat: add fedx-scripts serve (#404)
adamstankiewicz Jul 18, 2023
4e456e3
fix(deps): update dependency sharp to v0.32.3
renovate[bot] Jul 18, 2023
dd0a21f
fix: reverted jest upgrade (#427)
BilalQamar95 Jul 25, 2023
5e9de99
fix(deps): update dependency sass to v1.65.1 (#426)
renovate[bot] Aug 15, 2023
e8136dc
fix(deps): update dependency postcss-custom-media to v10 (#407)
renovate[bot] Aug 15, 2023
26c67bb
chore(deps): update dependency @types/react to v17.0.64
renovate[bot] Aug 15, 2023
b3f6406
fix(deps): update dependency @pmmmwh/react-refresh-webpack-plugin to …
renovate[bot] Aug 15, 2023
8dec2ba
fix(deps): update dependency autoprefixer to v10.4.15
renovate[bot] Aug 15, 2023
5e1f332
fix(deps): update dependency postcss to v8.4.27
renovate[bot] Aug 15, 2023
b351065
fix(deps): update dependency postcss-rtlcss to v4.0.7
renovate[bot] Aug 15, 2023
6986459
fix(deps): update dependency sharp to v0.32.4
renovate[bot] Aug 15, 2023
04068a7
fix(deps): update dependency postcss to v8.4.28
renovate[bot] Aug 15, 2023
edb8de8
fix(deps): update dependency sharp to v0.32.5
renovate[bot] Aug 16, 2023
4b0b1fb
feat: Re-enable typescript for production builds
marlonkeating Apr 14, 2023
0020ea0
fix: updated jest to resolve word-wrap ReDoS vulnerability (#411)
BilalQamar95 Jul 11, 2023
3926fa2
fix(deps): update dependency sharp to v0.32.2
renovate[bot] Jul 11, 2023
5a61aa6
feat: add fedx-scripts serve (#404)
adamstankiewicz Jul 18, 2023
5bf2fa2
fix: reverted jest upgrade (#427)
BilalQamar95 Jul 25, 2023
c2aaff8
feat: Re-enable typescript for production builds
marlonkeating Apr 14, 2023
9ea50a6
fix: install ts-jest as dev dependency to ensure winds up in consumin…
muselesscreator Aug 7, 2023
4c98ab5
fix: make ts-jest a dependency to try and ensure it makes it to consu…
muselesscreator Aug 8, 2023
3d6ee96
Merge pull request #449 from openedx/bw/alpha_master
muselesscreator Aug 31, 2023
06e1b86
fix: package rebase
muselesscreator Aug 31, 2023
ccb91a3
Merge branch 'master' into alpha
muselesscreator Aug 31, 2023
861a040
Merge remote-tracking branch 'origin/master' into alpha
muselesscreator Aug 31, 2023
4c76eb5
Merge pull request #450 from openedx/master
edx-requirements-bot Sep 6, 2023
a1bb895
feat: sync alhpa with master (#520)
abdullahwaheed Mar 19, 2024
bd87fa6
Merge branch 'master' of github.com:openedx/frontend-build into alpha
abdullahwaheed Mar 19, 2024
5779e9f
Merge pull request #521 from openedx/master
edx-requirements-bot Mar 20, 2024
c6372b7
feat!: updated jest to v29 (#415)
BilalQamar95 Mar 20, 2024
caa1ff7
refactor: updated eslint-config
BilalQamar95 Mar 27, 2024
088ada9
Merge branch 'master' of https://github.com/openedx/frontend-build in…
BilalQamar95 Apr 5, 2024
f325dca
refactor: updated eslint-config
BilalQamar95 Apr 5, 2024
4ba4acf
refactor: updated tsconfig to resolve parsing error
BilalQamar95 Apr 5, 2024
11d1cab
Merge pull request #530 from openedx/bilalqamar95/alpha-eslint-update
abdullahwaheed Apr 5, 2024
2c4ef22
Merge pull request #524 from openedx/master
edx-requirements-bot Apr 5, 2024
3dfca7d
refactor: Readme and workflow updates (#532)
BilalQamar95 Apr 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,14 @@ on:

jobs:
commitlint:
uses: openedx/.github/.github/workflows/commitlint.yml@master
runs-on: ubuntu-20.04
steps:
- name: Check out repository
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: remove tsconfig.json # see issue https://github.com/conventional-changelog/commitlint/issues/3256
run: |
rm tsconfig.json
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're not going to need this, going forward. See this comment on a Paragon PR: openedx/paragon#2867 (comment)

- name: Check commits
uses: wagoid/commitlint-github-action@v5
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,25 @@ locally. To serve a production build locally:
attempt to run the build on the same port specified in the
`env.config.js` file.

## Local module configuration for TypeScript

#. Create file in repository `tsconfig.json`, with a clause `"extends": "@openedx/frontend-build"`
#. Set "rootDir" to the root of the source code folders
#. Set "include" to wildcard patterns specifying the subdirectories/files under rootDir where source code can be found
#. Include any wildcards under rootDir that should be excluded using "exclude"

```Sample json
{
"extends": "@openedx/frontend-build",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're actually extending @edx/typescript-config in the tsconfig in this repo. Should we not recommend doing the same elsewhere?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, it might be good to recommend setting outDir, because I found in openedx/paragon#3016 that if you extend @edx/typescript-config but don't set outDir, when you run tsc the files will get output to ./node_modules/@edx/typescript-config/dist/ - which is not that different from sending them to /dev/null. Most people won't be running tsc (rather webpack, babel, etc.) but if they do this heads up will save them some time trying to figure out why the output is not showing up.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like we're actually extending @edx/typescript-config in the tsconfig in this repo. Should we not recommend doing the same elsewhere?

@arbrandes I believe the original intent for recommending @openedx/frontend-build here was that there might be MFE-specific additions/updates we want in the base TS config available to MFEs that don't make sense in the upstream @edx/typescript-config (which, in theory, could be used for more beyond just MFEs).

For example, the base ESLint config provided to MFEs via frontend-build extends @edx/eslint-config, but slightly differs. This approach to extend @openedx/frontend-build was largely following that paradigm.

That said, if supporting MFE-only TypeScript config isn't necessary (which is probably isn't; I don't really see legacy UI repos like edx-platform adopting TypeScript anytime soon), I agree recommending to extend @edx/typescript-config directly makes more sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I've always wondered why typescript-config and eslint-config existed. Personally, I'd prefer to just consolidate them into frontend-build or frontend-platform.

"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"include": ["src/**/*"],
"exclude": ["dist", "node_modules"]
}
```

## Development

This project leverages the command line interface for webpack, jest,
Expand Down
3 changes: 2 additions & 1 deletion config/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@ const { babel } = require('../lib/presets');

module.exports = {
extends: '@edx/eslint-config',
parser: '@babel/eslint-parser',
plugins: ['@typescript-eslint'],
parser: '@typescript-eslint/parser',
parserOptions: {
requireConfigFile: true,
babelOptions: {
Expand Down
9 changes: 7 additions & 2 deletions config/jest.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const path = require('path');
const fs = require('fs');
const { jsWithTs: tsjPreset } = require('ts-jest/presets');

const presets = require('../lib/presets');

Expand All @@ -11,7 +12,10 @@ if (fs.existsSync(appEnvConfigPath)) {
}

module.exports = {
testURL: 'http://localhost/',
testEnvironment: 'jsdom',
testEnvironmentOptions: {
url: 'http://localhost/',
},
setupFiles: [
path.resolve(__dirname, 'jest/setupTest.js'),
],
Expand All @@ -33,11 +37,12 @@ module.exports = {
'/node_modules/(?!@(open)?edx)',
],
transform: {
'^.+\\.[t|j]sx?$': [
'^.+\\.jsx?$': [
'babel-jest',
{
configFile: presets.babel.resolvedFilepath,
},
],
...tsjPreset.transform,
},
};
2 changes: 1 addition & 1 deletion config/webpack.common.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ module.exports = {
// the application being built.
'env.config': false,
},
extensions: ['.js', '.jsx'],
extensions: ['.js', '.jsx', '.ts', '.tsx'],
},
ignoreWarnings: [
// Ignore warnings raised by source-map-loader.
Expand Down
4 changes: 2 additions & 2 deletions config/webpack.prod.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,12 +70,12 @@ module.exports = merge(commonConfig, {
// The babel-loader transforms newer ES2015+ syntax to older ES5 for older browsers.
// Babel is configured with the .babelrc file at the root of the project.
{
test: /\.(js|jsx)$/,
test: /\.(js|jsx|ts|tsx)$/,
exclude: /node_modules\/(?!@(open)?edx)/,
use: {
loader: 'babel-loader',
options: {
configFile: presets.babel.resolvedFilepath,
configFile: presets['babel-typescript'].resolvedFilepath,
},
},
},
Expand Down
3 changes: 3 additions & 0 deletions example/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import config from 'env.config';
import Image from './Image';
import appleUrl, { ReactComponent as Apple } from './apple.svg';
import appleImg from './apple.jpg';

Expand All @@ -19,6 +20,8 @@ export default function App() {
</ul>
<h2>JSX parsing tests</h2>
<Apple style={{ width: '10rem' }} />
<h2>TSX parsing tests</h2>
<Image src={appleUrl} alt="appleFromTsx" style={{ width: '10rem' }} />
<h2>Asset import tests</h2>
<img src={appleUrl} alt="apple" style={{ width: '10rem' }} />
<img src={appleUrl} alt="apple" style={{ width: '10rem' }} />
Expand Down
16 changes: 16 additions & 0 deletions example/src/Image.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React, { CSSProperties } from 'react';

type ImageProps = {
src: string;
alt?: string;
style?: CSSProperties;
};

const Image = ({ alt, ...rest }:ImageProps) => <img alt={alt} {...rest} />;

const defaultProps = {
alt: undefined,
style: undefined,
};
Image.defaultProps = defaultProps;
export default Image;
20 changes: 16 additions & 4 deletions example/src/__snapshots__/App.test.jsx.snap
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,19 @@ exports[`Basic test should render 1`] = `
</h2>
<IconMock
style={
Object {
{
"width": "10rem",
}
}
/>
<h2>
TSX parsing tests
</h2>
<img
alt="appleFromTsx"
src="icon/mock/path"
style={
{
"width": "10rem",
}
}
Expand All @@ -46,7 +58,7 @@ exports[`Basic test should render 1`] = `
alt="apple"
src="icon/mock/path"
style={
Object {
{
"width": "10rem",
}
}
Expand All @@ -55,7 +67,7 @@ exports[`Basic test should render 1`] = `
alt="apple"
src="icon/mock/path"
style={
Object {
{
"width": "10rem",
}
}
Expand All @@ -65,7 +77,7 @@ exports[`Basic test should render 1`] = `
alt="apple"
src="test-file-stub"
style={
Object {
{
"width": "10rem",
}
}
Expand Down
16 changes: 16 additions & 0 deletions example/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"extends": "../tsconfig.json",
arbrandes marked this conversation as resolved.
Show resolved Hide resolved
"compilerOptions": {
"rootDir": ".",
"outDir": "dist"
},
"include": [
".eslintrc.js",
"env.config.js",
"src"
],
"exclude": [
"node_modules",
"dist",
]
}
Loading
Loading