Skip to content
This repository was archived by the owner on Jan 6, 2025. It is now read-only.
This repository was archived by the owner on Jan 6, 2025. It is now read-only.

Use file extensions explicitly #432

@christian-bromann

Description

@christian-bromann

Describe the bug

I am having issues being able to package individual components up due to the following error:

ERROR in ./node_modules/@vscode/webview-ui-toolkit/dist/button/index.js 6:0-57
Module not found: Error: Can't resolve './button.styles' in '/Users/christianbromann/Sites/Stateful/projects/vscode-runme/node_modules/@vscode/webview-ui-toolkit/dist/button'
Did you mean 'button.styles.js'?
BREAKING CHANGE: The request './button.styles' failed to resolve only because it was resolved as fully specified

It seems this project recently migrated to ESM (which I would consider being recognised as major version bump) and files in dist still have no explicit file extension, e.g.

import { buttonStyles as styles } from './button.styles';

Maybe there is just a misunderstanding how these components are supposed to be consumed. I currently just bundle them into my webview code and import them like:

import '@vscode/webview-ui-toolkit/dist/button/index.js'

as I don't need all of the components.

To reproduce

Checkout this branch: runmedev/vscode-runme#79 and try to build the project.

Expected behavior

I am able to import individual components.

Current behavior

It throws an error.

Screenshots

Desktop (please complete the following information):

  • OS Version: [e.g. macOS 11.3.1]
  • Toolkit Version: [e.g. v0.8.0]

Additional context

I will rollback for now so nothing urgent here but would be great if:

  • all file imports could have explicit extensions

  • every component could be exported through package.json so I could do something like

     import Button from '@vscode/webview-ui-toolkit/button'
    

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions