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

package.json/ dist/svgo.browser.js are no longer exported #1998

Closed
XhmikosR opened this issue May 9, 2024 · 8 comments
Closed

package.json/ dist/svgo.browser.js are no longer exported #1998

XhmikosR opened this issue May 9, 2024 · 8 comments
Labels

Comments

@XhmikosR
Copy link
Contributor

XhmikosR commented May 9, 2024

Using v3.3.1:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\xmr\Desktop\svgomg\node_modules\svgo\package.json

Adding this in the exports fixes the issue but this means that if people where requiring other things that the ones exported right now, they will be broken:

"./package.json": "./package.json"

There must be a way to export everything again so that it's not a breaking change.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented May 9, 2024

For example:

Could not resolve import "svgo/dist/svgo.browser.js" in C:\Users\xmr\Desktop\svgomg\src\js\svgo-worker\index.js using exports defined in C:\Users\xmr\Desktop\svgomg\node_modules\svgo\package.json.
[08:01:06] Finished 'bound js' after 301 ms
[08:01:06] Finished 'bound js' after 465 ms
Could not resolve import "svgo/dist/svgo.browser.js" in C:\Users\xmr\Desktop\svgomg\src\js\svgo-worker\index.js using exports defined in C:\Users\xmr\Desktop\svgomg\node_modules\svgo\package.json.
'svgo/dist/svgo.browser.js' is imported by src/js/svgo-worker/index.js, but could not be resolved – treating it as an external dependency
No name was provided for external module 'svgo/dist/svgo.browser.js' in output.globals – guessing 'svgo_browser_js'

I can change the imports but this means that the changes in v3.3.0 are indeed breaking. :/

@XhmikosR XhmikosR changed the title package.json is no longer exported package.json/ dist/svgo.browser.js are no longer exported May 9, 2024
@XhmikosR XhmikosR closed this as completed May 9, 2024
@XhmikosR
Copy link
Contributor Author

@SethFalco I just tried 4.0.0-rc here: jakearchibald/svgomg@b2cdb05

And it seems it doesn't work:

C:\Users\xmr\Desktop\svgomg>npm i svgo@4.0.0-rc.0 -D
npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated
npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies

added 982 packages, and audited 1032 packages in 33s

163 packages are looking for funding
  run `npm fund` for details

17 vulnerabilities (1 low, 5 moderate, 10 high, 1 critical)

To address issues that do not require attention, run:
  npm audit fix

To address all issues possible (including breaking changes), run:
  npm audit fix --force

Some issues need review, and may require choosing
a different dependency.

Run `npm audit` for details.

C:\Users\xmr\Desktop\svgomg>npm run dev

> svgomg@1.16.0 dev
> gulp dev

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './package.json' is not defined by "exports" in C:\Users\xmr\Desktop\svgomg\node_modules\svgo\package.json
    at exportsNotFound (node:internal/modules/esm/resolve:303:10)
    at packageExportsResolve (node:internal/modules/esm/resolve:650:9)
    at resolveExports (node:internal/modules/cjs/loader:591:36)
    at Module._findPath (node:internal/modules/cjs/loader:668:31)
    at Module._resolveFilename (node:internal/modules/cjs/loader:1130:27)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (C:\Users\xmr\Desktop\svgomg\gulpfile.js:5:35)
    at Module._compile (node:internal/modules/cjs/loader:1376:14) {
  code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}

Did I miss something or something else is broken?

Thanks!

@SethFalco
Copy link
Member

SethFalco commented Jun 10, 2024

We don't export out package.json!

SVGOMG only used it for the version I believe, so you can do, which is the reason I added it:

const { VERSION } = require('svgo');

PS: A while back I opened a PR to update SVGO there too, but closed it later. In case it's helpful to you, these were the changes I proposed:

@XhmikosR
Copy link
Contributor Author

Damn it, I misread the migration notes :)

So, this works jakearchibald/svgomg@2c5835c

Sorry for the noise!

@XhmikosR
Copy link
Contributor Author

I don't follow the repos I have push rights so unless I'm CC'ed I won't see any issue :)

I'm keeping the xmr-dev branch for now since I have other PRs pending, but I left them as is after reading the new plans.

@SethFalco
Copy link
Member

Sorry for the noise!

Don't be afraid to spam me if anything else comes up! And thanks for trying the RC and querying/reporting problems. Feedback on the release notes is also welcome if you think the issue was the wording.

@XhmikosR
Copy link
Contributor Author

XhmikosR commented Jun 10, 2024

One thing I notice is the lack of extension in the browser export. Not a huge deal, but I prefer always adding an extension (plus xo errors by default for such cases).

Your call though :)

@SethFalco
Copy link
Member

(plus xo errors by default for such cases)

Sorry, could you clarify what this means?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants