Closed purplemana closed 5 years ago
I've just tested project references, and it works.
testTtsc.zip (npm i && npm start
)
Can you provide some example project where it doesn't work?
Maybe you put all transformers into main project which gather other projects via references? Transformers should be in every project's tsconfig.json
Please access it from the branch ttypescript
in the git repo https://github.com/purplemana/alchemist. Few points:
src
folder. The baseUrl
points to .
. Paths
is set to resolve @src/*
to src/*
, so inside the package code, you can reference any local file from the top, e.g. @src/types
instead of relative ../../types
.build
folder.Repro steps:
ttypescript
& yarn install
.cd packacges/drivers
and build with yarn build
.src/fixtures/db/index.ts
contains import { DB } from "@src/db";
which is remapped correctly to const db_1 = require("../../db");
in the output file located at build/src/fixtures/db/index.js
.yarn clean
.cd packages/models
and build with yarn build
. This will trigger re-building of drivers
.packages/drivers/build/src/fixtures/db/index.js
. This time it is not remapped by the transform and still contains const db_1 = require("@src/db");
.So when models
is being built, the transform doesn't run on the output of drivers
.
Your project doesn't build correctly: after yarn install
it prints
yarn install v0.16.1
info No lockfile found.
success Nothing to install.
✨ Done in 0.08s.
and after yarn build
a lot of ts errors:
../resources/src/errors/auth/index.test.ts:2:24 - error TS2307: Cannot find module 'chai'.
2 import { expect } from "chai";
~~~~~~
../resources/src/errors/auth/index.test.ts:6:1 - error TS2582: Cannot find name 'describe'. Do you need to install type definitions for a test runner? Try `npm i @types/jest` or `npm i @types/mocha`.
6 describe("errors/auth tests", () => {
Your yarn version seems to not support workspaces. Could you try with the latest version 1.12.1
please? Also as a precaution, check if the older yarn created an empty lockfile and delete it.
I found your problem: plugins
section must be in the compilerOptions
, but you set it in the root of tsconfig.json
Thanks for the super quick help @cevek! It's working as expected. Wow, this has been the end of a long list of trial and errors to get this mono-repo setup working without heart burns.
I have a monorepo where I have configured each package to be built by
ttsc -b
. I need tsconfig alias paths to be transformed to relative paths usinghttps://www.npmjs.com/package/@zerollup/ts-transform-paths
module. Currently building a dependent project with ttsc doesn't run the transforms on the dependency packages. The only way is to manually build all packages in the order of dependencies. Considering tsc already builds them in the order, adding this support will be a huge step in solving the dreaded mono-repo holy grail problems.Please let me know if there are any known workarounds.