2022-05-04 19:10:19 +10:00
|
|
|
|
const { whenDev } = require("@craco/craco");
|
2021-09-02 12:16:40 +10:00
|
|
|
|
const CracoAlias = require("craco-alias");
|
2021-09-01 15:54:20 +10:00
|
|
|
|
const CracoSwcPlugin = require("craco-swc");
|
2022-07-18 13:57:31 +10:00
|
|
|
|
|
2021-09-01 15:54:20 +10:00
|
|
|
|
module.exports = {
|
2021-09-01 15:59:30 +10:00
|
|
|
|
plugins: [
|
2021-09-02 12:16:40 +10:00
|
|
|
|
{
|
|
|
|
|
|
plugin: CracoAlias,
|
|
|
|
|
|
options: {
|
|
|
|
|
|
source: "tsconfig",
|
|
|
|
|
|
baseUrl: "./src",
|
|
|
|
|
|
tsConfigPath: "./tsconfig.extend.json",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-05-04 19:10:19 +10:00
|
|
|
|
// Use Babel on dev since Jotai doesn’t have swc plugins yet
|
|
|
|
|
|
// See https://github.com/pmndrs/jotai/discussions/1057
|
|
|
|
|
|
// Use swc on production and test since Babel seems to break Jest
|
|
|
|
|
|
...whenDev(
|
|
|
|
|
|
() => [],
|
|
|
|
|
|
[
|
|
|
|
|
|
{
|
|
|
|
|
|
plugin: CracoSwcPlugin,
|
|
|
|
|
|
options: {
|
|
|
|
|
|
swcLoaderOptions: {
|
|
|
|
|
|
jsc: {
|
|
|
|
|
|
target: "es2021",
|
|
|
|
|
|
transform: {
|
|
|
|
|
|
react: {
|
|
|
|
|
|
runtime: "automatic",
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2021-09-01 15:59:30 +10:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-05-04 19:10:19 +10:00
|
|
|
|
]
|
|
|
|
|
|
),
|
2021-09-01 15:59:30 +10:00
|
|
|
|
],
|
2022-05-04 19:10:19 +10:00
|
|
|
|
babel: {
|
|
|
|
|
|
plugins: [
|
|
|
|
|
|
"jotai/babel/plugin-debug-label",
|
|
|
|
|
|
"./node_modules/jotai/babel/plugin-react-refresh",
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
jest: {
|
|
|
|
|
|
configure: (jestConfig) => {
|
|
|
|
|
|
jestConfig.setupFilesAfterEnv = ["./src/test/setupTests.ts"];
|
|
|
|
|
|
jestConfig.forceExit = true; // jest hangs if we don't have this
|
|
|
|
|
|
|
2022-05-10 12:15:20 +10:00
|
|
|
|
jestConfig.moduleNameMapper["lodash-es"] = "lodash";
|
|
|
|
|
|
jestConfig.moduleNameMapper["^.+\\.(css|less)$"] =
|
|
|
|
|
|
"<rootDir>/src/test/importStub.js";
|
|
|
|
|
|
jestConfig.moduleNameMapper["^!!raw-loader!.*"] =
|
|
|
|
|
|
"<rootDir>/src/test/importStub.js";
|
|
|
|
|
|
|
|
|
|
|
|
jestConfig.extensionsToTreatAsEsm = [".ts", ".tsx"];
|
|
|
|
|
|
// Need to transform node modules to prevent
|
|
|
|
|
|
// "cannot use import outside module" error
|
|
|
|
|
|
jestConfig.transformIgnorePatterns = [
|
|
|
|
|
|
// "/node_modules/",
|
|
|
|
|
|
"\\.pnp\\.[^\\/]+$",
|
|
|
|
|
|
];
|
|
|
|
|
|
|
2022-05-04 19:10:19 +10:00
|
|
|
|
return jestConfig;
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2022-05-19 16:37:56 +10:00
|
|
|
|
webpack: {
|
|
|
|
|
|
configure: {
|
|
|
|
|
|
resolve: {
|
2022-06-07 10:17:25 +10:00
|
|
|
|
// Polyfill for monaco-editor-auto-typings
|
2022-05-19 16:37:56 +10:00
|
|
|
|
fallback: {
|
2022-05-24 13:56:06 +07:00
|
|
|
|
path: require.resolve("path-browserify"),
|
2022-06-07 10:17:25 +10:00
|
|
|
|
// stream: require.resolve("stream-browserify"),
|
|
|
|
|
|
// buffer: require.resolve("buffer"),
|
2022-05-19 16:37:56 +10:00
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
|
|
|
|
|
},
|
2021-09-01 15:54:20 +10:00
|
|
|
|
};
|