web: migrate to babel

Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
Jens Langhammer 2021-04-03 18:20:17 +02:00
parent 82c2a202cb
commit 650b084c72
7 changed files with 1416 additions and 46 deletions

View File

@ -13,7 +13,7 @@
<link rel="stylesheet" type="text/css" href="{% static 'dist/patternfly.min.css' %}?v={{ ak_version }}"> <link rel="stylesheet" type="text/css" href="{% static 'dist/patternfly.min.css' %}?v={{ ak_version }}">
<link rel="stylesheet" type="text/css" href="{% static 'dist/authentik.css' %}?v={{ ak_version }}"> <link rel="stylesheet" type="text/css" href="{% static 'dist/authentik.css' %}?v={{ ak_version }}">
<script src="{% url 'authentik_api:javascript-catalog' %}?v={{ ak_version }}"></script> <script src="{% url 'authentik_api:javascript-catalog' %}?v={{ ak_version }}"></script>
<script src="{% static 'dist/adoptedStyleSheets.js' %}?v={{ ak_version }}" type="module"></script> <script src="{% static 'dist/poly.js' %}?v={{ ak_version }}" type="module"></script>
{% block head %} {% block head %}
{% endblock %} {% endblock %}
</head> </head>

26
web/.babelrc Normal file
View File

@ -0,0 +1,26 @@
{
"presets": [
"@babel/env",
"@babel/typescript"
],
"plugins": [
[
"@babel/plugin-proposal-decorators",
{
"decoratorsBeforeExport": true
}
],
[
"@babel/plugin-proposal-class-properties",
{
"loose": true
}
],
[
"@babel/plugin-transform-runtime",
{
"regenerator": true
}
]
]
}

1390
web/package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -10,10 +10,15 @@
"lit-analyse": "lit-analyzer src" "lit-analyse": "lit-analyzer src"
}, },
"dependencies": { "dependencies": {
"@babel/core": "^7.13.14",
"@babel/plugin-proposal-decorators": "^7.13.5",
"@babel/preset-env": "^7.13.12",
"@babel/preset-typescript": "^7.13.0",
"@fortawesome/fontawesome-free": "^5.15.3", "@fortawesome/fontawesome-free": "^5.15.3",
"@patternfly/patternfly": "^4.96.2", "@patternfly/patternfly": "^4.96.2",
"@polymer/iron-form": "^3.0.1", "@polymer/iron-form": "^3.0.1",
"@polymer/paper-input": "^3.2.1", "@polymer/paper-input": "^3.2.1",
"@rollup/plugin-babel": "^5.3.0",
"@sentry/browser": "^6.2.5", "@sentry/browser": "^6.2.5",
"@sentry/tracing": "^6.2.5", "@sentry/tracing": "^6.2.5",
"@types/chart.js": "^2.9.31", "@types/chart.js": "^2.9.31",
@ -37,6 +42,7 @@
"yaml": "^1.10.2" "yaml": "^1.10.2"
}, },
"devDependencies": { "devDependencies": {
"@babel/plugin-transform-runtime": "^7.13.10",
"@rollup/plugin-typescript": "^8.2.1", "@rollup/plugin-typescript": "^8.2.1",
"@typescript-eslint/eslint-plugin": "^4.20.0", "@typescript-eslint/eslint-plugin": "^4.20.0",
"@typescript-eslint/parser": "^4.20.0", "@typescript-eslint/parser": "^4.20.0",

View File

@ -6,6 +6,11 @@ import typescript from "@rollup/plugin-typescript";
import cssimport from "rollup-plugin-cssimport"; import cssimport from "rollup-plugin-cssimport";
import copy from "rollup-plugin-copy"; import copy from "rollup-plugin-copy";
import externalGlobals from "rollup-plugin-external-globals"; import externalGlobals from "rollup-plugin-external-globals";
import babel from '@rollup/plugin-babel';
const extensions = [
'.js', '.jsx', '.ts', '.tsx',
];
const resources = [ const resources = [
{ src: "node_modules/rapidoc/dist/rapidoc-min.js", dest: "dist/" }, { src: "node_modules/rapidoc/dist/rapidoc-min.js", dest: "dist/" },
@ -67,20 +72,15 @@ export default [
], ],
output: [ output: [
{ {
format: "es", format: "iife",
dir: "dist", file: "dist/poly.js",
sourcemap: true, sourcemap: true,
} }
], ],
plugins: [ plugins: [
cssimport(), cssimport(),
typescript(),
externalGlobals({
django: "django",
}),
resolve({ browser: true }), resolve({ browser: true }),
commonjs(), commonjs(),
sourcemaps(),
isProdBuild && terser(), isProdBuild && terser(),
].filter(p => p), ].filter(p => p),
watch: { watch: {
@ -100,12 +100,16 @@ export default [
], ],
plugins: [ plugins: [
cssimport(), cssimport(),
typescript(), resolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: 'runtime',
include: ['src/**/*'],
}),
externalGlobals({ externalGlobals({
django: "django", django: "django",
}), }),
resolve({ browser: true }),
commonjs(),
sourcemaps(), sourcemaps(),
isProdBuild && terser(), isProdBuild && terser(),
].filter(p => p), ].filter(p => p),
@ -127,12 +131,16 @@ export default [
], ],
plugins: [ plugins: [
cssimport(), cssimport(),
typescript(), resolve({ extensions, browser: true }),
commonjs(),
babel({
extensions,
babelHelpers: 'runtime',
include: ['src/**/*'],
}),
externalGlobals({ externalGlobals({
django: "django" django: "django"
}), }),
resolve({ browser: true }),
commonjs(),
sourcemaps(), sourcemaps(),
isProdBuild && terser(), isProdBuild && terser(),
].filter(p => p), ].filter(p => p),

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css"> <link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
<link rel="stylesheet" type="text/css" href="/static/dist/authentik.css"> <link rel="stylesheet" type="text/css" href="/static/dist/authentik.css">
<script src="/api/jsi18n/"></script> <script src="/api/jsi18n/"></script>
<script src="/static/dist/adoptedStyleSheets.js" type="module"></script> <script src="/static/dist/poly.js" type="module"></script>
<script src="/static/dist/AdminInterface.js" type="module"></script> <script src="/static/dist/AdminInterface.js" type="module"></script>
<title>authentik</title> <title>authentik</title>
</head> </head>

View File

@ -8,7 +8,7 @@
<link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css"> <link rel="stylesheet" type="text/css" href="/static/dist/patternfly-base.css">
<link rel="stylesheet" type="text/css" href="/static/dist/authentik.css"> <link rel="stylesheet" type="text/css" href="/static/dist/authentik.css">
<script src="/api/jsi18n/"></script> <script src="/api/jsi18n/"></script>
<script src="/static/dist/adoptedStyleSheets.js" type="module"></script> <script src="/static/dist/poly.js" type="module"></script>
<script src="/static/dist/FlowInterface.js" type="module"></script> <script src="/static/dist/FlowInterface.js" type="module"></script>
<title>authentik</title> <title>authentik</title>
</head> </head>