hperrin / svelte-material-ui

Svelte Material UI Components
https://sveltematerialui.com/
Apache License 2.0
3.27k stars 287 forks source link

`Error: Package path ./internal is not exported` in smui v7 #641

Closed marekdedic closed 3 months ago

marekdedic commented 6 months ago

Describe the bug Hi, I'm trying to update to SMUI v7, but I am encountering the following errors:

Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/checkbox/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/checkbox/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/form-field/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/form-field/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/linear-progress/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/linear-progress/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./internal is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/button/node_modules/@smui/common/package.json)
Module not found: Error: Package path . is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/data-table/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/dialog/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/list/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Module not found: Error: Package path ./classadder is not exported from package /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common (see exports field in /home/marekdedic/Documents/git/shared-drive-mover/node_modules/@smui/top-app-bar/node_modules/@smui/common/package.json)
Details:
    domainEmitter: [object Object]
    domainThrown: false

To Reproduce Steps to reproduce the behavior:

  1. Go to https://github.com/skaut/shared-drive-mover/commit/514d750927967d221ff950aaa0484eb40dd910a2
  2. npm ci && npm run build
  3. See error

Expected behavior No error.

Desktop (please complete the following information):

hperrin commented 6 months ago

I'm guessing you have different versions installed at the same time, because the ./internal path is certainly exported:

https://github.com/hperrin/svelte-material-ui/blob/09c2396de874d88c92e8969218c9d93963fac430/packages/common/package.json#L20

hperrin commented 6 months ago

Or maybe you need to update your version of Node/NPM/some other build tool? Maybe it's not understanding the new exports conditions. (I'm using the "svelte" export condition, as recommended by Svelte.)

marekdedic commented 6 months ago

Hmm, it seems like I have version 7.0.0-beta.16 :/ Take a look here...

hperrin commented 6 months ago

I spotted this line:

"svelte-material-ui": "^6.2.0"

Try changing that one too.

marekdedic commented 6 months ago

Ugh, my mistake (any thoughts about moving this package to the namespace too? Maybe something like @smui/theme?)

However, after updating that one too, I still got the error :(

https://github.com/skaut/shared-drive-mover/pull/1476

dr3adx commented 6 months ago

me too, webpack serve is FULL of same exact errors related to smui/common

dr3adx commented 6 months ago

on a clean dir , i even removed node_modules!!

dr3adx commented 6 months ago

i cant believe i have to reinstall everything now and waste my whole life fixing this shit

hperrin commented 5 months ago

@dr3adx Just so we're clear about what's going on here, I'm giving you the product of literally hundreds of hours of my labor and expertise for free, and you are complaining and cursing at me that you have to spend a few minutes figuring out what is probably either something you did wrong or the result of a change to a dependency.

dr3adx commented 5 months ago

All I'm saying is test stuff before publishing because it's not me, literally v6 works while v7 doesnt

On Fri, Jan 12, 2024, 12:34 AM Hunter Perrin @.***> wrote:

@dr3adx https://github.com/dr3adx Just so we're clear about what's going on here, I'm giving you the product of literally hundreds of hours of my labor and expertise for free, and you are complaining at me that you have to spend a few minutes figuring out what is probably something either you did wrong or is the result of a change to a dependency.

— Reply to this email directly, view it on GitHub https://github.com/hperrin/svelte-material-ui/issues/641#issuecomment-1887645955, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABBR55FWBCH2N6EZRGTCWTLYOAPB3AVCNFSM6AAAAABBEOWNNCVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQOBXGY2DKOJVGU . You are receiving this because you were mentioned.Message ID: @.***>

marekdedic commented 5 months ago

@dr3adx Smui v7 is in beta, if you are on v7 and expecting perfectly stable and smooth ride without any bugs, that's your problem. On top of that, the repo is open-source, you are paying nothing for it, you are free to fork it or not use it if you don't like how it's maintained.

I'm glad @hperrin created this and maintains it (thanks!), there are some bugs (and this maybe isn't one of them but an issue on my side), you are free to report them if you find them (or not, your choice...), but don't be a dick about it.

hperrin commented 5 months ago

@dr3adx https://mail.port87.com is a SvelteKit app built with the latest version of SMUI. So is https://sveltematerialui.com. I test every version with SvelteKit before I release. Also, there are thousands of users of this library, and this issue has only come up a couple times. I'm not saying that this issue isn't real or that it's definitely something you did, I'm saying the root cause is probably not something within SMUI's code base. It sounds like either a dependency issue or a build system issue. If it is and we can figure it out, I will definitely add a note in the documentation to help other users who could run into it.

It's also really unhelpful to come in here and curse at me while I'm trying to help you. It doesn't help us figure out this issue, and it will eventually get you banned.

I understand that you're frustrated and that the situation you're in sucks. I've been there myself many times. Just remember that the people on the other side of your screen are real people who don't like being treated poorly.

mkyral commented 5 months ago

I just got this issue in Jenkins build. It was build successfully last time (before x-mass). But something had to change between. I was not able to reproduce it locally until I fully removed node_module and package-lock.json. Then I got the same "warning".

src/main/frontend/main.ts → src/main/resources/public/build/bundle.js...

WARNING: Your @rollup/plugin-node-resolve configuration's 'exportConditions' array should include 'svelte'. See https://github.com/sveltejs/rollup-plugin-svelte#svelte-exports-condition for more information

(!) Plugin node-resolve: Could not resolve import "@smui/common/classadder" in XXX/src/node_modules/@smui/snackbar/dist/Actions.js using exports defined in XXX/src/node_modules/@smui/snackbar/node_modules/@smui/common/package.json.
(!) Plugin node-resolve: Could not resolve import "@smui/common/internal" in XXX/src/node_modules/@smui/snackbar/dist/Snackbar.svelte using exports defined in XXX/src/node_modules/@smui/snackbar/node_modules/@smui/common/package.json.
...
(!) Unresolved dependencies
https://rollupjs.org/troubleshooting/#warning-treating-module-as-external-dependency
@smui/common/internal (imported by "node_modules/@smui/snackbar/dist/Snackbar.svelte", "node_modules/@smui/banner/dist/Banner.svelte", "node_modules/@smui/textfield/dist/Textfield.svelte", "node_modules/@smui/textfield/dist/Textarea.svelte", "node_modules/@smui/textfield/dist/Input.svelte", "node_modules/@smui/banner/dist/Fixed.svelte", "node_modules/@smui/radio/dist/Radio.svelte", "node_modules/@smui/floating-label/dist/FloatingLabel.svelte", "node_modules/@smui/line-ripple/dist/LineRipple.svelte", "node_modules/@smui/notched-outline/dist/NotchedOutline.svelte", "node_modules/@smui/data-table/dist/DataTable.svelte", "node_modules/@smui/data-table/dist/Head.svelte", "node_modules/@smui/data-table/dist/Body.svelte", "node_modules/@smui/data-table/dist/Cell.svelte", "node_modules/@smui/data-table/dist/Row.svelte", "node_modules/@smui/data-table/dist/Pagination.svelte" and "node_modules/@smui-extra/badge/dist/Badge.svelte")
@smui/common/classadder (imported by "node_modules/@smui/snackbar/dist/Actions.js", "node_modules/@smui/textfield/dist/Prefix.js", "node_modules/@smui/textfield/dist/HelperLine.js" and "node_modules/@smui/textfield/dist/Suffix.js")
@smui/textfield/helper-text (imported by "src/main/frontend/components/SideBar.svelte", "src/main/frontend/components/common/SmallChangesInputField.svelte", "src/main/frontend/components/common/MarginDiffInputField.svelte", "src/main/frontend/components/job/JobWizard.svelte", "src/main/frontend/components/job/JobFiltersBar.svelte", "src/main/frontend/components/itemDetail/ItemDetailRow.svelte" and "src/main/frontend/components/itemDetail/PriceField.svelte")
(!) Circular dependencies
node_modules/@smui/snackbar/node_modules/@smui/common/dist/index.js -> node_modules/@smui/snackbar/node_modules/@smui/common/dist/CommonLabel.svelte -> node_modules/@smui/snackbar/node_modules/@smui/common/dist/index.js
node_modules/@smui/snackbar/node_modules/@smui/common/dist/index.js -> node_modules/@smui/snackbar/node_modules/@smui/common/dist/CommonIcon.svelte -> node_modules/@smui/snackbar/node_modules/@smui/common/dist/index.js
node_modules/@smui/common/dist/index.js -> node_modules/@smui/common/dist/CommonLabel.svelte -> node_modules/@smui/common/dist/index.js
...and 7 more
(!) Missing global variable names
https://rollupjs.org/configuration-options/#output-globals
Use "output.globals" to specify browser global variable names corresponding to external modules:
@smui/common/internal (guessing "internal")
@smui/common/classadder (guessing "classadder")
@smui/textfield/helper-text (guessing "HelperText$1")
created src/main/resources/public/build/bundle.js in 20s

Build finish, but app fails with:

Uncaught ReferenceError: internal is not defined
    <anonymous> main.ts:85
[main.ts:85](https://XXX/frontend/main.ts)
    <anonymous> main.ts:85

I'm still investigating what exactly changed.

I'm using svelte3, smui-v7-beta-15 and node-19.7.0

hperrin commented 5 months ago

I noticed this line:

WARNING: Your @rollup/plugin-node-resolve configuration's 'exportConditions' array should include 'svelte'.

That could be it. I don't have default exports, just "svelte" and "types", so maybe that's why it's not finding the export.

Can you try adding that export condition and see if the issue persists?

hperrin commented 5 months ago

Adopting the "svelte" export condition recently became a recommendation from the Svelte team:

https://kit.svelte.dev/docs/packaging#anatomy-of-a-package-json-exports

mkyral commented 5 months ago

I don't know exactly what I should do, but I will try.

I've tried to force beta-15, to check it out, but this does not work as npm installed some dependencies as beta-16 so I've ended up with mix of beta-15 and beta-16 packages. Unfortunately I had no more time today. I'll continue Monday.

hperrin commented 5 months ago

In your Rollup config, you should have a place where you add the @rollup/plugin-node-resolve plugin. You can add a config object to it, and put ["svelte"] into the exportConditions key.

mkyral commented 5 months ago

Thanks, I can confirm that adding of this configuration line works. Maybe I should finally migrate to Vite :-D

Described in https://github.com/rollup/plugins/tree/master/packages/node-resolve/#exportconditions

hperrin commented 5 months ago

@marekdedic Can you try as well and let me know if that fixes the issue?

marekdedic commented 5 months ago

Hi, I'm sorry, but I'm confused as to what your suggestion is - my package is not a library, it's a project. It doesn't export anything and there isn't any single svelte file I could export. I'm also really confused by the svelte exports directive as a whole, so I might just be misunderstanding the whole thing.

Or are you saying I should modify the smui packages manually in my node_modules?

Additionally, I use webpack, not rollup.

mkyral commented 5 months ago

In my case it was a missing configuration for the rollup-node-resolve plugin. So you should look for something similar in webpack.

hperrin commented 5 months ago

@marekdedic I found the equivalent for Webpack, https://webpack.js.org/configuration/resolve/#resolveconditionnames

So add this to your Webpack config:

module.exports = {
  //...
  resolve: {
    conditionNames: ['svelte', 'require', 'node'],
  },
};
marekdedic commented 5 months ago

Hi, I can confirm this works for me - thnk you very much for the help!