make bundle smaller and debugger run faster
This commit is contained in:
parent
0acaa652a3
commit
d17e1b2acb
7 changed files with 43 additions and 36 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -11,6 +11,7 @@ dist
|
|||
.DS_Store
|
||||
.idea/
|
||||
world
|
||||
data*.json
|
||||
out
|
||||
*.iml
|
||||
.vercel
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ const buildOptions = {
|
|||
// logLevel: 'debug',
|
||||
logLevel: 'info',
|
||||
platform: 'browser',
|
||||
sourcemap: prod ? true : 'inline',
|
||||
sourcemap: prod ? true : 'linked',
|
||||
outdir: 'dist',
|
||||
mainFields: [
|
||||
'browser', 'module', 'main'
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@
|
|||
"build-storybook": "storybook build && node scripts/build.js moveStorybookFiles",
|
||||
"start-experiments": "vite --config experiments/vite.config.ts",
|
||||
"watch-other-workers": "echo NOT IMPLEMENTED",
|
||||
"watch-worker": "node prismarine-viewer/buildMesherWorker.mjs -w",
|
||||
"run-playground": "run-p watch-worker watch-other-workers playground-server watch-playground",
|
||||
"watch-mesher": "node prismarine-viewer/buildMesherWorker.mjs -w",
|
||||
"run-playground": "run-p watch-mesher watch-other-workers playground-server watch-playground",
|
||||
"run-all": "run-p start run-playground",
|
||||
"playground-server": "live-server --port=9090 prismarine-viewer/public",
|
||||
"watch-playground": "node prismarine-viewer/esbuild.mjs -w"
|
||||
|
|
@ -55,7 +55,7 @@
|
|||
"esbuild": "^0.19.3",
|
||||
"esbuild-plugin-polyfill-node": "^0.3.0",
|
||||
"express": "^4.18.2",
|
||||
"flying-squid": "npm:@zardoy/flying-squid@^0.0.15",
|
||||
"flying-squid": "npm:@zardoy/flying-squid@^0.0.17",
|
||||
"fs-extra": "^11.1.1",
|
||||
"google-drive-browserfs": "github:zardoy/browserfs#google-drive",
|
||||
"iconify-icon": "^1.0.8",
|
||||
|
|
@ -157,5 +157,6 @@
|
|||
"updateConfig": {
|
||||
"ignoreDependencies": []
|
||||
}
|
||||
}
|
||||
},
|
||||
"packageManager": "pnpm@9.0.0"
|
||||
}
|
||||
|
|
|
|||
28
pnpm-lock.yaml
generated
28
pnpm-lock.yaml
generated
|
|
@ -90,8 +90,8 @@ importers:
|
|||
specifier: ^4.18.2
|
||||
version: 4.18.2
|
||||
flying-squid:
|
||||
specifier: npm:@zardoy/flying-squid@^0.0.15
|
||||
version: /@zardoy/flying-squid@0.0.15
|
||||
specifier: npm:@zardoy/flying-squid@^0.0.17
|
||||
version: /@zardoy/flying-squid@0.0.17
|
||||
fs-extra:
|
||||
specifier: ^11.1.1
|
||||
version: 11.1.1
|
||||
|
|
@ -5629,8 +5629,8 @@ packages:
|
|||
tslib: 1.14.1
|
||||
dev: true
|
||||
|
||||
/@zardoy/flying-squid@0.0.15:
|
||||
resolution: {integrity: sha512-VooP9XuzNQVL3y0zlaU5wStRm1vfQIXAzVNHuvMoMgyIyOiD7A59QzVZT93GAoTyUBHTwqweXMPQftjywUy62A==}
|
||||
/@zardoy/flying-squid@0.0.17:
|
||||
resolution: {integrity: sha512-qGCS7aRmMflDdIN7IGLpDc0W2gUYc5OQ45KEn3XtcxwOP0Q7zyvo3mnsD5KSV3n2lyhQ4783Ov8V6J86xea0lw==}
|
||||
engines: {node: '>=8'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
|
|
@ -5645,11 +5645,9 @@ packages:
|
|||
minecraft-data: 3.62.0
|
||||
minecraft-protocol: github.com/zardoy/minecraft-protocol/2c14a686bfe7cbd9a5c87b629b402295ee86219f
|
||||
mkdirp: 2.1.6
|
||||
moment: 2.30.1
|
||||
needle: 2.9.1
|
||||
node-gzip: 1.1.2
|
||||
node-rsa: 1.1.1
|
||||
prismarine-chunk: github.com/zardoy/prismarine-chunk/3c7e679508cf8ebd1ac4df9a6c22d7cb6c45290b(minecraft-data@3.62.0)
|
||||
prismarine-chunk: github.com/zardoy/prismarine-chunk/f32234a724a5c2482ffbaf85edc5e91c7ab9b38f(minecraft-data@3.62.0)
|
||||
prismarine-entity: 2.3.1
|
||||
prismarine-item: 1.14.0
|
||||
prismarine-nbt: 2.5.0
|
||||
|
|
@ -11492,10 +11490,6 @@ packages:
|
|||
dependencies:
|
||||
nearley: 2.20.1
|
||||
|
||||
/moment@2.30.1:
|
||||
resolution: {integrity: sha512-uEmtNhbDOrWPFS+hdjFCBfy9f2YoyzRpwcl+DqpC6taX21FzsTLQVbMV/W7PzNSX6x/bhC1zA3c2UQ5NzH6how==}
|
||||
dev: false
|
||||
|
||||
/moo@0.5.2:
|
||||
resolution: {integrity: sha512-iSAJLHYKnX41mKcJKjqvnAN9sf0LMDTXDEvFv+ffuRR9a1MIuXLjMNL6EsnDHSkKLTWNqQQ5uo61P4EbU4NU+Q==}
|
||||
|
||||
|
|
@ -11576,18 +11570,6 @@ packages:
|
|||
railroad-diagrams: 1.0.0
|
||||
randexp: 0.4.6
|
||||
|
||||
/needle@2.9.1:
|
||||
resolution: {integrity: sha512-6R9fqJ5Zcmf+uYaFgdIHmLwNldn5HbK8L5ybn7Uz+ylX/rnOsSp1AHcvQSrCaFN+qNM1wpymHqD7mVasEOlHGQ==}
|
||||
engines: {node: '>= 4.4.x'}
|
||||
hasBin: true
|
||||
dependencies:
|
||||
debug: 3.2.7(supports-color@8.1.1)
|
||||
iconv-lite: 0.4.24
|
||||
sax: 1.3.0
|
||||
transitivePeerDependencies:
|
||||
- supports-color
|
||||
dev: false
|
||||
|
||||
/negotiator@0.6.3:
|
||||
resolution: {integrity: sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==}
|
||||
engines: {node: '>= 0.6'}
|
||||
|
|
|
|||
|
|
@ -13,8 +13,8 @@ const prod = process.argv.includes('--prod')
|
|||
let connectedClients = []
|
||||
|
||||
const watchExternal = [
|
||||
'dist/mesher.js',
|
||||
'dist/webglRendererWorker.js'
|
||||
// 'dist/mesher.js',
|
||||
// 'dist/webglRendererWorker.js'
|
||||
]
|
||||
|
||||
/** @type {import('esbuild').Plugin[]} */
|
||||
|
|
@ -55,6 +55,13 @@ const plugins = [
|
|||
}, () => {
|
||||
throw new Error('hit banned package')
|
||||
})
|
||||
build.onLoad({
|
||||
filter: /^prismarine-auth/,
|
||||
}, () => {
|
||||
return {
|
||||
contents: 'module.exports = {}',
|
||||
}
|
||||
})
|
||||
|
||||
build.onResolve({
|
||||
filter: /^three$/,
|
||||
|
|
@ -80,11 +87,26 @@ const plugins = [
|
|||
}
|
||||
})
|
||||
|
||||
const removeNodeModulesSourcemaps = (map) => {
|
||||
const doNotRemove = ['prismarine', 'mineflayer', 'flying-squid', '@jspm/core', 'minecraft']
|
||||
map.sourcesContent.forEach((_, i) => {
|
||||
if (map.sources[i].includes('node_modules') && !doNotRemove.some(x => map.sources[i].includes(x))) {
|
||||
map.sourcesContent[i] = null
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
build.onEnd(async ({ metafile, outputFiles }) => {
|
||||
// write outputFiles
|
||||
//@ts-ignore
|
||||
for (const file of outputFiles) {
|
||||
await fs.promises.writeFile(file.path, file.contents)
|
||||
let contents = file.text
|
||||
if (file.path.endsWith('.map') && file.text) {
|
||||
const map = JSON.parse(file.text)
|
||||
removeNodeModulesSourcemaps(map)
|
||||
contents = JSON.stringify(map)
|
||||
}
|
||||
await fs.promises.writeFile(file.path, contents)
|
||||
}
|
||||
if (!prod) return
|
||||
// const deps = Object.entries(metafile.inputs).sort(([, a], [, b]) => b.bytes - a.bytes).map(([x, { bytes }]) => [x, filesize(bytes)]).slice(0, 5)
|
||||
|
|
@ -167,7 +189,7 @@ const plugins = [
|
|||
}
|
||||
|
||||
// write metafile to disk if needed to analyze
|
||||
// fs.writeFileSync('dist/meta.json', JSON.stringify(metafile, null, 2))
|
||||
fs.writeFileSync('dist/meta.json', JSON.stringify(metafile, null, 2))
|
||||
|
||||
/** @type {import('esbuild').OutputFile} */
|
||||
//@ts-ignore
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
import { isMobile } from './menus/components/common'
|
||||
|
||||
if (process.env.NODE_ENV === 'development' && isMobile()) {
|
||||
require('eruda').default.init()
|
||||
// can be changed to require('eruda')
|
||||
import('https://cdn.skypack.dev/eruda').default.init()
|
||||
console.log('JS Loaded in', Date.now() - window.startLoad)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -51,7 +51,7 @@ import worldInteractions from './worldInteractions'
|
|||
import * as THREE from 'three'
|
||||
import MinecraftData, { versionsByMinecraftVersion } from 'minecraft-data'
|
||||
import debug from 'debug'
|
||||
import _ from 'lodash-es'
|
||||
import { defaultsDeep } from 'lodash-es'
|
||||
|
||||
import { initVR } from './vr'
|
||||
import {
|
||||
|
|
@ -89,7 +89,6 @@ import { fsState } from './loadSave'
|
|||
import { watchFov } from './rendererUtils'
|
||||
import { loadInMemorySave } from './react/SingleplayerProvider'
|
||||
|
||||
// side effects
|
||||
import { downloadSoundsIfNeeded, earlyCheck as earlySoundsMapCheck } from './soundSystem'
|
||||
import { ua } from './react/utils'
|
||||
import { handleMovementStickDelta, joystickPointer } from './react/TouchAreasControls'
|
||||
|
|
@ -97,6 +96,7 @@ import { possiblyHandleStateVariable } from './googledrive'
|
|||
import flyingSquidEvents from './flyingSquidEvents'
|
||||
import { hideNotification, notificationProxy } from './react/NotificationProvider'
|
||||
import { ViewerWrapper } from 'prismarine-viewer/viewer/lib/viewerWrapper'
|
||||
import './hotReload'
|
||||
|
||||
window.debug = debug
|
||||
window.THREE = THREE
|
||||
|
|
@ -352,7 +352,7 @@ async function connect (connectOptions: {
|
|||
const renderDistance = singleplayer ? renderDistanceSingleplayer : multiplayerRenderDistance
|
||||
let localServer
|
||||
try {
|
||||
const serverOptions = _.defaultsDeep({}, connectOptions.serverOverrides ?? {}, options.localServerOptions, defaultServerOptions)
|
||||
const serverOptions = defaultsDeep({}, connectOptions.serverOverrides ?? {}, options.localServerOptions, defaultServerOptions)
|
||||
Object.assign(serverOptions, connectOptions.serverOverridesFlat ?? {})
|
||||
const downloadMcData = async (version: string) => {
|
||||
// todo expose cache
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue