More changes to fix babel and loaders

This commit is contained in:
Dummy Tester 123 2021-02-08 14:48:07 -06:00
parent ddc1caf3cf
commit 8aac241384
7 changed files with 105 additions and 24 deletions

View File

@ -5,6 +5,12 @@ packageExtensions:
'@ant-design/react-slick@*':
dependencies:
react: '*'
'unstated-next@*':
dependencies:
react: '*'
'react-scripts@*':
dependencies:
ts-loader: '*'
plugins:
- path: .yarn/plugins/@yarnpkg/plugin-workspace-tools.cjs

View File

@ -1,9 +1,46 @@
const CracoLessPlugin = require('craco-less');
const CracoExtendScope = require('@dvhb/craco-extend-scope');
const CracoAlias = require('craco-alias');
const CracoBabelLoader = require('craco-babel-loader');
const path = require('path');
const fs = require('fs');
//console.log('qualified', pnp.resolveRequest('@babel/preset-typescript'), path.resolve(__dirname, '/') + 'src/');
// Handle relative paths to sibling packages
const appDirectory = fs.realpathSync(process.cwd());
const resolvePackage = (relativePath) => path.resolve(appDirectory, relativePath);
module.exports = {
webpack: {
configure: (webpackConfig) => {
const scopePluginIndex = webpackConfig.resolve.plugins.findIndex(
({ constructor }) => constructor && constructor.name === 'ModuleScopePlugin'
);
webpackConfig.resolve.plugins.splice(scopePluginIndex, 1);
return webpackConfig;
},
},
plugins: [
{ plugin: CracoExtendScope, options: { path: '@packages' } },
{
plugin: CracoBabelLoader,
options: {
includes: [
// No "unexpected token" error importing components from these lerna siblings:
resolvePackage('../packages'),
],
},
},
{
plugin: CracoAlias,
options: {
source: 'tsconfig',
// baseUrl SHOULD be specified
// plugin does not take it from tsconfig
baseUrl: '../',
// tsConfigPath should point to the file where "baseUrl" and "paths" are specified
tsConfigPath: '../tsconfig.base.json',
},
},
{
plugin: CracoLessPlugin,
options: {

View File

@ -4,8 +4,8 @@
"dependencies": {
"@ant-design/icons": "^4.4.0",
"@ant-design/pro-layout": "^6.7.0",
"@babel/preset-typescript": "^7.12.13",
"@craco/craco": "^5.7.0",
"@dvhb/craco-extend-scope": "^1.0.1",
"@packages/common": "workspace:packages/common",
"@project-serum/serum": "^0.13.11",
"@project-serum/sol-wallet-adapter": "^0.1.4",
@ -25,6 +25,8 @@
"bs58": "^4.0.1",
"buffer-layout": "^1.2.0",
"chart.js": "^2.9.4",
"craco-alias": "^2.1.1",
"craco-babel-loader": "^0.1.4",
"craco-less": "^1.17.0",
"echarts": "^4.9.0",
"eventemitter3": "^4.0.7",
@ -40,7 +42,7 @@
"typescript": "^4.1.3"
},
"scripts": {
"start": "craco start",
"start": "craco start --verbose",
"build": "craco build",
"test": "craco test",
"eject": "react-scripts eject",

View File

@ -1,5 +1,5 @@
{
"extends": "../tsconfig.json",
"extends": "../tsconfig.base.json",
"include": [
"src"
],

View File

@ -1,9 +1,5 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "dist",
"composite": true,
"noEmit": false
},
"extends": "../../tsconfig.base.json",
"compilerOptions": {},
"include": ["src/**/*", "src/config/tokens.json"]
}

View File

@ -1333,7 +1333,7 @@ __metadata:
languageName: node
linkType: hard
"@babel/plugin-transform-typescript@npm:^7.9.0":
"@babel/plugin-transform-typescript@npm:^7.12.13, @babel/plugin-transform-typescript@npm:^7.9.0":
version: 7.12.13
resolution: "@babel/plugin-transform-typescript@npm:7.12.13"
dependencies:
@ -1573,6 +1573,19 @@ __metadata:
languageName: node
linkType: hard
"@babel/preset-typescript@npm:^7.12.13":
version: 7.12.13
resolution: "@babel/preset-typescript@npm:7.12.13"
dependencies:
"@babel/helper-plugin-utils": ^7.12.13
"@babel/helper-validator-option": ^7.12.11
"@babel/plugin-transform-typescript": ^7.12.13
peerDependencies:
"@babel/core": ^7.0.0-0
checksum: d4a8824acf588f1043c39be7057c7ab5de89473ae30d1ef394ee3c355ce2829d7b222d1c0740035e4da4f111002e7fee6c72b5d06d8f5b4b543fa79078cf790a
languageName: node
linkType: hard
"@babel/runtime-corejs3@npm:^7.10.2, @babel/runtime-corejs3@npm:^7.12.1":
version: 7.12.13
resolution: "@babel/runtime-corejs3@npm:7.12.13"
@ -1652,7 +1665,7 @@ __metadata:
languageName: node
linkType: hard
"@craco/craco@npm:^5.7.0":
"@craco/craco@npm:^5.0.0, @craco/craco@npm:^5.7.0":
version: 5.9.0
resolution: "@craco/craco@npm:5.9.0"
dependencies:
@ -1688,13 +1701,6 @@ __metadata:
languageName: node
linkType: hard
"@dvhb/craco-extend-scope@npm:^1.0.1":
version: 1.0.1
resolution: "@dvhb/craco-extend-scope@npm:1.0.1"
checksum: 545e28318d94b4a4c9b40dd79ba9278ba621217efb3938ac3364b47d631243ac3c6dc457a3c6dc308572dba59da37b537daf9690f1ac15a7c63d78f2361269b3
languageName: node
linkType: hard
"@formatjs/ecma402-abstract@npm:1.5.2":
version: 1.5.2
resolution: "@formatjs/ecma402-abstract@npm:1.5.2"
@ -5590,6 +5596,22 @@ __metadata:
languageName: node
linkType: hard
"craco-alias@npm:^2.1.1":
version: 2.1.1
resolution: "craco-alias@npm:2.1.1"
checksum: 4a7dce1eb12805c25bda5dd343ab70bdd95f9e94226e79f280a5cd3d34b0c15242843c7917a0055d0e054a41c6688ccd7065c37a8691cb70646bcd3a4b1c02a2
languageName: node
linkType: hard
"craco-babel-loader@npm:^0.1.4":
version: 0.1.4
resolution: "craco-babel-loader@npm:0.1.4"
dependencies:
"@craco/craco": ^5.0.0
checksum: 33278c1b7eeba3532aa400ee0e11370db9ce308ab57126ed06419848712cc881035b5460f0465e37c543b41a2759d3aa7b8580a7c56ad1d8b5e67970a47a7211
languageName: node
linkType: hard
"craco-less@npm:^1.17.0":
version: 1.17.1
resolution: "craco-less@npm:1.17.1"
@ -6644,7 +6666,7 @@ __metadata:
languageName: node
linkType: hard
"enhanced-resolve@npm:^4.1.0":
"enhanced-resolve@npm:^4.0.0, enhanced-resolve@npm:^4.1.0":
version: 4.5.0
resolution: "enhanced-resolve@npm:4.5.0"
dependencies:
@ -10461,8 +10483,8 @@ fsevents@~2.3.1:
dependencies:
"@ant-design/icons": ^4.4.0
"@ant-design/pro-layout": ^6.7.0
"@babel/preset-typescript": ^7.12.13
"@craco/craco": ^5.7.0
"@dvhb/craco-extend-scope": ^1.0.1
"@packages/common": "workspace:packages/common"
"@project-serum/serum": ^0.13.11
"@project-serum/sol-wallet-adapter": ^0.1.4
@ -10490,6 +10512,8 @@ fsevents@~2.3.1:
bs58: ^4.0.1
buffer-layout: ^1.2.0
chart.js: ^2.9.4
craco-alias: ^2.1.1
craco-babel-loader: ^0.1.4
craco-less: ^1.17.0
echarts: ^4.9.0
eventemitter3: ^4.0.7
@ -11098,7 +11122,7 @@ fsevents@~2.3.1:
languageName: node
linkType: hard
"micromatch@npm:^4.0.2":
"micromatch@npm:^4.0.0, micromatch@npm:^4.0.2":
version: 4.0.2
resolution: "micromatch@npm:4.0.2"
dependencies:
@ -15438,7 +15462,7 @@ resolve@1.15.0:
languageName: node
linkType: hard
"semver@npm:^7.1.2, semver@npm:^7.3.2":
"semver@npm:^7.1.2, semver@npm:^7.3.2, semver@npm:^7.3.4":
version: 7.3.4
resolution: "semver@npm:7.3.4"
dependencies:
@ -16710,6 +16734,22 @@ resolve@1.15.0:
languageName: node
linkType: hard
"ts-loader@npm:*":
version: 8.0.15
resolution: "ts-loader@npm:8.0.15"
dependencies:
chalk: ^4.1.0
enhanced-resolve: ^4.0.0
loader-utils: ^2.0.0
micromatch: ^4.0.0
semver: ^7.3.4
peerDependencies:
typescript: "*"
webpack: "*"
checksum: bf47ef147ae56af9d4e1c3ed2eb43815c850ed04524a4b2043b5f679fd92859016323521a76c62bea42391242da9dd1da8dd0e5ec8f7158e6206b9d97ff90b43
languageName: node
linkType: hard
"ts-pnp@npm:1.1.6":
version: 1.1.6
resolution: "ts-pnp@npm:1.1.6"