Skip to content

chore(aws-cdk-lib): two import styles confuse Rosetta#17588

Merged
mergify[bot] merged 6 commits intomasterfrom
huijbers/ubergen-imports-consistent
Nov 19, 2021
Merged

chore(aws-cdk-lib): two import styles confuse Rosetta#17588
mergify[bot] merged 6 commits intomasterfrom
huijbers/ubergen-imports-consistent

Conversation

@rix0rrr
Copy link
Copy Markdown
Contributor

@rix0rrr rix0rrr commented Nov 19, 2021

We currently allow two different import styles for our monopackage:

import { aws_ec2 } from 'aws-cdk-lib';
import * as aws_ec2 from 'aws-cdk-lib/aws-ec2';

However, the way this is currently implemented breaks the source
analysis performed by Rosetta on examples. Rosetta will only be
able to trace the first of these to the submodule that is being
imported. The second style actually is a completely different JavaScript
file that "represents" the export, and the tracing will break.

Today these resolve to:

import { aws_ec2 } from "aws-cdk-lib";

------> aws-cdk-lib/lib/aws-ec2/index.ts

import * as aws_ec2 from "aws-cdk-lib/aws-ec2";

------> aws-cdk-lib/aws-ec2.ts

This PR changes the layout of the package generated by ubergen to have
the submodule directories at the root, so that the imports resolve the
same:

// aws-cdk-lib/index.ts
export * as aws_ec2 from './aws-ec2';

// aws-cdk-lib/aws-ec2/index.ts
module_contents_here();

This means we now collect all submodules into the root of aws-cdk-lib and monocdk, instead of into
the lib subdirectory. It makes the gitignore config slightly different from the ones we usually have (but arguably better).


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

We currently allow two different import styles for our monopackage:

```ts
import { aws_ec2 } from 'aws-cdk-lib';
import * as aws_ec2 from 'aws-cdk-lib/aws-ec2';
```

However, the way this is currently implemented breaks the source
analysis performed by Rosetta on examples. Rosetta will only be
able to trace the first of these to the submodule that is being
imported. The second style actually is a completely different JavaScript
file that "represents" the export, and the tracing will break.

Today these resolve to:

```
import { aws_ec2 } from "aws-cdk-lib";

------> aws-cdk-lib/lib/aws-ec2/index.ts

import * as aws_ec2 from "aws-cdk-lib/aws-ec2";

------> aws-cdk-lib/aws-ec2.ts
```

This PR changes the layout of the package generated by `ubergen` to have
the submodule directories at the root, so that the imports resolve the
same:

```ts
// aws-cdk-lib/index.ts
export * as aws_ec2 from './aws-ec2';

// aws-cdk-lib/aws-ec2/index.ts
module_contents_here();
```
@rix0rrr rix0rrr requested a review from a team November 19, 2021 11:06
@rix0rrr rix0rrr self-assigned this Nov 19, 2021
@gitpod-io
Copy link
Copy Markdown

gitpod-io bot commented Nov 19, 2021

@github-actions github-actions bot added the aws-cdk-lib Related to the aws-cdk-lib package label Nov 19, 2021
@mergify mergify bot added the contribution/core This is a PR that came from AWS. label Nov 19, 2021
@rix0rrr rix0rrr force-pushed the huijbers/ubergen-imports-consistent branch from 0d91787 to 70881e9 Compare November 19, 2021 11:34
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 19, 2021

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).

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

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

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

@mergify mergify bot merged commit 281e63b into master Nov 19, 2021
@mergify mergify bot deleted the huijbers/ubergen-imports-consistent branch November 19, 2021 13:43
@mergify
Copy link
Copy Markdown
Contributor

mergify bot commented Nov 19, 2021

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).

TikiTDO pushed a commit to TikiTDO/aws-cdk that referenced this pull request Feb 21, 2022
We currently allow two different import styles for our monopackage:

```ts
import { aws_ec2 } from 'aws-cdk-lib';
import * as aws_ec2 from 'aws-cdk-lib/aws-ec2';
```

However, the way this is currently implemented breaks the source
analysis performed by Rosetta on examples. Rosetta will only be
able to trace the first of these to the submodule that is being
imported. The second style actually is a completely different JavaScript
file that "represents" the export, and the tracing will break.

Today these resolve to:

```
import { aws_ec2 } from "aws-cdk-lib";

------> aws-cdk-lib/lib/aws-ec2/index.ts

import * as aws_ec2 from "aws-cdk-lib/aws-ec2";

------> aws-cdk-lib/aws-ec2.ts
```

This PR changes the layout of the package generated by `ubergen` to have
the submodule directories at the root, so that the imports resolve the
same:

```ts
// aws-cdk-lib/index.ts
export * as aws_ec2 from './aws-ec2';

// aws-cdk-lib/aws-ec2/index.ts
module_contents_here();
```

This means we now collect all submodules into the *root* of `aws-cdk-lib` and `monocdk`, instead of into
the `lib` subdirectory. It makes the gitignore config slightly different from the ones we usually have (but arguably better).

----

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

aws-cdk-lib Related to the aws-cdk-lib package contribution/core This is a PR that came from AWS.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants