-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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: export package.json and dist/svgo.browser.js again #1999
Conversation
@@ -59,10 +59,15 @@ | |||
"require": "./dist/svgo-node.cjs", | |||
"types": "./lib/svgo-node.d.ts" | |||
}, | |||
"./dist/svgo.browser.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.
If I'm not mistaken, that this will still fail if one requires dist/svgo.browser
. We might need to tweak it.
Hmm, we could do something like this: "exports": {
".": {
"import": "./lib/svgo-node.js",
"require": "./dist/svgo-node.cjs",
"types": "./lib/svgo-node.d.ts"
},
"./browser": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./dist/svgo.browser": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./bin/*": "./bin/*",
"./dist/*": "./dist/*",
"./lib/*": "./lib/*",
"./plugins/*": "./plugins/*",
"./package.json": "./package.json"
}, We could also do: "exports": {
".": {
"import": "./lib/svgo-node.js",
"require": "./dist/svgo-node.cjs",
"types": "./lib/svgo-node.d.ts"
},
"./browser": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./dist/svgo.browser": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./*": "./*"
}, However, this will only make the imports available with the Alternatively, it could be worth deprecated v3.3.0 and v3.3.1, and making a new release v3.3.2 which reverts the changes. Then we make a v4.0.0 release, with less concern over breaking changes. (A lot of people are very keen to see I'm leaning on the latter, and will have a tag ready to push/release. However, I'll leave room for discussion before I do anything. |
Agreed, @SethFalco the latter is the best choice. But while at it, we should look into any other major changes slated for v4 like dropping any Node.js version support |
The Because "exports": {
".": {
"import": "./lib/svgo-node.js",
"require": "./dist/svgo-node.cjs",
"types": "./lib/svgo-node.d.ts"
},
"./browser": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./dist/svgo.browser.js": {
"import": "./dist/svgo.browser.js",
"types": "./lib/svgo.d.ts"
},
"./*": "./*"
},
"typesVersions": {
"*": {
".": [
"./lib/svgo-node.d.ts"
],
"browser": [
"./lib/svgo.d.ts"
],
"dist/svgo.browser.js": [
"./lib/svgo.d.ts"
]
}
} |
Now that we're committed to do a v4 release instead, I'm thinking we could close this, and make the change in imports one of the documented breaking changes. That way, there's no need to define the aliases and duplicate type versions. I'll also have to look into ensuring that everything that users would want to import is still convenient to import, like individual plugins potentially. If there are no qualms with that, feel free to close the issue. Otherwise, hit me with any feedback! |
Sounds good! Let's document the changes for the release notes |
Actually, I still think we need package.json there, don't we @SethFalco ? |
As far as I'm concerned, I noticed in the other issue that it looked like you were importing it, though. Mind sharing your use case and we'll see if it makes sense, or maybe SVGO could do something better to export what is it you need? For example, if you want the SVGO version at runtime, then this is something we could export ourselves. |
We use it in svgomg for the version only during build time: |
Understood, instead of exporting import { version } from "react";
import _ from "lodash";
import axios from "axios";
console.log(version, _.VERSION, axios.VERSION);
// 18.3.1 4.17.21 1.6.8 I'll write up an issue later today, and can do the PR this weekend too. Thanks for being so active with pull requests and issues, by the way. I'll be reviewing them over the next few days as I find time between other tasks. |
Fixes #1998