-
Notifications
You must be signed in to change notification settings - Fork 7
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
Update tsconfigs & bundling #161
Conversation
🦋 Changeset detectedLatest commit: ac6f911 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
9da39ee
to
a26c210
Compare
a26c210
to
6e40547
Compare
6e40547
to
de7bfbd
Compare
Oh, just realize that this'll break #150 again. Shouldn't be hard fix though. |
Took a look, we'll just need to add |
d60d842
to
2ab1c49
Compare
I realized I had a question about this: do we want sourcemaps? It'd be even smaller to get rid of them, and I don't see how they'd help debug for an eslint config, but I'll leave that up to you. |
@lishaduck yeah, i don't think we want to export sourcemaps, the end user doesn't need them. |
Do you happen to know the difference between using the |
So, it was all bundled before. The dependencies fields made zero difference. Making it a devdep made it so that it didn't try to install, but it was still there. This PR makes it so that you only bundle the library, not the dependencies. As |
I don't think this is correct. Adding a dep as devDependency makes TSUP bundle it inline.
This is the reason. Or did i misunderstood something? |
Yeah, but it would've been there either way. The issue was with npm.
Huh. That wasn't what I was seeing. It looked like it was bundling all of it. Either I misunderstood it, or it was buggy. Probably the former 🤷♂️ 😬 |
Ok, I looked at the source, it seems like the CLI defaults to not bundling node_modules, but the API does, and the default in the presence of a config is (maybe) to bundle them? I didn't look super closely. |
2ab1c49
to
357856e
Compare
"main": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"node": "./dist/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm ok with "exports", it's better than "main", but i didn't know you could specify "node" here. I'll look up the docs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looked the docs.
It says:
"node" - matches for any Node.js environment. Can be a CommonJS or ES module file. In most cases explicitly calling out the Node.js platform is not necessary.
So maybe that's not necessary? Would be the same as default? Or not putting anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I assumed it acted like a bin, but I'm not sure why 🤷♂️
Yeah, default should work fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, we should refactor this then.
"compilerOptions": { | ||
"composite": false, | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this? You wrote "moduleResolution": "bundler"
in all other configs, why just not having it here instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I assumed that they were all different (not all of them are bundled), but everything else (i.e., Node16
) breaks. I can recentralize it if desired.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mmm, what's the point of this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We bundle sheriff-types so that the esm/cjs split is respected.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
treeshake and minify seems a bit overkill for a single 100-lines file with just a bunch of hard-coded strings in it. Also keeping it non-minified can be good for letting the consumer debugging easier (also raw strings don' get minifed anyway, so what's the point?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In constants, yes, but I figured keeping them all consistent was convenient, and I didn't notice a difference in compile times.
I figured that for strings, minification wouldn't minify them, so it didn't make a major debugging hurdle.
@lishaduck also this needs to be updated and conflicts resolved. |
I'll get to it next week 🤞1 Footnotes
|
"main": "dist/index.js", | ||
"exports": { | ||
".": { | ||
"node": "./dist/index.js" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ya, we should refactor this then.
"lib": ["ES2021"], | ||
"module": "ESNext", | ||
"moduleResolution": "Bundler", | ||
"allowImportingTsExtensions": true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what problem is this solving? Any specific type error that arised?
"clean": true, | ||
"target": "node20", | ||
"skipNodeModulesBundle": true, | ||
"noExternal": ["@sherifforg/constants"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, but in tandem we should also revert the old fix that i did, meaning bringing back this dep to the regular deps instead of devdeps
"clean": true, | ||
"target": "node20", | ||
"skipNodeModulesBundle": true, | ||
"noExternal": ["@sherifforg/constants"], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great, but in tandem we should also revert the old fix that i did, meaning bringing back this dep to the regular deps instead of devdeps
"compilerOptions": { | ||
"composite": false, | ||
"target": "ESNext", | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yes please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we also remove these from everywhere?
"skipNodeModulesBundle": true,
"minify": true,
"replaceNodeEnv": true,
"treeshake": "recommended",
"removeNodeProtocol": false
Some of these apis aren't even documented anywhere, i have no clue what they do or what problem do they solve.
Treeshake: i don't think has any usecase here.
Minify: i would avoid because it risks of hiding the compiled code.
This stuff seems to be unnecessary and add complexity to the whole without adding any tangible value.
|
|
|
I also discovered that the CJS build is broken by default, we need to enable |
But in the docs it says:
Also:
Can you be more specific on how it's broken? Any stacktrace? |
Correct. I think it's a bug. I'll look into it sometime when I have some time.
I haven't used the CJS build, so I don't have a stacktrace, but I recall noticing that it emits the |
I just built // src/index.ts
var src_default = getExportableConfig;
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
allJsExtensions,
allJsxExtensions,
baseNoRestrictedSyntaxRules,
ignores,
sheriff,
sheriffStartingOptions,
supportedFileTypes,
testsFilePatterns
}); I'm no master of Commonjs syntax but i think |
It's missing an |
i guess this is pretty much this issue. |
So then we can add the |
That was the goal, to get |
Just if you're curious, this is a good read: https://blog.isquaredsoftware.com/2023/08/esm-modernization-lessons/ I just refound it, and it was quite useful. |
Oh yeah, i remember this, read this last year. Bu thanks!
I'm really looking forward to merge all your open PRs, sorry for the conflicts >_< |
It's fine :)
I think that already got merged in #158 |
We updated the dependency but didn't actually added the watch script to "listen" to |
Here we go #227 |
Depends on #158.
Diff: lishaduck/sheriff@bump-deps...updatetsconfigs