Skip to content

Commit

Permalink
Refactor typescript handling for performance fix
Browse files Browse the repository at this point in the history
Resolves: #517
  • Loading branch information
ggodlewski committed Dec 3, 2024
1 parent 71eab38 commit 2a69b40
Show file tree
Hide file tree
Showing 146 changed files with 12,448 additions and 3,046 deletions.
2 changes: 1 addition & 1 deletion .nvmrc
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20.10.0
22.10.0
8 changes: 5 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
FROM node:20-alpine
FROM node:22-bookworm-slim

ARG BUILD_UI
ARG GIT_SHA

RUN apk add --no-cache bash openssh-keygen git-lfs openssh-client
RUN apt-get update
RUN apt-get install -yq bash git-lfs openssh-client curl unzip socat
RUN curl -fsSL https://deno.land/install.sh | DENO_INSTALL=/usr/local sh
WORKDIR /usr/src/app

COPY package.json package-lock.json ./
RUN npm install
RUN npm install --location=global ts-node

RUN if [[ -z "$BUILD_UI" ]] ; then cd /usr/src/app/apps/ui && npm run build ; fi
RUN if [ -z "$BUILD_UI" ] ; then cd /usr/src/app/apps/ui && npm run build ; fi

COPY . ./
RUN npm link --location=user
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/AuthModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
</div>
</template>
<script>
import {UtilsMixin} from './UtilsMixin';
import {UtilsMixin} from './UtilsMixin.ts';
export default {
name: 'AuthModal',
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/components/BackLinks.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
</template>
<script>
import {UtilsMixin} from './UtilsMixin.ts';
import * as d3 from 'https://cdn.jsdelivr.net/npm/d3@7/+esm';
// eslint-disable-next-line import/no-unresolved
import * as d3 from 'https://cdn.jsdelivr.net/npm/d3@7/+esm.mjs';
function smartSlice(limit, arr) {
arr = Array.from(arr).map(subArr => {
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/LogsViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
import {UtilsMixin} from './UtilsMixin.ts';
import StatusToolBar from './StatusToolBar.vue';
import {Prism} from './prismFix';
import {Prism} from './prismFix.ts';
export default {
mixins: [UtilsMixin],
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/components/MarkDown.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<pre><code class="language-markdown line-numbers" ref="code"><slot></slot></code></pre>
</template>
<script lang="ts">
import {Prism} from './prismFix';
import {Prism} from './prismFix.ts';
export default {
props: ['absPath'],
Expand Down
8 changes: 4 additions & 4 deletions apps/ui/src/components/prismFix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@ const email = /\b\S+@[\w.]+[a-z]{2}/;
const linkMd = /\[([^\]]+)]\(([^)]+)\)/;

// Tokens that may contain URLs and emails
const candidates = ['comment', 'url', 'attr-value', 'string', 'front-matter'];
const candidates = ['comment', 'node:url', 'attr-value', 'string', 'front-matter'];

// Prism.languages.markdown.url.inside['url-link'] = Prism.languages.markdown.url.inside['url'];
// delete Prism.languages.markdown.url.inside['url'];
// Prism.languages.markdown.url.inside['url-link'] = Prism.languages.markdown.url.inside['node:url'];
// delete Prism.languages.markdown.url.inside['node:url'];
// Prism.languages.markdown['url-reference'].alias = 'url-link';

Prism.languages.markdown.urlOuter = Prism.languages.markdown.url;
Expand Down Expand Up @@ -62,7 +62,7 @@ Prism.hooks.add('wrap', function (env) {
return url;
}

if ('url' === env.type) {
if ('node:url' === env.type) {
env.tag = 'a';
env.attributes.href = removeHash(env.content);
env.attributes['data-to-rewrite'] = 'true';
Expand Down
2 changes: 0 additions & 2 deletions apps/ui/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
'use strict';

import {Tooltip} from 'bootstrap';
import {createApp} from './app.ts';
import {addTelemetry} from './telemetry.ts';
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/pages/GDocsView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
</template>
<script lang="js">
import dayjs from 'dayjs';
import relativeTime from 'dayjs/plugin/relativeTime';
import relativeTime from 'dayjs/plugin/relativeTime.js';
import {UiMixin} from '../components/UiMixin.ts';
import {DEFAULT_TAB, disableElement, UtilsMixin} from '../components/UtilsMixin.ts';
import {GitMixin} from '../components/GitMixin.ts';
Expand Down
3 changes: 2 additions & 1 deletion apps/ui/src/pages/LazyHydrate.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<script lang="ts">
import { defineComponent, onMounted, PropType, ref, watch } from 'vue';
import { defineComponent, onMounted, ref, watch } from 'vue';
import type { PropType } from 'vue';
type VoidFunction = () => void;
const isBrowser = () => {
return typeof window === 'object';
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/pages/ShareView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</template>
<script>
import {UtilsMixin} from '../components/UtilsMixin.ts';
// eslint-disable-next-line import/no-unresolved
await import('https://apis.google.com/js/api.js');
export default {
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/src/pages/StaticView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</template>
<script>
import {markRaw} from 'vue';
import {UtilsMixin} from '../components/UtilsMixin';
import {UtilsMixin} from '../components/UtilsMixin.ts';
import BaseLayout from '../layout/BaseLayout.vue';
import ShareModal from '../components/ShareModal.vue';
import NavBar from '../components/NavBar.vue';
Expand Down
8 changes: 4 additions & 4 deletions apps/ui/src/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,13 +155,13 @@ export function addTelemetry(app) {
new FetchInstrumentation({
ignoreUrls: [],
applyCustomAttributesOnSpan(span: Span, request: Request | RequestInit, result: Response | FetchError) {
if (result['url'] && result['url'].indexOf('/api/') > -1) {
if (result['node:url'] && result['node:url'].indexOf('/api/') > -1) {
const method = request.method || 'get';
const url = new URL(result['url']);
const url = new URL(result['node:url']);
span.updateName('http_client ' + method + ' ' + url.toString());
} else {
if (result['url']) {
console.log(result['url']);
if (result['node:url']) {
console.log(result['node:url']);
}
}
},
Expand Down
5 changes: 3 additions & 2 deletions apps/ui/vite.config.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defineConfig } from 'vite';
import vue from '@vitejs/plugin-vue';
import {generateHead} from '../../html/generateHead.ts';

import {generateHead} from '../../website/generateHead.ts';

if (!process.env.BUILD_TIME) {
process.env.BUILD_TIME = new Date().toISOString();
Expand Down Expand Up @@ -82,7 +83,7 @@ export default defineConfig({
vue(),
htmlPlugin()
],
publicDir: '../../html/public',
publicDir: './public',
resolve: {
alias: {
// 'vue/server-renderer': '@vue/server-renderer/dist/server-renderer.esm-bundler.js',
Expand Down
5 changes: 5 additions & 0 deletions deno.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"compilerOptions": {
"experimentalDecorators": true
}
}
Loading

0 comments on commit 2a69b40

Please sign in to comment.