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

Submodules #1286

Closed
4 tasks done
eladb opened this issue Feb 23, 2020 · 1 comment · Fixed by #1297
Closed
4 tasks done

Submodules #1286

eladb opened this issue Feb 23, 2020 · 1 comment · Fixed by #1297
Assignees
Labels
effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.

Comments

@eladb
Copy link
Contributor

eladb commented Feb 23, 2020

🚀 Feature Request

Affected Languages

  • TypeScript or Javascript
  • Python
  • Java
  • .NET (C#, F#, ...)

Description

We are looking into releasing the entire AWS CDK as a single module (see aws/aws-cdk-rfcs#122).

In order to be able to organize the namespace of that huge single module we need a way to group types into "submodules".

The current way these types are exported is:

import * as aws_s3 from './aws-s3';
export aws_s3;

import * as aws_sns from './aws-sns';
export aws_sns;

This offers a good experience in TypeScript:

import { aws_s3, aws_sns } from 'monocdk';

new aws_s3.Bucket(this, ...);

We need this to translate properly to all supported jsii languages.

Proposed Solution

A few things to consider:

  1. What are we doing with submodule README files? How do we model them inside the jsii manifest? Maybe we need an entry for the submodule itself.
  2. Ideally we want to be able to control the name of the submodule per-language. For example, Java submodules should translate into java package names, and we wish to keep the java package names in tact as we bundle all of the code into a single JAR. This means that we can't just use the name of the TypeScript submodule but rather need some form of translation table. It could be a custom jsdocs attribute such as @java.package foo.bar.foo.
@eladb eladb added the feature-request A feature should be added or improved. label Feb 23, 2020
@eladb eladb removed their assignment Feb 25, 2020
@CaerusKaru
Copy link
Contributor

We could add a pacmak.json configuration which would allow for per-package name manipulation as well as any other package-level info needed for other languages but not necessarily for Node/NPM.

@RomainMuller RomainMuller added the effort/large Large work item – several weeks of effort label Mar 12, 2020
RomainMuller added a commit that referenced this issue Mar 19, 2020
Introduces a `jsii` *Submodule* feature. *Submodules* are introduced
by declaring a `namespace`:
```ts
// 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
mergify bot pushed a commit that referenced this issue May 27, 2020
Introduces a new `.jsiirc.json` file leveraged by sumodules defined
using the `export * as namespace from './namespace';`  syntax. The
`.jsiirc.json` file is a sibling to what `./namespace` resolves to (since
this typically resolves to `./namespace/index.ts`, the `.jsiirc.json` file
must be at `./namespace/.jsiirc.json`).

The `targets` key can je set within this `.jsiirc.json` document and
include specific configuration for various targets:

```js
{
  "targets": {
    "dotnet": {
      // Only the "namespace" key is considered/supported at this point
      "namespace": "Some.DotNet.Namespace"
    },
    "java": {
      // Only the "package" key is considered/supported at this point
      "package": "some.java.package_name"
    },
    "python": {
      // Only the "module" key is considered/supported at this point
      // The configured module name for a submodule _MUST_ be nested
      // under the root module name for the package.
      "module": "some.module_name"
    }
  }
}
```

Related to #1286 

---

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

[Apache 2.0 license]: https://www.apache.org/licenses/LICENSE-2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
effort/large Large work item – several weeks of effort feature-request A feature should be added or improved.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants