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

fix(build): use correct path for relative imports of external modules + bracket notation #2974

Closed

Conversation

ntziolis
Copy link
Contributor

@ntziolis ntziolis commented Oct 14, 2021

Description

Rolled up two issues as they both only required minor fixes:

Issue 1
Currently using build with external modules that are specified by relative path only work when the --dir equals root of the workspace. Any relative import is always expressed in relation to the root workspace directory instead of in relation to the baseDir.

Issue 2
When using a built mesh with additional resolvers from within a typescript project the compiler was complaining about either missing .resolvers or .default. This was easily mitigated by using bracket notation.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Checklist:

  • I have followed the CONTRIBUTING doc and the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests and linter rules pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

Further comments

I have tested this locally as we were trying to get mesh build up and running in the context of an nx workspace.

Let me know if I should create a change set or wait for #2970 to create a single PR + changeset.

@changeset-bot
Copy link

changeset-bot bot commented Oct 14, 2021

⚠️ No Changeset found

Latest commit: 10cacb7

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

moduleMapProp = relative(baseDir, importedModuleName).split('\\').join('/');
importPath = `./${relative(artifactsDir, importedModuleName).split('\\').join('/')}`;
moduleMapProp = relative(baseDir, importPath).split('\\').join('/');
importPath = `./${relative(artifactsDir, importPath).split('\\').join('/')}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sample:

// prior to if block
const baseDir = 'apps/api/mesh'
const importedModuleName = './composers'
const importPath= 'apps/api/mesh/composers'
// after if block
const moduleMapProp = 'composers'
const importPath= './../composers'

@ntziolis
Copy link
Contributor Author

@ardatan Sry for the flood of PRs, we have been migrating to mesh build (using mesh inside a sub directory in an nx project) and we have been running into these as the migration progresses.

@ntziolis ntziolis changed the title fix(build): use correct path for relative imports of external modules fix(build): use correct path for relative imports of external modules + bracket notation Oct 14, 2021
@ardatan ardatan force-pushed the master branch 2 times, most recently from 39e5048 to 7ef75ea Compare November 11, 2021 12:46
@ardatan ardatan force-pushed the master branch 6 times, most recently from faf42fd to a1c915a Compare December 8, 2021 11:37
@theguild-bot theguild-bot mentioned this pull request Aug 11, 2022
@ardatan ardatan force-pushed the master branch 2 times, most recently from c3c0b9e to 696f9c7 Compare February 14, 2023 05:53
@ardatan
Copy link
Owner

ardatan commented Apr 20, 2023

Thanks for the PR!
I think this has been fixed in the recent releases. If not, let me know :)

@ardatan ardatan closed this Apr 20, 2023
@theguild-bot theguild-bot mentioned this pull request Apr 24, 2023
@theguild-bot theguild-bot mentioned this pull request Sep 28, 2023
This was referenced Apr 30, 2024
This was referenced May 7, 2024
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

2 participants