Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

feat: add package.json exports for public packages#6458

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
bradzacher merged 10 commits intov6from6050-package-exports
Feb 22, 2023

Conversation

bradzacher
Copy link
Member

BREAKING CHANGE:
Restricts API surface by strictly defining package.json exports for each package

PR Checklist

Overview

Configures option 3 from#6050 - where we completely lock down our API so people cannot access ourdist folder any more.

Currently blocked onJoshuaKGoldberg/ts-api-utils#54

@bradzacherbradzacher added breaking changeThis change will require a new major version to be released repo maintenancethings to do with maintenance of the repo, and not with code/docs labelsFeb 13, 2023
@bradzacherbradzacher added this to the6.0.0 milestoneFeb 13, 2023
@typescript-eslint
Copy link
Contributor

Thanks for the PR,@bradzacher!

typescript-eslint is a 100% community driven project, and we are incredibly grateful that you are contributing to that community.

The core maintainers work on this in their personal time, so please understand that it may not be possible for them to review your work immediately.

Thanks again!


🙏Please, if you or your company is finding typescript-eslint valuable, help us sustain the project by sponsoring it transparently onhttps://opencollective.com/typescript-eslint.

@nx-cloud
Copy link

nx-cloudbot commentedFeb 13, 2023
edited
Loading

☁️ Nx Cloud Report

CI is running/has finished running commands for commit00af53f. As they complete they will appear below. Click to see the status, the terminal output, and the build insights.

📂 See all runs for this branch


✅ Successfully ran 51 targets

Sent with 💌 fromNxCloud.

@codecov
Copy link

codecovbot commentedFeb 13, 2023
edited
Loading

Codecov Report

Merging#6458 (00af53f) intov6 (fc2df63) willincrease coverage by0.00%.
The diff coverage is100.00%.

Additional details and impacted files
@@           Coverage Diff           @@##               v6    #6458   +/-   ##=======================================  Coverage   87.05%   87.06%           =======================================  Files         365      365             Lines       12580    12579    -1       Branches     3720     3720           =======================================  Hits        10952    10952             Misses       1278     1278+ Partials      350      349    -1
FlagCoverage Δ
unittest87.06% <100.00%> (+<0.01%)⬆️

Flags with carried forward coverage won't be shown.Click here to find out more.

Impacted FilesCoverage Δ
.../eslint-plugin/src/rules/prefer-ts-expect-error.ts100.00% <ø> (ø)
...lugin-internal/src/rules/plugin-test-formatting.ts79.76% <100.00%> (ø)
packages/eslint-plugin/src/util/astUtils.ts88.88% <100.00%> (ø)
...s/eslint-plugin/src/util/collectUnusedVariables.ts93.16% <100.00%> (-0.03%)⬇️
...s/utils/src/eslint-utils/rule-tester/RuleTester.ts70.23% <100.00%> (ø)
packages/eslint-plugin/src/rules/no-mixed-enums.ts95.83% <0.00%> (+1.38%)⬆️

@bradzacher
Copy link
MemberAuthor

Hmm.. I can't reproduce the typecheck failure locally... There's no reason it shouldn't work considering it's not the ESM version of the package.

Maybe there's an issue with the CI getting the wrong version? Idk why it would be different to local considering it's covered by the yarn.lock

@bradzacherbradzacher marked this pull request as ready for reviewFebruary 14, 2023 08:46
Copy link
Member

@JoshuaKGoldbergJoshuaKGoldberg left a comment

Choose a reason for hiding this comment

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

Glorious, I love it. 👏

Left some suggestions inline but they're all nice-to-haves IMO.

"license": "MIT",
"author": "Josh Goldberg <npm@joshuakgoldberg.com>",
-"type": "module",
+"type": "commonjs",

Choose a reason for hiding this comment

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

Should be fixed inJoshuaKGoldberg/ts-api-utils#37 ->ts-api-utils@0.0.22.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

I guess the issue now is that TS won't let us import this file because it seestype: 'module' and our project istype: 'commonjs'

Choose a reason for hiding this comment

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

We could switch totype: 'module' 😈

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

Yup - we can't import the package without this patch.
TS looks attype: module and treats it as an exclusively esm package, erroring:

src/convert-comments.ts:1:24 - 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'. Consider writing a dynamic 'import("ts-api-utils")' call instead.  To convert this file to an ECMAScript module, change its file extension to '.mts' or create a local package.json file with `{ "type": "module" }`.       1 import * as tools from 'ts-api-utils';                          ~~~~~~~~~~~~~~

So we'll need to keep this patch (in perpetuity?)
Maybe this needs to be changed in the package so it doesn't listtype?

Copy link
Member

@JoshuaKGoldbergJoshuaKGoldbergFeb 22, 2023
edited
Loading

Choose a reason for hiding this comment

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

Hmm, I suppose we could take an issue in ts-api-utils. But I do wonder what the actual blockers to typescript-eslint going ESM are.

Copy link
MemberAuthor

@bradzacherbradzacherFeb 22, 2023
edited
Loading

Choose a reason for hiding this comment

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

I do wonder what the actual blockers to typescript-eslint going ESM are.

In order for CJS to load ESM, it must use animport() expression.

ESLlint is CJS and does not useimport() to load plugins - it usesrequire (viacreateRequire[1])
https://github.com/eslint/eslintrc/blob/main/lib/config-array-factory.js#L1086
https://github.com/eslint/eslintrc/blob/main/lib/config-array-factory.js#L984

So we need to export a CJS API from our packages. Now we could get around that and use ESM with a CJS facade in front of an ESM package and leverageimport() expressions to load the ESM "backend", however our plugin and parser need to have fully synchronous APIs to adhere to the ESLint requirements.

Because the plugin needs to be CJS, all our lint utilities (utils,type-utils,scope-manager, etc) need to be CJS.
Because the parser needs to be CJS, all our parser utilities (visitor-keys,typescript-estree, etc) need to be CJS.

So for now we're firmly stuck as a project shipping CJS :(

@bradzacherbradzacher merged commitd676683 intov6Feb 22, 2023
@bradzacherbradzacher deleted the 6050-package-exports branchFebruary 22, 2023 04:19
@github-actionsgithub-actionsbot locked asresolvedand limited conversation to collaboratorsMar 2, 2023
Sign up for freeto subscribe to this conversation on GitHub. Already have an account?Sign in.
Reviewers

@fiskerfiskerfisker left review comments

@armano2armano2armano2 left review comments

@JoshuaKGoldbergJoshuaKGoldbergJoshuaKGoldberg approved these changes

Assignees
No one assigned
Labels
breaking changeThis change will require a new major version to be releasedrepo maintenancethings to do with maintenance of the repo, and not with code/docs
Projects
None yet
Milestone
6.0.0
Development

Successfully merging this pull request may close these issues.

4 participants
@bradzacher@fisker@armano2@JoshuaKGoldberg

[8]ページ先頭

©2009-2025 Movatter.jp