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
Typescript project reference #1839
Comments
Well parcel isn't even running typescript 3 yet, perhaps we should start with simply upgrading to 3 first |
Isn't it? I used other typescript 3 features with parcel today (spread operator with tupples). Worked perfectly. Interesting. |
That's pretty cool, parcel localRequires it so it just uses whatever the user has installed. Means ts 3 doesn't have that many changes that would break parcel's implementation. We currently test against It's mainly a thing of running ts 3 in the tests to make sure everything still works, I'll create a PR in a bit |
According to typescript documentation, the only breaking change is https://github.com/Microsoft/TypeScript-wiki/blob/master/Breaking-Changes.md In the mean time, I'll try to make a fork that adds that |
Awesome, thanks for looking that up. Update PR: #1840 |
Tried adding Doesn't seems to do anything. I expected as much considering it seems we must use Maybe it's something on typescript side. Like supporting a |
It seems voluntary on TS side that |
Well that's a pity, although I'm not sure if this would be able to work inside parcel at all as parcel compiles one file at a time and gives typescript very little information. |
Yeah, I realized that. Maybe we can have a middle ground. I don't know. But this would be quite cool if this was supported by parcel. We wouldn't need to have one watcher per package. Edit: I came across But I wonder how parcel would handle going outside of the current package boundaries. |
From Ryan Cavanaugh as an answer to "How to compile projets references with
Would this be ok to do that in parcel ? |
Probably better to contribute this to |
Does Parcel still not support typescript project references, i.e. composite projects? |
I read the docs above but I don’t think I really understand what this feature is or what we’d need to do in Parcel to enable it. Can someone summarize? Parcel 2 is using more TypeScript internals than Parcel 1 but still uses transpileModule to compile files independently (with a plugin - we compile with Babel by default now). |
@devongovett basically inside tsconfig.json you define which monorepo packages your typescript package depends on. Then your editor and Typescript compiler can lint and compile your package while resolving its monorepo dependencies. E.g. I may have this tsconfig.settings.json in my workspace root:
and then have a folder structure like:
Where
and a tsconfig.json like:
now inside e.g. |
I’m probably missing something, but does this not already work via normal node_modules resolution with something like Yarn workspaces? |
@devongovett no because that would require you to first build the dependency packages; Typescript project references understand source references |
Hmm, a bundler like Parcel would build the dependency packages on demand. You can use the |
@devongovett how would my editor pick that up though? I'm using vscode. Intellisense understands typescript project references, but wouldn't be aware of Parcel |
Combine them? I’d like to convince TS to support Another solution I’ve found is to create an |
@devongovett hmm ok, I'll give this a try and create an open source boilerplate with Parcel + Typescript References + Yarn workspaces + Lerna + React.js + Serverless Framework. Let me know if you'd be open to providing feedback along the way |
Sure, I’d be happy to. I’m happy for us to also look into implementing project references. We may end up with a TypeScript specific resolver at some point to handle this and other TS specific stuff (e.g. |
@devongovett My team uses project references. It works something like this: without project references = when we import something, typescript does the usual flow (import, read source, check types, compile source) with project references = when we import something, typescript does nothing, just imports signatures from Would be really cool to see parcel supporting it. |
🙋 feature request
With typescript 3.0.0 there's now something called "Project reference". It basically links multiple ts packages together in mono-repository. And build them in order in a single
tsc
call.https://www.typescriptlang.org/docs/handbook/project-references.html
Faster build time, cool and all. But it requires a custom flag to
tsc
:tsc -b
🤔 Expected Behavior
Parcel detects that there's project reference activated and pass
-b
flag😯 Current Behavior
-b
flag isn't passed. Therefore dependencies are not built. Leading to💁 Possible Solution
If the
tsconfig.json
containsreferences
field, add-b
flagAs a workaround, we can manually call
tsc -w -b
on another terminal. But then that's the equivalent of not using parcel🔦 Context
Simply setting up a project with "Project references".
💻 Examples
WIP
The text was updated successfully, but these errors were encountered: