You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi, I'm new to Transcrypt, but I love the concept!
I thought I'd try a simple "Hello World" project, but I'm running into the following error when I build using webpack:
ERROR in ./src/main.py
Module not found: Error: Can't resolve './..__target__src.main.js' in 'C:\project\src'
@ ./src/main.py 1:0-44 1:0-44
@ multi (webpack)-dev-server/client?http://localhost:8081 ./src/main.py
The only thing that stands out to me is the folder path:
./..__target__src.main.js
My guess is it should actually be:
./../__target__/src.main.js
I'm running on Windows 10, and I'm not sure if it's a problem with building paths on Windows, or because I'm doing something wrong.
It builds fine when I run:
transcrypt src/main.py
Is there any other info I should Include?
OS: Windows 10
Python: 3.7.2
Node: v10.15.1
NPM: 6.4.1
It's been a while since I've been able to get back to this project, but I was able to figure out a fix for the problem. It looks like there is an issue in transcrypt-loader when run on Windows.
I had to edit the following file: ./node_modules/transcrypt-loader/__target_es5__/index.js
On line 44, the code was calling path.relative as follows:
var import_path = './' + path.relative(fileinfo.dir, target_path);
This returned the string: ..\__target__\src.main.js, which caused import_path to be: ./..\__target__\src.main.js, which wasn't a valid path when used in the code farther down:
return 'export * from "{}";'.format(import_path);
The fix I used was to call replace() on the string, and change all back slashes to forward slashes:
var import_path = './' + path.relative(fileinfo.dir, target_path).replace(/\\/g, '/');
In the end, it appears to be a problem with running transcrypt-loader on Windows, due to differences in the path separator. I'd be happy to contribute a pull request, but I couldn't find the transcrypt-loader source in this repo, and I couldn't find another project in GitHub for it either. Is there another place this project is being shared?
Hi, sorry that you stumbled into this.
Support for bundlers was added only recently and the demo at transcrypt/demos/webpack actually uses a patched version.
I'll contact the original developer to solve the problem, taking into account your solution.
We still have to confere on where to host the project for this, and the link on https://www.npmjs.com/package/transcrypt-loader states that it's in the Transcrypt project which is not (yet) the case.
I managed to find the source code for the transcrypt-loader npm package. It appears to only live in a branch called "parcel-bundler2". I have submitted a pull request but I think @doconix will need to do the actual uploading if it is approved.
Just FYI, this same problem exists in the parcel-plugin-transcrypt package as well. It works with the above workaround by adding replace() on line 46 in asset.js and changing it from
The default package config in the same file that uses python3 was an issue on Windows as well, though that can be fixed by putting a custom config in package.json (though not really ideal).
For anyone interested, because the new version of Parcel uses a plugin system that is completely incompatible with the older version, I recently created and published a new Python transformer for Parcel V2 that uses Transcrypt. So far it has handled all of the different environments and platforms I've tried it on. But if you run into any problems with it, feel free to open up a GitHub issue and I'll look into it.
Activity
jalbr74 commentedon Mar 21, 2019
Here's a link to my Hello World project:
https://github.com/jalbr74/hello-transcrypt
bunkahle commentedon Apr 23, 2019
Hi,
you can find a kind of tutorial for transcrypt at:
https://github.com/bunkahle/Transcrypt-Examples/tree/master/hello
or
https://github.com/bunkahle/Transcrypt-Examples
where you find more information how to take the first basic steps.
jalbr74 commentedon Jul 2, 2019
It's been a while since I've been able to get back to this project, but I was able to figure out a fix for the problem. It looks like there is an issue in transcrypt-loader when run on Windows.
I had to edit the following file:
./node_modules/transcrypt-loader/__target_es5__/index.jsOn line 44, the code was calling path.relative as follows:
This returned the string:
..\__target__\src.main.js, which causedimport_pathto be:./..\__target__\src.main.js, which wasn't a valid path when used in the code farther down:The fix I used was to call
replace()on the string, and change all back slashes to forward slashes:In the end, it appears to be a problem with running transcrypt-loader on Windows, due to differences in the path separator. I'd be happy to contribute a pull request, but I couldn't find the transcrypt-loader source in this repo, and I couldn't find another project in GitHub for it either. Is there another place this project is being shared?
JdeH commentedon Aug 14, 2019
Hi, sorry that you stumbled into this.
Support for bundlers was added only recently and the demo at transcrypt/demos/webpack actually uses a patched version.
I'll contact the original developer to solve the problem, taking into account your solution.
We still have to confere on where to host the project for this, and the link on https://www.npmjs.com/package/transcrypt-loader states that it's in the Transcrypt project which is not (yet) the case.
Meanwhile thanks for the detective work!
koeninger commentedon Jul 30, 2020
@JdeH is there anything I can do to help resolve this? We'd be happy to host the transcrypt loader on the cloudflare github if need be.
windows workaround for python3 not being in virtualenv path, and tran…
phistrom commentedon Aug 7, 2020
I managed to find the source code for the transcrypt-loader npm package. It appears to only live in a branch called "parcel-bundler2". I have submitted a pull request but I think @doconix will need to do the actual uploading if it is approved.
JennaSys commentedon Dec 30, 2020
Just FYI, this same problem exists in the parcel-plugin-transcrypt package as well. It works with the above workaround by adding replace() on line 46 in
asset.jsand changing it fromto
The default package config in the same file that uses python3 was an issue on Windows as well, though that can be fixed by putting a custom config in
package.json(though not really ideal).JennaSys commentedon Feb 3, 2022
For anyone interested, because the new version of Parcel uses a plugin system that is completely incompatible with the older version, I recently created and published a new Python transformer for Parcel V2 that uses Transcrypt. So far it has handled all of the different environments and platforms I've tried it on. But if you run into any problems with it, feel free to open up a GitHub issue and I'll look into it.