Skip to content

Commit

Permalink
feat: remove webpack bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
4e6 committed Apr 2, 2024
1 parent 8a8a9ef commit 9000a62
Show file tree
Hide file tree
Showing 8 changed files with 126 additions and 981 deletions.
6 changes: 2 additions & 4 deletions app/gui2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"story:build": "histoire build",
"story:preview": "histoire preview",
"build-only": "vite build",
"build-ydoc-server": "vite build --config vite.ydoc-server.config.ts",
"compile-server": "tsc -p tsconfig.server.json",
"typecheck": "vue-tsc --noEmit -p tsconfig.app.json --composite false",
"lint": "eslint .",
Expand Down Expand Up @@ -125,16 +126,13 @@
"sql-formatter": "^13.0.0",
"tailwindcss": "^3.2.7",
"tar": "^6.2.0",
"ts-loader": "^9.5.1",
"tsx": "^4.7.1",
"typescript": "~5.2.2",
"unbzip2-stream": "^1.4.3",
"vite": "^4.4.9",
"vite-plugin-inspect": "^0.7.38",
"vitest": "^1.3.1",
"vue-react-wrapper": "^0.3.1",
"vue-tsc": "^1.8.27",
"webpack": "^5.91.0",
"webpack-cli": "^5.1.4"
"vue-tsc": "^1.8.27"
}
}
23 changes: 7 additions & 16 deletions app/gui2/shared/ast/ffi.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,11 @@
import { isJvm } from '../util/detect'

async function resolveImports() {
if (isJvm) {
const javaImpl = await import('./ffiJvm')
return javaImpl
} else {
const wasmImpl = await import('./ffiWasm')
return wasmImpl
}
declare global {
function parse_tree(code: string): Uint8Array;
function parse_doc_to_json(docs: string): string;
function is_ident_or_operator(code: string): number;
function xxHash128(input: string): string;
}

const { is_ident_or_operator, parse_doc_to_json, parse_tree, initializeFFI, xxHash128 } =
await resolveImports()

// TODO[ao]: We cannot to that, because the ffi is used by cjs modules.
// await initializeFFI()
export async function initializeFFI(path?: string | undefined) {}

/* eslint-disable-next-line camelcase */
export { initializeFFI, is_ident_or_operator, parse_doc_to_json, parse_tree, xxHash128 }
export const { is_ident_or_operator, parse_doc_to_json, parse_tree, xxHash128 } = globalThis;
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ declare global {
export async function initializeFFI(path?: string | undefined) {}

/* eslint-disable-next-line camelcase */
export { is_ident_or_operator, parse_doc_to_json, parse_tree, xxHash128 }
export const { is_ident_or_operator, parse_doc_to_json, parse_tree, xxHash128 } = globalThis;
4 changes: 0 additions & 4 deletions app/gui2/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,6 @@ export default defineConfig({
build: {
// dashboard chunk size is larger than the default warning limit
chunkSizeWarningLimit: 700,
lib: {
name: 'ydoc-server',
entry: './ydoc-server/server.ts'
},
rollupOptions: {
output: {
manualChunks: {
Expand Down
46 changes: 46 additions & 0 deletions app/gui2/vite.ydoc-server.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/// <reference types="histoire" />

import { getDefines, readEnvironmentFromFile } from 'enso-common/src/appConfig'
import { fileURLToPath } from 'node:url'
import { defineConfig } from 'vite'
const localServerPort = 8080
const projectManagerUrl = 'ws://127.0.0.1:30535'

const IS_CLOUD_BUILD = process.env.CLOUD_BUILD === 'true'

await readEnvironmentFromFile()

// https://vitejs.dev/config/
export default defineConfig({
root: fileURLToPath(new URL('.', import.meta.url)),
cacheDir: fileURLToPath(new URL('../../node_modules/.cache/vite', import.meta.url)),
publicDir: fileURLToPath(new URL('./public', import.meta.url)),
envDir: fileURLToPath(new URL('.', import.meta.url)),
resolve: {
alias: {
shared: fileURLToPath(new URL('./shared', import.meta.url)),
'@': fileURLToPath(new URL('./src', import.meta.url)),
},
},
define: {
...getDefines(localServerPort),
IS_CLOUD_BUILD: JSON.stringify(IS_CLOUD_BUILD),
PROJECT_MANAGER_URL: JSON.stringify(projectManagerUrl),
RUNNING_VITEST: false,
'import.meta.vitest': false,
// Single hardcoded usage of `global` in aws-amplify.
'global.TYPED_ARRAY_SUPPORT': true,
},
build: {
minify: false,
outDir: '../../lib/java/js-websocket/target/classes/dist',
rollupOptions: {
input: {
ydocServer: fileURLToPath(new URL('ydoc-server/server.ts', import.meta.url)),
},
output: {
entryFileNames: `assets/[name].js`,
},
},
},
})
22 changes: 0 additions & 22 deletions app/gui2/webpack.config.cjs

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,12 @@

public class Main {

private static final String YDOC_SERVER_PATH = "/ydoc-server-bundle.js";
private static final String WASM_PATH = "/153299079965dcf860b5.wasm";
private static final String YDOC_SERVER_PATH = "/dist/assets/ydocServer.js";

private Main() {
}

public static void main(String[] args) throws Exception {
ClasspathResource.createTempFile(WASM_PATH);
var demo = ClasspathResource.createTempFile(YDOC_SERVER_PATH);
if (demo == null) {
throw new IOException("Cannot find " + YDOC_SERVER_PATH);
Expand Down
Loading

0 comments on commit 9000a62

Please sign in to comment.