-
Notifications
You must be signed in to change notification settings - Fork 375
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
[EPIC] Better NPM package Bundle Layout with typescript definition bundle (.d.ts) #5854
Comments
I created a PR here: #5863 to highlight the problem we have for step 1 --- in order to output types (.d.ts) files |
Nanda to review, discuss with Jacky and break it down into smaller issues (possibly in an epic) |
We also need to review all babel plugins usage here:
|
To build TerriaMap to es6 with generators use e.g. |
Better NPM package Bundle Layout with typescript definition bundle (.d.ts)
Background & Motivation
This PR demonstrated the difficulties that a terriajs lib / plugin developer might face when try to bundle a library / plugin that requires TerriaJs as dependencies.
Approach & Goals
This ticket proposes a new bundle layout approach that can achieve:
devDependencies
ordependencies
of his project.declaration
tsconfig set totrue
to make sure all types are correct..d.ts
file) will be produced to include allTerriaJs
types definition.TerriaJs
as dependencies).types
field will be added topackage.json
to indicate the location of the.d.ts
. See here. And example package here<script>
tags.What's Next & How to achieve it
This will be a task too big to achieve in one go (we might want to convert it into an epic if go ahead). However, I think it's possible seperate it into smaller tasks that can be gradually done, review & merged WITHOUT creating backwards compatibility issues for developers & users.
Here is the plan:
declaration
tsconfig set totrue
.devDependencies
&peerDependencies
, excluded it from bundle and import it as "external"devDependencies
, included in the bundledependencies
, excluded it from bundle and import it as "external"Side note re: Build Speed
typescript is known to be slow for building large project.
Babel won't be the solution --- it might be fast but it simply strip the types without understanding it.
People often solve it by sub projects / mono repo --- i.e. you only need to build the module you've modified without building everything.
Since ts 3.7, we have the project reference feature provided better support to it --- Magda actually use this feature. See here.
Having said that, it's complicated to introduce sub-project event with ts project reference feature. We'd better get this ticket done before solving the build speed issue.
The text was updated successfully, but these errors were encountered: