cloudflare / python-worker-hello-world

Python hello world for Cloudflare Workers
Apache License 2.0
276 stars 48 forks source link

Wrangler publish fails on Windows 10 #2

Closed 12932 closed 4 years ago

12932 commented 4 years ago

I managed to bypass https://github.com/cloudflare/python-worker-hello-world/issues/1 by deleting the fake Windows 10 python3 (that redirects to Windows Store), and making a copy of python.exe as python3.exe (dirty hack)

However, wrangler publish seems to be failing still

C:\Users\admin\wranglers\pythonhelloworld>wrangler publish
⬇️ Installing wranglerjs...
⬇️ Installing wasm-pack...
 ./index.py
Module not found: Error: Can't resolve './__target__index.js' in 'C:\Users\admin\wranglers\pythonhelloworld'
resolve './__target__index.js' in 'C:\Users\admin\wranglers\pythonhelloworld'
  using description file: C:\Users\admin\wranglers\pythonhelloworld\package.json (relative path: .)
    Field 'browser' doesn't contain a valid alias configuration
    using description file: C:\Users\admin\wranglers\pythonhelloworld\package.json (relative path: ./__target__index.js)
      no extension
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js doesn't exist
      .wasm
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.wasm doesn't exist
      .mjs
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.mjs doesn't exist
      .js
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.js doesn't exist
      .json
        Field 'browser' doesn't contain a valid alias configuration
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.json doesn't exist
      as directory
        C:\Users\admin\wranglers\pythonhelloworld\__target__index.js doesn't exist
[C:\Users\admin\wranglers\pythonhelloworld\__target__index.js]
[C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.wasm]
[C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.mjs]
[C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.js]
[C:\Users\admin\wranglers\pythonhelloworld\__target__index.js.json]
 @ ./index.py 1:0-38 1:0-38
Error: webpack returned an error. Try configuring `entry` in your webpack config relative to the current working directory, or setting `context = __dirname` in your webpack config.
koeninger commented 4 years ago

The best way to change the python path used by transcrypt-loader is to edit webpack.config.js. I've updated this repo's webpack.config.js to explicitly include the default python3 command, you would need to edit it to the appropriate path on your system (just python -m transcrypt works for me, but ymmv on your python install) .

The issue with targetindex.js is a known issue with transcrypt-loader, with a workaround here https://github.com/QQuick/Transcrypt/issues/624#issuecomment-507866238

I'd prefer to see if we can get this fixed appropriately upstream before forking transcrypt-loader, so have linked that workaround from this project's readme for now.

I've tested this working on Windows 10 once webpack.config.js and ./node_modules/transcrypt-loader/__target_es5__/index.js are edited appropriately.