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

fix(scoped-elements): remove types.js from exports #2655

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bennypowers
Copy link
Member

@bennypowers bennypowers commented Apr 3, 2023

What I did

  1. remove types.js from package exports, as we have both types export condition (nodenext) and top-level "types" fallback

Reviewer Notes

This may require a major changeset

@changeset-bot
Copy link

changeset-bot bot commented Apr 3, 2023

⚠️ No Changeset found

Latest commit: b5b27b8

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

@Westbrook
Copy link
Contributor

This removes the export map, but are these types still built? That could mean, at least internally, they are still used and that the test results could be a false positive...

@bennypowers
Copy link
Member Author

@Westbrook help me understand what's the problem if internal types are still built. You're saying that tests would pass here in CI because those files are available to monorepo packages, but would fail for users that npm i'd?

If so, would a repro that installs this version and passes some import tests assuage your concerns?

@Westbrook
Copy link
Contributor

Roughly. We should check to see if the files are still being written and if they are, can we stop that and still have this pass?

@bennypowers
Copy link
Member Author

bennypowers commented Apr 21, 2023

https://github.com/bennypowers/scoped-ce-repro-no-typesjs-export

using yarn link

image

passes with moduleResolution: node but fails for nodenext:

$ /tmp/scopr/node_modules/.bin/tsc --moduleResolution nodenext
../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:1:53 - error TS1479: The current file is a CommonJS m
odule whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Conside
r writing a dynamic 'import("@open-wc/dedupe-mixin")' call instead.

1 export type ScopedElementsMixin = <T extends import("@open-wc/dedupe-mixin").Constructor<import("@lit/reactive-element").ReactiveElement>>(supercla
ss: T) => T & import("@open-wc/dedupe-mixin").Constructor<import("./types").ScopedElementsHost> & typeof import("./types").ScopedElementsHost;
                                                      ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:1:97 - error TS1479: The current file is a CommonJS m
odule whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Conside
r writing a dynamic 'import("@lit/reactive-element")' call instead.

1 export type ScopedElementsMixin = <T extends import("@open-wc/dedupe-mixin").Constructor<import("@lit/reactive-element").ReactiveElement>>(supercla
ss: T) => T & import("@open-wc/dedupe-mixin").Constructor<import("./types").ScopedElementsHost> & typeof import("./types").ScopedElementsHost;
                                                                                                  ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:1:169 - error TS1479: The current file is a CommonJS 
module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consid
er writing a dynamic 'import("@open-wc/dedupe-mixin")' call instead.

1 export type ScopedElementsMixin = <T extends import("@open-wc/dedupe-mixin").Constructor<import("@lit/reactive-element").ReactiveElement>>(supercla
ss: T) => T & import("@open-wc/dedupe-mixin").Constructor<import("./types").ScopedElementsHost> & typeof import("./types").ScopedElementsHost;
                                                                                                                                                     
                     ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:7:56 - error TS1479: The current file is a CommonJS m
odule whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Conside
r writing a dynamic 'import("@open-wc/dedupe-mixin")' call instead.

7 export function ScopedElementsMixin<T_1 extends import("@open-wc/dedupe-mixin").Constructor<HTMLElement>>(superclass: T_1): T_1 & import("@open-wc/
dedupe-mixin").Constructor<import("./types").ScopedElementsHost>;
                                                         ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:7:138 - error TS1479: The current file is a CommonJS 
module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consid
er writing a dynamic 'import("@open-wc/dedupe-mixin")' call instead.

7 export function ScopedElementsMixin<T_1 extends import("@open-wc/dedupe-mixin").Constructor<HTMLElement>>(superclass: T_1): T_1 & import("@open-wc/
dedupe-mixin").Constructor<import("./types").ScopedElementsHost>;
                                                                                                                                           ~~~~~~~~~~
~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:16:40 - error TS1479: The current file is a CommonJS 
module whose imports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consid
er writing a dynamic 'import("@lit/reactive-element")' call instead.

16 export type CSSResultOrNative = import("@lit/reactive-element").CSSResult | CSSStyleSheet;
                                          ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/types.d.ts:1:29 - error TS1479: The current file is a CommonJS module whose im
ports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dy
namic 'import("@open-wc/dedupe-mixin")' call instead.

1 import { Constructor } from '@open-wc/dedupe-mixin';
                              ~~~~~~~~~~~~~~~~~~~~~~~

../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/types.d.ts:2:33 - error TS1479: The current file is a CommonJS module whose im
ports will produce 'require' calls; however, the referenced file is an ECMAScript module and cannot be imported with 'require'. Consider writing a dy
namic 'import("@lit/reactive-element")' call instead.

2 import { ReactiveElement } from '@lit/reactive-element';
                                  ~~~~~~~~~~~~~~~~~~~~~~~


Found 8 errors in 2 files.

Errors  Files
     6  ../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/ScopedElementsMixin.d.ts:1
     2  ../../home/bennyp/Developer/open-wc/packages/scoped-elements/types/src/types.d.ts:1
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

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

2 participants