Skip to content

Commit d21f0f6

Browse files
committed
chore: resolve icons via babel
1 parent 79729fd commit d21f0f6

File tree

5 files changed

+607
-53
lines changed

5 files changed

+607
-53
lines changed

.babelrc.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{
2+
"plugins": [
3+
[ "@babel/plugin-transform-react-jsx", {
4+
"importSource": "preact",
5+
"runtime": "automatic"
6+
} ],
7+
"inline-react-svg",
8+
[ "module-resolver", {
9+
"alias": {
10+
"react": "preact/compat",
11+
"react-dom": "preact/compat"
12+
}
13+
} ]
14+
]
15+
}

karma.config.js

Lines changed: 4 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
const path = require('path');
44
const {
5-
DefinePlugin,
6-
NormalModuleReplacementPlugin
5+
DefinePlugin
76
} = require('webpack');
87

98
const basePath = '.';
@@ -73,18 +72,13 @@ module.exports = function(karma) {
7372
use: {
7473
loader: 'babel-loader',
7574
options: {
76-
plugins: [
77-
[ '@babel/plugin-transform-react-jsx', {
78-
'importSource': '@bpmn-io/properties-panel/preact',
79-
'runtime': 'automatic'
80-
} ]
81-
].concat(coverage ? [
75+
plugins: coverage ? [
8276
[ 'istanbul', {
8377
include: [
8478
'lib/**'
8579
]
8680
} ]
87-
] : [])
81+
] : []
8882
}
8983
}
9084
},
@@ -99,42 +93,14 @@ module.exports = function(karma) {
9993

10094
// @barmac: process.env has to be defined to make @testing-library/preact work
10195
'process.env': {}
102-
}),
103-
new NormalModuleReplacementPlugin(
104-
/^preact(\/[^/]+)?$/,
105-
function(resource) {
106-
107-
const replMap = {
108-
'preact/hooks': path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js'),
109-
'preact/jsx-runtime': path.resolve('node_modules/@bpmn-io/properties-panel/preact/jsx-runtime/dist/jsxRuntime.module.js'),
110-
'preact': path.resolve('node_modules/@bpmn-io/properties-panel/preact/dist/preact.module.js')
111-
};
112-
113-
const replacement = replMap[resource.request];
114-
115-
if (!replacement) {
116-
return;
117-
}
118-
119-
resource.request = replacement;
120-
}
121-
),
122-
new NormalModuleReplacementPlugin(
123-
/^preact\/hooks/,
124-
path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js')
125-
)
96+
})
12697
],
12798
resolve: {
12899
mainFields: [
129100
'browser',
130101
'module',
131102
'main'
132103
],
133-
alias: {
134-
'preact': '@bpmn-io/properties-panel/preact',
135-
'react': '@bpmn-io/properties-panel/preact/compat',
136-
'react-dom': '@bpmn-io/properties-panel/preact/compat'
137-
},
138104
modules: [
139105
'node_modules',
140106
absoluteBasePath

0 commit comments

Comments
 (0)