Skip to content

feat(jsii): introduce submodules feature#1297

Merged
RomainMuller merged 26 commits into
masterfrom
rmuller/submodules
Mar 19, 2020
Merged

feat(jsii): introduce submodules feature#1297
RomainMuller merged 26 commits into
masterfrom
rmuller/submodules

Conversation

@RomainMuller
Copy link
Copy Markdown
Contributor

@RomainMuller RomainMuller commented Feb 27, 2020

Commit Message

feat(jsii): introduce submodules feature (#1297)

Introduces a jsii Submodule feature. Submodules are introduced
by declaring a namespace:

// Using a namespaced export statement
export * as ns from './subfolder';

// Using a namespace declaration
export ns {
  // ...
}

Submodules can be nested in other submodules, but the
dependency graph between submodules (and the top-level module)
must not result in a cycle (jsii` does currently not check for this
particular issue, although it probably will in the future).

Although this is out-of-scope for this change, they could be
enhanced so a specific README.md is attached to them, and so
that dedicated code-generating configuration can be specified.

Fixes #1286

End Commit Message


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

@RomainMuller RomainMuller added feature-request A feature should be added or improved. module/compiler Issues affecting the JSII compiler labels Feb 27, 2020
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 6e08662
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

Copy link
Copy Markdown
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Is this already magically supported by all code generators?

Comment thread packages/jsii/lib/assembler.ts Outdated
Comment thread packages/jsii/lib/assembler.ts Outdated
Comment thread packages/jsii/lib/assembler.ts Outdated
Comment thread packages/jsii/lib/assembler.ts
Comment thread packages/jsii/lib/assembler.ts
Comment thread packages/jsii/lib/assembler.ts
Comment thread packages/jsii/lib/assembler.ts
Comment thread packages/jsii/lib/assembler.ts Outdated
this._namespaceMap.set(symbol, ns);

const decl = symbol.declarations?.[0];
if (decl != null
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

add a comment such as "if this is a supported jsii type"...

Also, do we want a warning if it's not?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I don't think the warning is useful (exports that cannot be modeled by jsii are logged somewhere else as part of the next pass).

Comment thread packages/jsii/lib/assembler.ts Outdated
@mergify mergify Bot added the contribution/core This is a PR that came from AWS. label Mar 2, 2020
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 8161f8f
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 18d854b
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: bfcdc22
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 4cd2e17
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: bbb7406
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: c8bfb68
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: eecc965
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@RomainMuller RomainMuller marked this pull request as ready for review March 12, 2020 14:00
@RomainMuller RomainMuller requested a review from a team as a code owner March 12, 2020 14:00
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: e0343da
  • Result: FAILED
  • Build Logs (available for 30 days)

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

Copy link
Copy Markdown
Contributor

@eladb eladb left a comment

Choose a reason for hiding this comment

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

Can't really review this. I wish you hadn't moved around all of the compliance test types which invalidated 100% of our snapshots.

If it's reasonable to ask, I would revert all changes to jsii-calc and friends and only add a few additional tests to verify submodules. This will make it much easier to actually review how this code behaves.

Comment thread docs/specifications/2-type-system.md Outdated

export * as ns1 from './namespaced';

export class Ns1 {
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Would my_module and myModule collide as well?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes. I guess I could add more coverage on this... Initially I only guarded against PascalCase / camelCase collisions, but figured Java & Python would use snake_case.

if (colliding != null) {
const submoduleDecl = submodule.valueDeclaration ?? submodule.declarations[0];
this._diagnostic(node, ts.DiagnosticCategory.Error,
`Submodule "${submodule.name}" conflicts with "${jsiiType.name}". Restricted names are: ${candidates.join(', ')}`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I guess top level types should always be pascal case (interfaces, classes, enums), so I think by definition they can't conflict with namespace names...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

They can because the conflict space is PascalCase (preferred for C#), camelCase (preferred for JS), snake_case (preferred for Python & Java).

Comment thread packages/jsii-reflect/test/__snapshots__/jsii-tree.test.js.snap Outdated
Co-Authored-By: Elad Ben-Israel <benisrae@amazon.com>
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 2d4aa0f
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 318c67e
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: c8d7514
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: fd2d41a
  • Result: FAILED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 72877ca
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@RomainMuller RomainMuller requested a review from eladb March 16, 2020 16:51
@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 4f26cce
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: 09b567b
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@RomainMuller RomainMuller removed the request for review from MrArnoldPalmer March 19, 2020 13:28
Comment on lines +5 to +12
export enum Goodness {
/** It's pretty good */
PRETTY_GOOD,
/** It's really good */
REALLY_GOOD,
/** It's amazingly good */
AMAZINGLY_GOOD
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Optimistic today, aren't we? :-D

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

}

public dependsOnModules(resolver: TypeResolver) {
resolver = this.fqn ? resolver.bind(this.fqn, this.pythonName) : resolver;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

this.boundResolver?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

That's not a thing on this particular type, due to peculiarities in the inheritance chain here.

@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 19, 2020

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

1 similar comment
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 19, 2020

Thank you for contributing! ❤️ I will now look into making sure the PR is up-to-date, then proceed to try and merge it!

@mergify mergify Bot added the pr/ready-to-merge This PR is ready to be merged. label Mar 19, 2020
@mergify
Copy link
Copy Markdown
Contributor

mergify Bot commented Mar 19, 2020

Merging (with squash)...

@aws-cdk-automation
Copy link
Copy Markdown
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildProject6AEA49D1-Blkkw9bQFn8A
  • Commit ID: b42349d
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

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

@RomainMuller RomainMuller merged commit 2df5d90 into master Mar 19, 2020
@RomainMuller RomainMuller deleted the rmuller/submodules branch March 19, 2020 15:29
@mergify mergify Bot removed the pr/ready-to-merge This PR is ready to be merged. label Mar 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contribution/core This is a PR that came from AWS. feature-request A feature should be added or improved. module/compiler Issues affecting the JSII compiler

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Submodules

3 participants