Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

URL transform doesn't work with TypeScript #552

Open
emlai opened this issue Mar 22, 2023 · 2 comments
Open

URL transform doesn't work with TypeScript #552

emlai opened this issue Mar 22, 2023 · 2 comments

Comments

@emlai
Copy link

emlai commented Mar 22, 2023

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
@Charlygraphy23
Copy link

SyntaxError: Cannot use import statement outside a module

You must have using import without modules. I think you need to add "type": "module" in your package.json file. Or else you can use require for importing file

@mon-jai
Copy link

mon-jai commented Oct 19, 2023

@Charlygraphy23 .mts doesn't work too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants