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

[lit] Add "types" to package exports #3320

Merged
merged 3 commits into from Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/red-jars-float.md
@@ -0,0 +1,5 @@
---
'lit': patch
---

The `lit` package now specifies and "types" export condition allowing TypeScript `moduleResolution` to be `nodenext`.
79 changes: 79 additions & 0 deletions packages/lit/package.json
Expand Up @@ -18,120 +18,198 @@
"type": "module",
"exports": {
".": {
"types": "./development/index.d.ts",
"development": "./development/index.js",
"default": "./index.js"
},
"./async-directive.js": {
"types": "./development/async-directive.d.ts",
"development": "./development/async-directive.js",
"default": "./async-directive.js"
},
"./decorators.js": {
"types": "./development/decorators.d.ts",
"development": "./development/decorators.js",
"default": "./decorators.js"
},
"./decorators/custom-element.js": {
"types": "./development/decorators/custom-element.d.ts",
"development": "./development/decorators/custom-element.js",
"default": "./decorators/custom-element.js"
},
"./decorators/event-options.js": {
"types": "./development/decorators/event-options.d.ts",
"development": "./development/decorators/event-options.js",
"default": "./decorators/event-options.js"
},
"./decorators/property.js": {
"types": "./development/decorators/property.d.ts",
"development": "./development/decorators/property.js",
"default": "./decorators/property.js"
},
"./decorators/query-all.js": {
"types": "./development/decorators/query-all.d.ts",
"development": "./development/decorators/query-all.js",
"default": "./decorators/query-all.js"
},
"./decorators/query-assigned-elements.js": {
"types": "./development/decorators/query-assigned-elements.d.ts",
"development": "./development/decorators/query-assigned-elements.js",
"default": "./decorators/query-assigned-elements.js"
},
"./decorators/query-assigned-nodes.js": {
"types": "./development/decorators/query-assigned-nodes.d.ts",
"development": "./development/decorators/query-assigned-nodes.js",
"default": "./decorators/query-assigned-nodes.js"
},
"./decorators/query-async.js": {
"types": "./development/decorators/query-async.d.ts",
"development": "./development/decorators/query-async.js",
"default": "./decorators/query-async.js"
},
"./decorators/query.js": {
"types": "./development/decorators/query.d.ts",
"development": "./development/decorators/query.js",
"default": "./decorators/query.js"
},
"./decorators/state.js": {
"types": "./development/decorators/state.d.ts",
"development": "./development/decorators/state.js",
"default": "./decorators/state.js"
},
"./directive-helpers.js": {
"types": "./development/directive-helpers.d.ts",
"development": "./development/directive-helpers.js",
"default": "./directive-helpers.js"
},
"./directive.js": {
"types": "./development/directive.d.ts",
"development": "./development/directive.js",
"default": "./directive.js"
},
"./directives/async-append.js": {
"types": "./development/directives/async-append.d.ts",
"development": "./development/directives/async-append.js",
"default": "./directives/async-append.js"
},
"./directives/async-replace.js": {
"types": "./development/directives/async-replace.d.ts",
"development": "./development/directives/async-replace.js",
"default": "./directives/async-replace.js"
},
"./directives/cache.js": {
"types": "./development/directives/cache.d.ts",
"development": "./development/directives/cache.js",
"default": "./directives/cache.js"
},
"./directives/choose.js": {
"types": "./development/directives/choose.d.ts",
"development": "./development/directives/choose.js",
"default": "./directives/choose.js"
},
"./directives/class-map.js": {
"types": "./development/directives/class-map.d.ts",
"development": "./development/directives/class-map.js",
"default": "./directives/class-map.js"
},
"./directives/guard.js": {
"types": "./development/directives/guard.d.ts",
"development": "./development/directives/guard.js",
"default": "./directives/guard.js"
},
"./directives/if-defined.js": {
"types": "./development/directives/if-defined.d.ts",
"development": "./development/directives/if-defined.js",
"default": "./directives/if-defined.js"
},
"./directives/join.js": {
"types": "./development/directives/join.d.ts",
"development": "./development/directives/join.js",
"default": "./directives/join.js"
},
"./directives/keyed.js": {
"types": "./development/directives/keyed.d.ts",
"development": "./development/directives/keyed.js",
"default": "./directives/keyed.js"
},
"./directives/live.js": {
"types": "./development/directives/live.d.ts",
"development": "./development/directives/live.js",
"default": "./directives/live.js"
},
"./directives/map.js": {
"types": "./development/directives/map.d.ts",
"development": "./development/directives/map.js",
"default": "./directives/map.js"
},
"./directives/range.js": {
"types": "./development/directives/range.d.ts",
"development": "./development/directives/range.js",
"default": "./directives/range.js"
},
"./directives/ref.js": {
"types": "./development/directives/ref.d.ts",
"development": "./development/directives/ref.js",
"default": "./directives/ref.js"
},
"./directives/repeat.js": {
"types": "./development/directives/repeat.d.ts",
"development": "./development/directives/repeat.js",
"default": "./directives/repeat.js"
},
"./directives/style-map.js": {
"types": "./development/directives/style-map.d.ts",
"development": "./development/directives/style-map.js",
"default": "./directives/style-map.js"
},
"./directives/template-content.js": {
"types": "./development/directives/template-content.d.ts",
"development": "./development/directives/template-content.js",
"default": "./directives/template-content.js"
},
"./directives/unsafe-html.js": {
"types": "./development/directives/unsafe-html.d.ts",
"development": "./development/directives/unsafe-html.js",
"default": "./directives/unsafe-html.js"
},
"./directives/unsafe-svg.js": {
"types": "./development/directives/unsafe-svg.d.ts",
"development": "./development/directives/unsafe-svg.js",
"default": "./directives/unsafe-svg.js"
},
"./directives/until.js": {
"types": "./development/directives/until.d.ts",
"development": "./development/directives/until.js",
"default": "./directives/until.js"
},
"./directives/when.js": {
"types": "./development/directives/when.d.ts",
"development": "./development/directives/when.js",
"default": "./directives/when.js"
},
"./experimental-hydrate-support.js": {
"types": "./development/experimental-hydrate-support.d.ts",
"development": "./development/experimental-hydrate-support.js",
"default": "./experimental-hydrate-support.js"
},
"./experimental-hydrate.js": {
"types": "./development/experimental-hydrate.d.ts",
"development": "./development/experimental-hydrate.js",
"default": "./experimental-hydrate.js"
},
"./html.js": {
"types": "./development/html.d.ts",
"development": "./development/html.js",
"default": "./html.js"
},
"./polyfill-support.js": {
"types": "./development/polyfill-support.d.ts",
"development": "./development/polyfill-support.js",
"default": "./polyfill-support.js"
},
"./static-html.js": {
"types": "./development/static-html.d.ts",
"development": "./development/static-html.js",
"default": "./static-html.js"
Copy link
Member

@aomarks aomarks Sep 29, 2022

Choose a reason for hiding this comment

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

I don't think we need development for lit, because all the differences are in the underlying packages

Copy link
Member Author

Choose a reason for hiding this comment

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

I agree that it's no different than the default build. The types field does need to point to the ./development/* directory for the self reference to work during build time since that is the specified outDir so I did have to add the entire /development/ directory to the published package. We could possibly just include the d.ts and d.ts.map files there.

I noticed some of the labs packages also include the (unnecessary) "development" export probably just from copy pasting so I opted to just follow that here too.

An alternative, and perhaps arguably more sensible, thing to do might be to change the tsc outDir to emit directly to the package root and not do the treemirror copy for the packages that don't need a development build but that seemed like extra work and I wasn't sure if that would require tweaking the rollup config as well.

Copy link
Collaborator

Choose a reason for hiding this comment

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

An alternative, and perhaps arguably more sensible, thing to do might be to change the tsc outDir to emit directly to the package root and not do the treemirror copy for the packages that don't need a development build but that seemed like extra work and I wasn't sure if that would require tweaking the rollup config as well.

+1 to that, the minified files in lit only save a couple of spaces and newlines.

But also +1 to not trying to do that first to fix the tests. This change seems reasonable to me given that we currently compile to /development/, Rollup to the default location, and treemirror in the types, just like in lit-html, etc.

Copy link
Member Author

Choose a reason for hiding this comment

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

I went ahead and removed the "development" export conditions from the lit package since there's nothing different in those so no need to even include them in package.json. I'm still keeping the existing tsc output directory and rollup since I don't want to mess with that, and therefore "types" export will still point to ./development/*.d.ts and the /development/ directory output will be included in the npm package for those. I think that's a good compromise for now.

}
},
Expand Down Expand Up @@ -284,6 +362,7 @@
"/static-html.{d.ts.map,d.ts,js.map,js}",
"/decorators/",
"/directives/",
"/development/",
"/logo.svg"
],
"dependencies": {
Expand Down