You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm having an issue with a React library (that I created), for some reason it works properly on dev mode, but it doesn't on production builds.
I noticed the bug only happens with the default import (that seems to import the Common JS build), but it doesn't happen with any other build target (UMD and ESM)
Reproduction
To reproduce the bug it's enough to bootstrap a new app with npx init vite using the React template.
Install the library with npm install react-resize-aware.
Then, edit the src/App.jsx file to be:
import { useState } from 'react';
import logo from './logo.svg';
import './App.css';
import useResizeAware from 'react-resize-aware';
function App() {
const [listener] = useResizeAware();
return (
<div>
{listener}
Test
</div>
);
}
export default App;
If you run the app on dev mode and you inspect the resulting DOM, an iframe will be visible.
If you build the app and run it with vite preview, the iframe is replaced by a <t /> element.
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
i have test some cases , and found that u can add 'module' field in 'react-resize-aware' package.json, then whether dev or prod mode would be ok. like this:
the reason is: if u don't specified the 'module' field , whether in dev/prod mode, vite (esbuild/rollup) will resolve the 'react-resize-aware' package by the 'main' fileld, which is dist/index.js , and your package was pack by microbundle, in microbundle docs, the 'main' field is for CJS , and u should include the 'module' field according the docs https://github.com/developit/microbundle
Describe the bug
I'm having an issue with a React library (that I created), for some reason it works properly on dev mode, but it doesn't on production builds.
I noticed the bug only happens with the default import (that seems to import the Common JS build), but it doesn't happen with any other build target (UMD and ESM)
Reproduction
To reproduce the bug it's enough to bootstrap a new app with
npx init vite
using the React template.Install the library with
npm install react-resize-aware
.Then, edit the
src/App.jsx
file to be:If you run the app on dev mode and you inspect the resulting DOM, an iframe will be visible.
If you build the app and run it with
vite preview
, the iframe is replaced by a<t />
element.System Info
Used Package Manager
npm
Logs
Validations
The text was updated successfully, but these errors were encountered: