lerna-yarn-workspaces-example | build TypeScript mono-repo project | Blockchain library
kandi X-RAY | lerna-yarn-workspaces-example Summary
kandi X-RAY | lerna-yarn-workspaces-example Summary
How to build TypeScript mono-repo project with yarn and lerna
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of lerna-yarn-workspaces-example
lerna-yarn-workspaces-example Key Features
lerna-yarn-workspaces-example Examples and Code Snippets
Community Discussions
Trending Discussions on lerna-yarn-workspaces-example
QUESTION
I use yarn workspaces and have the following packages:
- packages/x-cli
- packages/x-core
I want to be able to import symbols from x-core subdirectories, the same way you would do import map from 'lodash/map'
, example:
ANSWER
Answered 2020-May-06 at 14:18Update on this: With Nodejs 14, you can specify subpath exports in your package.json.
https://nodejs.org/api/esm.html#esm_subpath_exports
I haven't tested that personally, but it looks like it can fix this issue by using
QUESTION
I can't find a way to generate d.ts and d.ts.map files using webpack. babel-loader only generates js and js.map files. I also need d.ts and d.ts.map files (which I was able to generate using tsc
command) as shown in this picture:
Here is a minimal repo that contains all the settings: https://github.com/stavalfi/lerna-yarn-workspaces-example
More DetailsI moved to Lerna + yarn. One of my packages is core
(will be used in other packages) which is written in TS and JS.
I'm using webpack 4,babel-loader 8 for ts-to-js.
The other packages are trying to find type definitions and implementation of my core
package but I was only able to generate index.js
and index.js.map
with webpack:
ANSWER
Answered 2019-Mar-23 at 22:06You can call the Typescript compiler tsc
directly to do that.
Use tsc --declaration
to output a .d.ts
file and tsc --declarationMap
to generate the corresponding map file.
You can find more documentation here: https://www.typescriptlang.org/docs/handbook/compiler-options.html
QUESTION
[It only infects typescript library creators]
if the code base contains absolute paths (by configuring tsconfig.json
and webpack), then the typescript compiler will generate all the d.ts files with the same absolute paths that are useless because my lib consumers can't do a thing with them.
Every library that I saw are doing one of the following:
- creating their own single-file.d.ts file manually
- using relative path in their code base so the output d.ts files also contain relative paths.
Clearly, both alternatives suck.
Other solution that I thought about- creating a single d.ts file (there will be no imports).
I couldn't find a working library for that.
- not sure if it's possible: before running ts-loader, we need to run a magic babel-plugin to transform every absolute path to a relative by looking in the webpack-resolve-module section in webpack.config file.
I created a library that generates broken d.ts files with absolute paths:
https://github.com/stavalfi/lerna-yarn-workspaces-example/tree/master/packages/x-core
index.ts:
...ANSWER
Answered 2019-May-18 at 20:52If any typescript library creator still has this problem, I created a Webpack loader for babel-plugin-module-resolver, which converts absolute paths to relative paths: https://github.com/stavalfi/babel-plugin-module-resolver-loader
It also solved the problem of *.d.ts
files with absolute paths by converting them to relative paths.
You will probably want to subscribe to/read this thread for additional workarounds: https://github.com/Microsoft/TypeScript/issues/15479
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install lerna-yarn-workspaces-example
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page