Skip to content

URL transform doesn't work with TypeScript #552

Open
@emlai

Description

@emlai

I have a transform file written in TypeScript. It works when used as a local file (-t path/to/file) but not as a URL (-t https://...).

With a github enterprise raw file link like https://raw.github.path/to/repo/path/to/file.ts?token=GHSAT0AAAAAAAAA6BCXCCVMJWKCSGK3L3UQZA2ZLWQ, jscodeshift fails with the following error:

/private/var/folders/sy/sqk95ngs0b7bb6c3872cbvyc0000gn/T/jscodeshift2023222-6764-1d1j47d.za2t.ts?token=GHSAT0AAAAAAAAA6BCXCCVMJWKCSGK3L3UQZA2ZLWQ:8
import type {
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at internalCompileFunction (node:internal/vm:73:18)
    at wrapSafe (node:internal/modules/cjs/loader:1159:20)
    at Module._compile (node:internal/modules/cjs/loader:1203:27)
    at Module._extensions..js (node:internal/modules/cjs/loader:1293:10)
    at Object.newLoader [as .js] (/Users/emlai/.npm/_npx/c5e6d14ea42cfa80/node_modules/pirates/lib/index.js:141:7)
    at Module.load (node:internal/modules/cjs/loader:1096:32)
    at Module._load (node:internal/modules/cjs/loader:935:12)
    at Module.require (node:internal/modules/cjs/loader:1120:19)
    at require (node:internal/modules/helpers:112:18)
    at setup (/Users/emlai/.npm/_npx/c5e6d14ea42cfa80/node_modules/jscodeshift/src/Worker.js:91:18)

When using a the url of the github "Raw" button, e.g. https://github.path/to/repo/raw/path/to/file.ts, I get the following error:

 ERR file/to/transform.tsx Transformation error (transform is not a function)
TypeError: transform is not a function

Activity

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions