-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
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
Failed import of js-big-decimal library #13031
Comments
You can specify the actual file instead. import "js-big-decimal/dist/web/js-big-decimal.js" Although, It doesn't work because Closing as it's working as intended. |
Thanks for the prompt & informative response @sapphi-red. One follow up question: you debugged this pretty quickly as "shouldn't work". Could the bundler do the same debugging and print a warning or error? One follow up piece of context: this import works correctly inside the same project when the rendering is done by storybook. The storybook runner uses a vite builder. It feels a bit off that it (somehow) succeeds in the storybook context, but not during a dev preview or build. Steps (from linked repo) (or pull current commit of linked repo):
import type { Meta, StoryObj } from "@storybook/react";
import App from "./App";
const meta = {
title: "App",
component: App,
tags: ["autodocs"],
argTypes: {
backgroundColor: { control: "color" },
},
} satisfies Meta<typeof App>;
export default meta;
type Story = StoryObj<typeof meta>;
export const Primary: Story = {
args: {},
};
Produces the following, where the rendered |
No. Because it depends on the package's content whether it needs a
I don't know much about storybook, but I guess storybook polyfills Node.js's behavior in some cases. |
Thanks again for the feedback. Will address on the target package. |
Describe the bug
I am importing and using popular js bigdecimal library: https://www.npmjs.com/package/js-big-decimal
yarn dev
succeeds (no errors), but the page fails at runtime because it has bundled the wrong file fromjs-big-decimal
. The bundled file is fromdist/node/...
, where it should be fromdist/web/...
.Also filed with js-big-decimal: royNiladri/js-big-decimal#98.
Reproduction
https://github.com/NiloCK/vite-bigdecimal-import-reproduction
Steps to reproduce
From readme of linked repository:
Steps taken in this repo:
yarn create vite
yarn add js-big-decimal
App.tsx
, lines 5, 8, and 27)yarn dev
Site does not render.
System Info
Used Package Manager
yarn
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: