Skip to content

Error: Can't resolve './..__target__src.main.js' #624

Open

Description

@jalbr74

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

Activity

  1. jalbr74 commented on Mar 21, 2019

    @jalbr74
    Author

    Here's a link to my Hello World project:
    https://github.com/jalbr74/hello-transcrypt

  2. bunkahle commented on Apr 23, 2019

    @bunkahle

    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.

  3. jalbr74 commented on Jul 2, 2019

    @jalbr74
    Author

    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?

  4. JdeH commented on Aug 14, 2019

    @JdeH
    Collaborator

    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!

  5. koeninger commented on Jul 30, 2020

    @koeninger

    @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.

  6. phistrom commented on Aug 7, 2020

    @phistrom

    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.

  7. JennaSys commented on Dec 30, 2020

    @JennaSys
    Collaborator

    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

    this.importPath = './' + path.join('__target__', this.pyModule) + '.js';
    

    to

    this.importPath = ('./' + path.join('__target__', this.pyModule) + '.js').replace(/\\/g, '/');
    

    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).

  8. JennaSys commented on Feb 3, 2022

    @JennaSys
    Collaborator

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions