Skip to content
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

Unbundle preact #989

Draft
wants to merge 11 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions .babelrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"plugins": [
[ "@babel/plugin-transform-react-jsx", {
"importSource": "preact",
"runtime": "automatic"
} ],
"inline-react-svg",
[ "module-resolver", {
"alias": {
"react": "preact/compat",
"react-dom": "preact/compat"
}
} ]
]
}
1 change: 0 additions & 1 deletion .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ jobs:
integration: [ true ]
integration-deps:
- [email protected] [email protected]
- "@bpmn-io/properties-panel@3"
include:
- integration-deps: "" # as defined in package.json
integration: false
Expand Down
46 changes: 4 additions & 42 deletions karma.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

const path = require('path');
const {
DefinePlugin,
NormalModuleReplacementPlugin
DefinePlugin
} = require('webpack');

const basePath = '.';
Expand Down Expand Up @@ -73,24 +72,15 @@ module.exports = function(karma) {
use: {
loader: 'babel-loader',
options: {
plugins: [
[ '@babel/plugin-transform-react-jsx', {
'importSource': '@bpmn-io/properties-panel/preact',
'runtime': 'automatic'
} ]
].concat(coverage ? [
plugins: coverage ? [
[ 'istanbul', {
include: [
'lib/**'
]
} ]
] : [])
] : []
}
}
},
{
test: /\.svg$/,
use: [ 'react-svg-loader' ]
}
]
},
Expand All @@ -99,42 +89,14 @@ module.exports = function(karma) {

// @barmac: process.env has to be defined to make @testing-library/preact work
'process.env': {}
}),
new NormalModuleReplacementPlugin(
/^preact(\/[^/]+)?$/,
function(resource) {

const replMap = {
'preact/hooks': path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js'),
'preact/jsx-runtime': path.resolve('node_modules/@bpmn-io/properties-panel/preact/jsx-runtime/dist/jsxRuntime.module.js'),
'preact': path.resolve('node_modules/@bpmn-io/properties-panel/preact/dist/preact.module.js')
};

const replacement = replMap[resource.request];

if (!replacement) {
return;
}

resource.request = replacement;
}
),
new NormalModuleReplacementPlugin(
/^preact\/hooks/,
path.resolve('node_modules/@bpmn-io/properties-panel/preact/hooks/dist/hooks.module.js')
)
})
],
resolve: {
mainFields: [
'browser',
'module',
'main'
],
alias: {
'preact': '@bpmn-io/properties-panel/preact',
'react': '@bpmn-io/properties-panel/preact/compat',
'react-dom': '@bpmn-io/properties-panel/preact/compat'
},
modules: [
'node_modules',
absoluteBasePath
Expand Down
Loading