-
Notifications
You must be signed in to change notification settings - Fork 172
Upgrade CRACO to v7.1.0 & react-scripts to v5.0.1 #2376
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
Merged
Merged
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
b4c7714
Update CRACO from v6.4.5 to v7.1.0
ianyong dda38cf
Update react-scripts from v4.0.3 to v5.0.1
ianyong a2de210
Remove selective dependency resolution of react-error-overlay
ianyong 6c42838
Remove duplicate ESLint installation - favour CRA's
ianyong 5d5663e
Enable old WebAssembly in Webpack 5
ianyong ca7f8de
Regenerate dependency tree
ianyong 37d7bb3
Force use of React 17 types instead of 18
ianyong 29fbfdc
Polyfill Node.js core modules
ianyong 58126d7
Ignore missing source map warnings for dependencies
ianyong 8116eea
Polyfill 'process' for environment variables to work
ianyong 0ea6fd8
Polyfill 'buffer' for the application to work in the browser
ianyong a5bba33
Move polyfill libraries to dev dependencies
ianyong 32c6f1e
Update test snapshots
ianyong 6982c11
Merge branch 'master' into upgrade-craco-and-react-scripts
ianyong File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
// eslint-disable-next-line @typescript-eslint/no-var-requires | ||
const webpack = require('webpack'); | ||
|
||
const cracoConfig = (module.exports = { | ||
webpack: { | ||
configure: webpackConfig => { | ||
|
@@ -19,26 +22,61 @@ const cracoConfig = (module.exports = { | |
} | ||
|
||
// add rules to pack WASM (for Sourceror) | ||
// adapted from https://prestonrichey.com/blog/react-rust-wasm/ | ||
const wasmExtensionRegExp = /\.wasm$/; | ||
webpackConfig.resolve.extensions.push('.wasm'); | ||
webpackConfig.module.rules.forEach(rule => { | ||
(rule.oneOf || []).forEach(oneOf => { | ||
if (oneOf.loader && oneOf.loader.indexOf('file-loader') >= 0) { | ||
// Make file-loader ignore WASM files | ||
if (oneOf.type === 'asset/resource') { | ||
oneOf.exclude.push(wasmExtensionRegExp); | ||
} | ||
}); | ||
}); | ||
// See https://webpack.js.org/configuration/experiments/#experiments. | ||
webpackConfig.experiments = { | ||
syncWebAssembly: true | ||
}; | ||
webpackConfig.output.webassemblyModuleFilename = 'static/[hash].module.wasm'; | ||
|
||
// Polyfill Node.js core modules. | ||
// An empty implementation (false) is provided when there is no browser equivalent. | ||
webpackConfig.resolve.fallback = { | ||
'child_process': false, | ||
'constants': require.resolve('constants-browserify'), | ||
'fs': false, | ||
'http': require.resolve('stream-http'), | ||
'https': require.resolve('https-browserify'), | ||
'os': require.resolve('os-browserify/browser'), | ||
'stream': require.resolve('stream-browserify'), | ||
'timers': require.resolve('timers-browserify'), | ||
'url': require.resolve('url/') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The trailing slash was part of the instructions given by Webpack. I'm not very sure if removing it will cause any errors. |
||
}; | ||
|
||
// workaround .mjs files by Acorn | ||
webpackConfig.module.rules.push({ | ||
test: /\.mjs$/, | ||
include: /node_modules/, | ||
type: 'javascript/auto' | ||
}); | ||
|
||
// Ignore warnings for dependencies that do not ship with a source map. | ||
// This is because we cannot do anything about our dependencies. | ||
webpackConfig.ignoreWarnings = [{ | ||
module: /node_modules/, | ||
message: /Failed to parse source map/ | ||
}]; | ||
|
||
webpackConfig.plugins = [ | ||
...webpackConfig.plugins, | ||
// Make environment variables available in the browser by polyfilling the 'process' Node.js module. | ||
new webpack.ProvidePlugin({ | ||
process: 'process/browser', | ||
}), | ||
// Make the 'buffer' Node.js module available in the browser. | ||
new webpack.ProvidePlugin({ | ||
Buffer: ['buffer', 'Buffer'], | ||
}) | ||
]; | ||
|
||
return webpackConfig; | ||
} | ||
}, | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
240 changes: 120 additions & 120 deletions
240
src/commons/assessment/__tests__/__snapshots__/Assessment.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
556 changes: 278 additions & 278 deletions
556
src/commons/assessmentWorkspace/__tests__/__snapshots__/AssessmentWorkspace.tsx.snap
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We cannot use ES6 imports for config files.