Registry / devops / wa-map-optimizer-vite

wa-map-optimizer-vite

JSON →
library1.2.4jsnpmunverified

Vite plugin for optimizing WorkAdventure Tiled (.tmj) maps. Version 1.2.4, released March 2026. Integrates wa-map-optimizer into Vite build pipeline: recursively discovers .tmj maps, validates structure, runs optimizer, rewrites 'script' and 'mapImage' custom properties to point to hashed Vite output. Generates HTML wrapper files for scripts. Supports configurable Play URL via options or PLAY_URL env var. Active maintenance with monthly releases.

npm install wa-map-optimizer-vite
INSTALL
IMPORT
SIG · WA-MAP-OPTIMIZER-V
W
wa-map-optimizer-vite
devopsjavascriptv1.2.4
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

getMaps
import { getMaps } from 'wa-map-optimizer-vite'
const { getMaps } = require('wa-map-optimizer-vite')
ESM-only package. CommonJS require is not supported.
getMapsScripts
import { getMapsScripts } from 'wa-map-optimizer-vite'
import getMapsScripts from 'wa-map-optimizer-vite'
Named export, not default. Must use named import syntax.
getMapsOptimizers
import { getMapsOptimizers } from 'wa-map-optimizer-vite'
Returns an array of Vite plugin objects. Spread them into the plugins array.
WaMapOptimizerOptions
import type { WaMapOptimizerOptions } from 'wa-map-optimizer-vite'
import { WaMapOptimizerOptions } from 'wa-map-optimizer-vite'
This is a TypeScript type, not a runtime value. Use 'import type' to avoid runtime errors.

Basic setup: discovers .tmj maps from 'maps' folder, exposes scripts as Rollup entries, attaches optimizer plugins.

// vite.config.ts import { defineConfig } from 'vite'; import { getMaps, getMapsScripts, getMapsOptimizers } from 'wa-map-optimizer-vite'; const maps = getMaps('maps'); export default defineConfig({ build: { manifest: true, rollupOptions: { input: { ...getMapsScripts(maps) } } }, plugins: [ ...getMapsOptimizers(maps, { logs: 1 }) ] }); // Then run: npx vite build
Debug
Known issues
breakingIn version 1.2.0, script entries now generate HTML wrapper files instead of direct JS file references.
fix
Ensure your map loading code expects HTML file paths for scripts (e.g., 'script.html' instead of 'script.js').
affects: >=1.2.0
gotchaThe plugin requires Vite's build manifest to be enabled (build.manifest: true) for reliable script detection.
fix
Set build.manifest: true in your Vite config.
affects: >=1.0.0
deprecatedThe 'output' option in WaMapOptimizerOptions was deprecated and will be removed in future versions.
fix
Use Vite's 'build.outDir' to control output directory instead.
affects: >=1.1.28
gotchagetMaps skips 'dist' and 'node_modules' directories automatically; if your maps are inside one of these, they will not be found.
fix
Place your map files outside 'dist' and 'node_modules', or adjust the path passed to getMaps.
affects: >=1.0.0
gotchaIf no script property is defined on a map, the map is still optimized but no HTML wrapper is generated. The mapImage property is optional.
fix
To generate scripts, add a 'script' custom property in Tiled pointing to your JS/TS entry file.
affects: >=1.0.0
Errors
Common errors & fixes
TypeError: getMaps is not a function
Incorrect import: using default import instead of named import.
fix
Change to: import { getMaps } from 'wa-map-optimizer-vite'
Error: Cannot find module 'wa-map-optimizer'
Missing peer dependency wa-map-optimizer.
fix
Run: npm install wa-map-optimizer
The 'manifest' option is not enabled. Script detection may fail.
build.manifest not set to true in Vite config.
fix
Add 'build.manifest: true' to your Vite config.
No maps found in the specified directory
getMaps path is incorrect or directory contains no .tmj files.
fix
Verify the path passed to getMaps exists and contains .tmj files. Path is relative to project root.
Upgrade
Version history
1.2.4latest on npm
Audit
Dependencies
wa-map-optimizerrequiredCore map optimization logic; this plugin is a Vite wrapper around it.
@workadventure/tiled-map-type-guardrequiredType validation of .tmj map files.
viterequiredPeer dependency; plugin used as Vite plugin.
Agent activity
0 hits · last 30 days

No traffic data recorded yet.

Resources
wa-map-optimizer-vite — npm install wa-map-optimizer-vite · libregistry