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

build: update verify-imports-resolve-same to ignore module extensions #19096

Merged
merged 1 commit into from Feb 22, 2022

Conversation

yuth
Copy link
Contributor

@yuth yuth commented Feb 22, 2022

verify-imports-resolve-same.ts script validates if the package import for
monorepo package imports the same modules, but when validating the imports
typescript either would provide .d.ts or .ts or .js file based on how it is
imported. Since .ts and .d.ts are typescript artifacts and .js is used at
runtime the extension can be safely ignored. The code to ignore the extension
was not escaping the . char and string replacement was failing because of it.
Update the regex to escape .


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

…ensions

verify-imports-resolve-same.ts script validates if the package import for
monorepo package imports the same modules, but when validating the imports
typescript either would provide .d.ts or .ts or .js file based on how it is
imported. Since .ts and .d.ts are typescript artifacts and .js is used at
runtime the extension can be safely ignored. The code to ignore the extension
was not escaping the `.` char and string replacement was failing because of it.
Update the regex to escape `.`
@gitpod-io
Copy link

gitpod-io bot commented Feb 22, 2022

@yuth yuth changed the title build: update verify-imports-resolve-same script to ignore module ext… build: update verify-imports-resolve-same script to ignore module exts Feb 22, 2022
@yuth yuth changed the title build: update verify-imports-resolve-same script to ignore module exts build: update verify-imports-resolve-same to ignore module extensions Feb 22, 2022
Copy link
Contributor

@skinny85 skinny85 left a comment

Choose a reason for hiding this comment

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

Awesome first PR! 😉

@@ -84,7 +84,7 @@ async function compileAndResolve(fileName: string, contents: string, symbolName:
}

// Return the filename
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/.ts|.js|.d.ts/, '');
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/[.](ts|js|d\.ts)$/, '');
Copy link
Contributor

Choose a reason for hiding this comment

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

Let's maybe also escape the first . here, instead of using a one-element class, since we do that later in the regex anyway, so it's better to be consistent...?

Suggested change
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/[.](ts|js|d\.ts)$/, '');
const srcFile = sym.declarations?.[0].getSourceFile().fileName.replace(/\.(ts|js|d\.ts)$/, '');

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject89A8053A-LhjRyN9kxr8o
  • Commit ID: ab908c2
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@mergify
Copy link
Contributor

mergify bot commented Feb 22, 2022

Thank you for contributing! Your pull request will be updated from master and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit 415a17d into aws:master Feb 22, 2022
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

3 participants