zerkalica/zerollup

[ts-transform-paths] v1.7.4 doesn't work

MichalLytek opened this issue ยท 14 comments

I've updated this package from 1.7.3 to 1.7.4 and suddenly it stopped rewriting the paths. When I've downgraded to 1.7.3, it started working again.

My setup is "ttypescript": "^1.5.8" and "typescript": "^3.7.2".

{
  "extends": "../../tsconfig.settings.json",
  "compilerOptions": {
    "rootDir": "src",
    "outDir": "lib",
    "baseUrl": "./",
    "paths": {
      "@src/*": ["src/*"]
    },
    "plugins": [
      {
        "transform": "@zerollup/ts-transform-paths",
        "exclude": ["*"]
      }
    ]
  },
  "include": ["src"]
}

Try 1.7.5

You can remove "exclude": ["*"], now external packages paths not transformed.

Having the same issue on 1.7.5, downgrading to 1.7.3 works as usual.

@rafamel
Rewrite works on 1.7.5 for me: https://github.com/zerkalica/zerollup-test-18

Can you provide demo example?

1.7.5 emit *.d.ts files with import bar from ; and *.js with const bar_1 = tslib_1.__importDefault(require("@src/bar")); which is not rewritted.

I'm still using TS 3.6.4 as ts-jest has problems with TS 3.7.2. But with 3.7.2 id doesn't work either.

Demo repo:
https://github.com/MichalLytek/type-graphql/tree/vNext

@MichalLytek
https://github.com/MichalLytek/type-graphql/tree/vNext has no ttypescript and plugins in tsconfig.json configured.

paths in src are relative

Can you provide real broken example?

it's a monorepo - sepatate tsconfig for every package:
https://github.com/MichalLytek/type-graphql/blob/vNext/packages/class-validator/tsconfig.json

steps to reproduce:
npm install, npm run bootstrap, npm run build, then check libs subfolders for packages, then update your package in all subfolders, run bootstrap, then see fail and check libs again

npm install; npm run bootstrap; npm run build - all ok, imports rewrited in all packages.

Explain please, command by command:

then update your package in all subfolders, run bootstrap, then see fail and check libs again

Change the version of "@zerollup/ts-transform-paths" to 1.7.5 in package.json, then run npm run bootstrap on root, then npm run build again and see the results

Hi there, I'm also having this issue on a monorepo with typescript, ttypescript, and @zerollup/ts-transform-paths hoisted at root, so that could be the common denominator. If this info is insufficient or @MichalLytek's doesn't work for you, I can set up a simple example monorepo, but I'm thinking this is likely already enough info to go from?

try 1.7.6, rewriting now works for type-graphql.

1.7.6 correctly builds the projects (both js and d.ts) but fails to execute the tests using ts-jest ๐Ÿ˜ž

Steps to reproduce:

  • use vNext branch
  • npm run bootstrap
  • npm run build
  • npx jest --clearCache
  • npm t, then a
  • 3 tests are green and working
  • update the plugin package in package.json of core and validator project
  • again - boostrap, build, clearCache, tests
  • you should see errors like Cannot find module '@typegraphql/core' from 'bar.ts' and after "fixing" to use in paths mapping src instead of lib, you will see errors about import from "@src/bar"; ๐Ÿ˜•

@MichalLytek In 1.7.7 i improve internal/external import detection, now tests passed.

I can confirm that now everything is working, thanks!

Thank you for help.