Skip to content

Commit 6ae2eb7

Browse files
Merge pull request #642 from openedx/master
sync: master to alpha
2 parents a4747f0 + 3c80898 commit 6ae2eb7

File tree

8 files changed

+399
-8
lines changed

8 files changed

+399
-8
lines changed

.eslintrc.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ module.exports = createConfig('eslint', {
77
'global-require': 'off',
88
'no-template-curly-in-string': 'off',
99
},
10+
ignorePatterns: ['example/**/*'],
1011
});

config/.eslintrc.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ module.exports = {
3737
'import/no-import-module-export': 'off',
3838
'react/function-component-definition': [2, { namedComponents: 'arrow-function' }],
3939
},
40+
settings: {
41+
'import/resolver': {
42+
typescript: {},
43+
},
44+
},
4045
globals: {
4146
newrelic: false,
4247
PARAGON_THEME: false,

config/webpack.common.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
1+
const fs = require('fs');
12
const path = require('path');
23
const RemoveEmptyScriptsPlugin = require('webpack-remove-empty-scripts');
4+
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');
35

46
const ParagonWebpackPlugin = require('../lib/plugins/paragon-webpack-plugin/ParagonWebpackPlugin');
57
const {
@@ -11,6 +13,14 @@ const {
1113
const paragonThemeCss = getParagonThemeCss(process.cwd());
1214
const brandThemeCss = getParagonThemeCss(process.cwd(), { isBrandOverride: true });
1315

16+
const tsconfigPath = path.resolve(process.cwd(), 'tsconfig.json');
17+
const resolvePlugins = [];
18+
19+
// Conditionally add TsconfigPathsPlugin if tsconfig.json exists
20+
if (fs.existsSync(tsconfigPath)) {
21+
resolvePlugins.push(new TsconfigPathsPlugin({ configFile: tsconfigPath }));
22+
}
23+
1424
module.exports = {
1525
entry: {
1626
app: path.resolve(process.cwd(), './src/index'),
@@ -45,6 +55,7 @@ module.exports = {
4555
'env.config': false,
4656
},
4757
extensions: ['.js', '.jsx', '.ts', '.tsx'],
58+
plugins: resolvePlugins,
4859
},
4960
optimization: {
5061
splitChunks: {
@@ -59,7 +70,6 @@ module.exports = {
5970
// RemoveEmptyScriptsPlugin get rid of empty scripts generated by webpack when using mini-css-extract-plugin
6071
// This helps to clean up the final bundle application
6172
// See: https://www.npmjs.com/package/webpack-remove-empty-scripts#usage-with-mini-css-extract-plugin
62-
6373
new RemoveEmptyScriptsPlugin(),
6474
new ParagonWebpackPlugin(),
6575
],

example/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"scripts": {
77
"test": "../bin/fedx-scripts.js jest ./src",
88
"build": "../bin/fedx-scripts.js webpack",
9-
"lint": "../bin/fedx-scripts.js eslint . --ext .jsx,.js",
9+
"lint": "../bin/fedx-scripts.js eslint --ext .jsx --ext .js --ext .ts --ext .tsx",
1010
"babel": "../bin/fedx-scripts.js babel src --out-dir dist/babel --source-maps --ignore **/*.test.jsx,**/*.test.js --copy-files",
1111
"start": "../bin/fedx-scripts.js webpack-dev-server",
1212
"serve": "../bin/fedx-scripts.js serve"
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { StrictMode } from 'react';
22
import { createRoot } from 'react-dom/client';
3-
import App from './App';
3+
import App from '@src/App';
44

55
// This line is to emulate what frontend-platform does when i18n initializes.
66
// It's necessary because our stylesheet is generated with `[dir="ltr"]` as a prefix on all
@@ -9,5 +9,7 @@ import App from './App';
99
global.document.getElementsByTagName('html')[0].setAttribute('dir', 'ltr');
1010

1111
const rootContainer = document.getElementById('root');
12-
const root = createRoot(rootContainer);
13-
root.render(<StrictMode><App /></StrictMode>);
12+
if (rootContainer) {
13+
const root = createRoot(rootContainer);
14+
root.render(<StrictMode><App /></StrictMode>);
15+
}

example/tsconfig.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"extends": "../tsconfig.json",
33
"compilerOptions": {
44
"rootDir": ".",
5-
"outDir": "dist"
5+
"outDir": "dist",
6+
"paths": {
7+
"@src/*": ["./src/*"]
8+
},
69
},
710
"include": [
811
".eslintrc.js",
@@ -13,4 +16,4 @@
1316
"node_modules",
1417
"dist",
1518
]
16-
}
19+
}

0 commit comments

Comments
 (0)