Skip to content

Pebble: typescript build fails with "Cannot find module 'web/websocket'" #1629

@imax9000

Description

@imax9000

Build environment: Linux
Moddable SDK version: 7b68560 (included here as a submodule)
Target device: Pebble Time 2

Description
Attempting to use TypeScript results in build failures.

Steps to Reproduce

docker run --rm -it ubuntu:latest

# inside the container
export TZ=Etc/UTC
ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone
export PATH=/usr/local/bin:/root/.local/bin:$PATH

apt update
apt install -y pipx npm
pipx install --python 3.12 --fetch-missing-python pebble-tool
npm install -g typescript

pebble new-project --alloy test
cd test
mv src/embeddedjs/main.{js,ts}
pebble build -v

Expected behavior
Successful build.

Actual behavior

Running Moddable prebuild.
Running mcrun -m ./src/embeddedjs/manifest.json -f x -p pebble/emery -t build -o ./build/mods/emery/mcrun -s tech.moddable.pebble
### -p pebble/emery
# tsc main.ts
../../../root/.local/share/pebble-sdk/SDKs/4.9.169/toolchain/moddable/typings/pebble/global.d.ts:89:40 - error TS2307: Cannot find module 'web/websocket' or its corresponding type declarations.

89 declare const WebSocket: typeof import('web/websocket').default;
                                          ~~~~~~~~~~~~~~~


Found 1 error in ../../../root/.local/share/pebble-sdk/SDKs/4.9.169/toolchain/moddable/typings/pebble/global.d.ts:89

# typescript compile failure
make: *** [/test/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/makefile:99: /test/build/mods/emery/mcrun/tmp/pebble/release/embeddedjs/tsc/main/test/src/embeddedjs/main.js] Error 1
Moddable prebuild failed: Command '['mcrun', '-m', './src/embeddedjs/manifest.json', '-f', 'x', '-p', 'pebble/emery', '-t', 'build', '-o', './build/mods/emery/mcrun', '-s', 'tech.moddable.pebble']' returned non-zero exit status 2.

Other information:

Curiously enough, output file is still getting generated (but I can't be confident that it would always generate correctly) and the Makefile is missing .DELETE_ON_ERROR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions