@@ -179,185 +179,4 @@ const replaceSlashes = target => {
179179 return target . replaceAll ( '/' , '[/\\\\]' ) ;
180180} ;
181181
182- module . exports = cracoConfig ; /* eslint-disable @typescript-eslint/no-require-imports */
183- const webpack = require ( 'webpack' ) ;
184-
185- const cracoConfig = {
186- webpack : {
187- configure : webpackConfig => {
188- // avoid the entire process.env being inserted into the service worker
189- // if SW_EXCLUDE_REGEXES is unset
190- const definePlugin = webpackConfig . plugins . find (
191- plugin => plugin . constructor . name === 'DefinePlugin'
192- ) ;
193- const inlineProcessEnv = definePlugin . definitions [ 'process.env' ] ;
194- if ( ! inlineProcessEnv . REACT_APP_SW_EXCLUDE_REGEXES ) {
195- inlineProcessEnv . REACT_APP_SW_EXCLUDE_REGEXES = undefined ;
196- }
197-
198- const injectManifestPlugin = webpackConfig . plugins . find (
199- plugin => plugin . constructor . name === 'InjectManifest'
200- ) ;
201- if ( injectManifestPlugin ) {
202- injectManifestPlugin . config . maximumFileSizeToCacheInBytes = 20 * 1024 * 1024 ;
203- }
204-
205- // add rules to pack WASM (for Sourceror)
206- const wasmExtensionRegExp = / \. w a s m $ / ;
207- webpackConfig . resolve . extensions . push ( '.wasm' ) ;
208- webpackConfig . module . rules . forEach ( rule => {
209- ( rule . oneOf || [ ] ) . forEach ( oneOf => {
210- if ( oneOf . type === 'asset/resource' ) {
211- oneOf . exclude . push ( wasmExtensionRegExp ) ;
212- }
213- } ) ;
214- } ) ;
215- // See https://webpack.js.org/configuration/experiments/#experiments.
216- webpackConfig . experiments = {
217- syncWebAssembly : true
218- } ;
219- webpackConfig . output . webassemblyModuleFilename = 'static/[hash].module.wasm' ;
220-
221- // Polyfill Node.js core modules.
222- // An empty implementation (false) is provided when there is no browser equivalent.
223- webpackConfig . resolve . fallback = {
224- 'child_process' : false ,
225- 'constants' : require . resolve ( 'constants-browserify' ) ,
226- 'fs' : false ,
227- 'http' : require . resolve ( 'stream-http' ) ,
228- 'https' : require . resolve ( 'https-browserify' ) ,
229- 'os' : require . resolve ( 'os-browserify/browser' ) ,
230- 'path/posix' : require . resolve ( 'path-browserify' ) ,
231- 'process/browser' : require . resolve ( 'process/browser' ) ,
232- 'stream' : require . resolve ( 'stream-browserify' ) ,
233- 'timers' : require . resolve ( 'timers-browserify' ) ,
234- 'url' : require . resolve ( 'url/' ) ,
235- } ;
236-
237- // workaround .mjs files by Acorn
238- webpackConfig . module . rules . push ( {
239- test : / \. m j s $ / ,
240- include : / n o d e _ m o d u l e s / ,
241- type : 'javascript/auto' ,
242- resolve : {
243- fullySpecified : false
244- } ,
245- } ) ;
246-
247- webpackConfig . ignoreWarnings = [ {
248- // Ignore warnings for dependencies that do not ship with a source map.
249- // This is because we cannot do anything about our dependencies.
250- module : / n o d e _ m o d u l e s / ,
251- message : / F a i l e d t o p a r s e s o u r c e m a p /
252- } , {
253- // Ignore the warnings that occur because js-slang uses dynamic imports
254- // to load Source modules
255- module : / j s - s l a n g \/ d i s t \/ m o d u l e s \/ l o a d e r \/ l o a d e r s .j s / ,
256- message : / C r i t i c a l d e p e n d e n c y : t h e r e q u e s t o f a d e p e n d e n c y i s a n e x p r e s s i o n /
257- } ] ;
258-
259- webpackConfig . plugins = [
260- ...webpackConfig . plugins ,
261- // Make environment variables available in the browser by polyfilling the 'process' Node.js module.
262- new webpack . ProvidePlugin ( {
263- process : 'process/browser' ,
264- } ) ,
265- // Make the 'buffer' Node.js module available in the browser.
266- new webpack . ProvidePlugin ( {
267- Buffer : [ 'buffer' , 'Buffer' ] ,
268- } ) ,
269- ] ;
270-
271- // Workaround to suppress warnings caused by ts-morph in js-slang
272- webpackConfig . module . noParse = / n o d e _ m o d u l e s \/ @ t s - m o r p h \/ c o m m o n \/ d i s t \/ t y p e s c r i p t \. j s $ / ;
273-
274- return webpackConfig ;
275- }
276- } ,
277- jest : {
278- configure : jestConfig => {
279- jestConfig . transformIgnorePatterns = [
280- // Will give something like
281- // '[/\\\\]node_modules[/\\\\]
282- // (?!
283- // ( @ion-phaser[/\\\\]react[/\\\\.*] )|
284- // ( js-slang[/\\\\.*] )|
285- // ( array-move[/\\\\.*] )|
286- // ...
287- // ( comma-separated-tokens[/\\\\.*] )
288- // ).*.(js|jsx|ts|tsx)$'
289- ignoreModulePaths (
290- '@ion-phaser/react' ,
291- 'js-slang' ,
292- 'array-move' ,
293- 'konva' ,
294- 'react-konva' ,
295- 'react-debounce-render' ,
296- 'devlop' ,
297- 'hastscript' ,
298- 'hast-to-hyperscript' ,
299- 'hast-util-.+' ,
300- 'mdast-util-.+' ,
301- 'micromark' ,
302- 'micromark-.+' ,
303- 'vfile' ,
304- 'vfile-message' ,
305- 'unist-util-.+' ,
306- 'web-namespaces' ,
307- 'rehype-react' ,
308- 'unified' ,
309- 'bail' ,
310- 'is-plain-obj' ,
311- 'trough' ,
312- 'decode-named-character-reference' ,
313- 'character-entities' ,
314- 'trim-lines' ,
315- 'property-information' ,
316- 'space-separated-tokens' ,
317- 'comma-separated-tokens' ,
318- 'query-string' ,
319- 'decode-uri-component' ,
320- 'split-on-first' ,
321- 'filter-obj' ,
322- '@sourceacademy/c-slang' ,
323- 'java-parser' ,
324- 'conductor'
325- ) ,
326- '^.+\\.module\\.(css|sass|scss)$'
327- ] ;
328- jestConfig . moduleNameMapper [ 'unist-util-visit-parents/do-not-use-color' ] =
329- '<rootDir>/node_modules/unist-util-visit-parents/lib' ;
330- jestConfig . moduleNameMapper [ 'vfile/do-not-use-conditional-minpath' ] =
331- '<rootDir>/node_modules/vfile/lib' ;
332- jestConfig . moduleNameMapper [ 'vfile/do-not-use-conditional-minproc' ] =
333- '<rootDir>/node_modules/vfile/lib' ;
334- jestConfig . moduleNameMapper [ 'vfile/do-not-use-conditional-minurl' ] =
335- '<rootDir>/node_modules/vfile/lib' ;
336-
337- jestConfig . setupFiles = [
338- ...jestConfig . setupFiles ,
339- './src/i18n/i18n.ts' // Setup i18next configuration
340- ]
341- return jestConfig ;
342- }
343- } ,
344- babel : {
345- presets : [
346- [ '@babel/preset-typescript' ]
347- ]
348- }
349- }
350-
351- const ignoreModulePaths = ( ...paths ) => {
352- const moduleRoot = replaceSlashes ( '/node_modules/' ) ;
353- const modulePaths = paths
354- . map ( replaceSlashes )
355- . map ( path => `(${ path } [/\\\\.*])` )
356- . join ( '|' ) ;
357- return moduleRoot + '(?!' + modulePaths + ').*.(js|jsx|ts|tsx)$' ;
358- } ;
359- const replaceSlashes = target => {
360- return target . replaceAll ( '/' , '[/\\\\]' ) ;
361- } ;
362-
363182module . exports = cracoConfig ;
0 commit comments