Include react and react-dom as external dependencies (#24843)

Signed-off-by: Jon Koops <jonkoops@gmail.com>
This commit is contained in:
Jon Koops 2023-11-20 17:34:03 +01:00 committed by GitHub
parent 87ed656685
commit 62d5eb0965
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 823 additions and 125 deletions

View file

@ -49,7 +49,7 @@ jobs:
- name: Build Keycloak - name: Build Keycloak
run: | run: |
./mvnw clean install --batch-mode --errors -DskipTests -DskipTestsuite -DskipExamples -DskipAccount2 -DskipCommon -Pdistribution ./mvnw clean install --batch-mode --errors -DskipTests -DskipTestsuite -DskipExamples -DskipAccount2 -Pdistribution
mv ./quarkus/dist/target/keycloak-999.0.0-SNAPSHOT.tar.gz ./keycloak-999.0.0-SNAPSHOT.tar.gz mv ./quarkus/dist/target/keycloak-999.0.0-SNAPSHOT.tar.gz ./keycloak-999.0.0-SNAPSHOT.tar.gz
- name: Upload Keycloak dist - name: Upload Keycloak dist

View file

@ -90,7 +90,19 @@
</replacement> </replacement>
<replacement> <replacement>
<token><![CDATA[<title>Keycloak account console</title>]]></token> <token><![CDATA[<title>Keycloak account console</title>]]></token>
<value xml:space="preserve"><![CDATA[<title>${properties.title!"Keycloak account console"}</title>]]></value> <value xml:space="preserve">
<![CDATA[
<title>${properties.title!"Keycloak account console"}</title>
<script type="importmap">
{
"imports": {
"react": "${resourceCommonUrl}/vendor/react/react.production.min.js",
"react/jsx-runtime": "${resourceCommonUrl}/vendor/react/react-jsx-runtime.production.min.js",
"react-dom": "${resourceCommonUrl}/vendor/react-dom/react-dom.production.min.js"
}
}
</script>
]]></value>
</replacement> </replacement>
<replacement> <replacement>
<token><![CDATA[</body>]]></token> <token><![CDATA[</body>]]></token>

View file

@ -13,6 +13,9 @@ export default defineConfig({
target: "esnext", target: "esnext",
modulePreload: false, modulePreload: false,
cssMinify: "lightningcss", cssMinify: "lightningcss",
rollupOptions: {
external: ["react", "react/jsx-runtime", "react-dom"],
},
}, },
plugins: [react(), checker({ typescript: true })], plugins: [react(), checker({ typescript: true })],
}); });

View file

@ -132,7 +132,19 @@
</replacement> </replacement>
<replacement> <replacement>
<token><![CDATA[<title>Keycloak Administration UI</title>]]></token> <token><![CDATA[<title>Keycloak Administration UI</title>]]></token>
<value xml:space="preserve"><![CDATA[<title>${properties.title!"Keycloak Administration UI"}</title>]]></value> <value xml:space="preserve">
<![CDATA[
<title>${properties.title!"Keycloak Administration UI"}</title>
<script type="importmap">
{
"imports": {
"react": "${resourceCommonUrl}/vendor/react/react.production.min.js",
"react/jsx-runtime": "${resourceCommonUrl}/vendor/react/react-jsx-runtime.production.min.js",
"react-dom": "${resourceCommonUrl}/vendor/react-dom/react-dom.production.min.js"
}
}
</script>
]]></value>
</replacement> </replacement>
<replacement> <replacement>
<token><![CDATA[</body>]]></token> <token><![CDATA[</body>]]></token>

View file

@ -13,6 +13,9 @@ export default defineConfig({
target: "esnext", target: "esnext",
modulePreload: false, modulePreload: false,
cssMinify: "lightningcss", cssMinify: "lightningcss",
rollupOptions: {
external: ["react", "react/jsx-runtime", "react-dom"],
},
}, },
plugins: [react(), checker({ typescript: true })], plugins: [react(), checker({ typescript: true })],
test: { test: {

1
themes/.gitignore vendored
View file

@ -1 +1,2 @@
web_modules web_modules
vendor

View file

@ -207,6 +207,16 @@
<workingDirectory>${dir.common}</workingDirectory> <workingDirectory>${dir.common}</workingDirectory>
</configuration> </configuration>
</execution> </execution>
<execution>
<id>pnpm-build-common</id>
<goals>
<goal>pnpm</goal>
</goals>
<configuration>
<arguments>run build</arguments>
<workingDirectory>${dir.common}</workingDirectory>
</configuration>
</execution>
</executions> </executions>
</plugin> </plugin>
</plugins> </plugins>

View file

@ -1,12 +1,23 @@
{ {
"name": "keycloak-npm-dependencies", "name": "keycloak-npm-dependencies",
"version": "1.0.0", "type": "module",
"description": "Keycloak NPM Dependencies", "scripts": {
"license": "Apache-2.0", "build": "pnpm build:clean && rollup --config",
"repository": "https://github.com/keycloak/keycloak", "build:clean": "shx rm -rf vendor"
},
"dependencies": { "dependencies": {
"jquery": "^3.7.1", "jquery": "^3.7.1",
"patternfly": "^3.59.5" "patternfly": "^3.59.5",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}, },
"packageManager": "pnpm@8.10.0" "packageManager": "pnpm@8.10.0",
"devDependencies": {
"@rollup/plugin-commonjs": "^25.0.7",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-replace": "^5.0.5",
"@rollup/plugin-terser": "^0.4.4",
"rollup": "^4.5.0",
"shx": "^0.3.4"
}
} }

View file

@ -0,0 +1,40 @@
import { defineConfig } from "rollup";
import { nodeResolve } from "@rollup/plugin-node-resolve";
import commonjs from "@rollup/plugin-commonjs";
import replace from "@rollup/plugin-replace";
import terser from "@rollup/plugin-terser";
const plugins = [
nodeResolve(),
commonjs(),
replace({
preventAssignment: true,
// React depends on process.env.NODE_ENV to determine which code to include for production.
// This ensures that no additional code meant for development is included in the build.
"process.env.NODE_ENV": JSON.stringify("production"),
}),
terser(),
];
export default defineConfig([
{
input: [
"node_modules/react/cjs/react.production.min.js",
"node_modules/react/cjs/react-jsx-runtime.production.min.js",
],
output: {
dir: "vendor/react",
format: "es",
},
plugins,
},
{
input: "node_modules/react-dom/cjs/react-dom.production.min.js",
output: {
dir: "vendor/react-dom",
format: "es",
},
external: ["react"],
plugins,
},
]);