Skip to content
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

feat(bootstrap): Allow to specify custom folder for packages symlinks #2081

Closed
wants to merge 1 commit into from
Closed

feat(bootstrap): Allow to specify custom folder for packages symlinks #2081

wants to merge 1 commit into from

Conversation

paul-roman
Copy link

Description

This allows to specify a symLinkDir in a package package.json to create the symbolic link from a specific folder of the package.

Motivation and Context

This was motivated by the need to access to the folder structure of the transpiled source of one of our packages, thus we needed that only the dist folder was used in the symbolic link.

How Has This Been Tested?

We added a "symLinkDir": "dist" field in one of our packages package.json, we ran lerna bootstrap and used another package which depends on the first one. Only the dist folder was used for the symbolic link, allowing us to access to the whole folder structure of the dist folder using

import '@repo/child-package/directory/subdirectory/feature';

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link
Member

@evocateur evocateur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Literally no tests added, not going to be accepted without them.

I'm unclear what problem this solves, aside from promoting dubious patterns like deeply-nested subpath imports (they should be exported from the module entry or factored into separate packages).

@@ -53,6 +53,9 @@ class Package {
rootPath: {
value: rootPath,
},
symLinkDir: {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

symlinkDir, if you must. We don't call symlinks "sym-links", after all.

@@ -53,6 +53,9 @@ class Package {
rootPath: {
value: rootPath,
},
symLinkDir: {
value: pkg.symLinkDir,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you point me to an example of any other usage in the ecosystem? I don't want to add arbitrary fields to package.json just to satisfy a vanishingly small percentage of use cases.

@@ -77,7 +77,10 @@ function symlinkDependencies(packages, packageGraph, tracker) {
});

// create package symlink
chain = chain.then(() => createSymlink(dependencyNode.location, targetDirectory, "junction"));
const dependencyLocation = dependencyNode.pkg.symLinkDir
? path.resolve(dependencyNode.location, dependencyNode.pkg.symLinkDir)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't this be better served by the lerna bootstrap equivalent of --contents? This smells to high heaven of Angular-isms.

@kamranayub
Copy link
Contributor

kamranayub commented Sep 17, 2019

Looks like this is halfway there to closing #2209.

The publishConfig.directory works well for publishing. In our monorepo we have two packages, core and baked. baked uses components from core. Since we use Rollup + Babel + TypeScript (these are libraries), we have a dist directory that we publish as the package. While we can publish new versions of the core components, for local development we're looking at using lerna link to make that easier to have a nicer workflow.

In a file within baked you may have:

import { MyComponent } from '@org/core-components'

This works for a published package but since lerna link symlinks the root directory and not the dist directory, for local development you must change the path:

import { MyComponent } from '@org/core-components/dist'

This PR and #2209 would make that workflow much easier. @paul-roman are you planning to add tests/make any additional changes? Otherwise I could possibly take a stab at contributing this.

Based on these discussions, what I'm seeing is some other changes:

@kamranayub
Copy link
Contributor

I have opened a new PR that continues these changes: #2274

@evocateur
Copy link
Member

Closing in favor of #2274

@evocateur evocateur closed this Oct 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants