playcanvas / playcanvas/editor

Ability to exclude a script from concatenation

Open
#697 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: assets area: launch tab area: publishing area: scripts enhancement
Dominant language
TypeScript
Stars
1.3k
Forks
215
Avg merge
1d 29m
Merged PRs (30d)
30

Description

This may sound like a stretch case but there is a simple and important use case that can benefit from it:

  • using PlayCanvas .js assets to spawn web workers.

This code will fail if script concatenation is enabled either on launch or on a build:

const workerScript = this.app.assets.find('worker.js', 'script');

const worker = new Worker(workerScript.getFileUrl());

The alternative right now is quite nasty:

  1. Have worker.js be worker.txt (text asset)
  2. Load its contents in a Blob with an application/javascript mimetype
  3. Feed that blob to the Worker constructor using URL.createObjectURL(blob).

It works, but it's not great to edit code in a txt file.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start from the editor's script-concatenation and build entry points; the issue does not name specific files or tests. Reproduce the Worker failure with a PlayCanvas .js asset, then determine how an asset can be excluded from concatenation while normal scripts retain their existing behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript
Domain
build-system, frontend, web-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.