-
-
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
The object is created with the old class name, but the instanceof check is performed with the renamed class name #18036
Comments
Start a new pull request in StackBlitz Codeflow. |
From a quick look, it looks like deps optimization is confused with "self import" used by wijmo packages. For example, import*as selfModule from"@mescius/wijmo.pdf" which is optimized (pre-bundled) to import * as selfModule from "/node_modules/@mescius/wijmo.pdf/es5-esm.js?v=e22d289e"; The potential workaround is to exclude these packages from optimization since they are mostly bundled already. A following config makes your "export" button work in the reproduction: https://stackblitz.com/edit/vitejs-vite-wzsyr5?file=vite.config.ts import { defineConfig } from 'vite';
export default defineConfig({
optimizeDeps: {
exclude: [
'@mescius/wijmo.pdf',
'@mescius/wijmo.grid.pdf',
'@mescius/wijmo.grid',
],
},
}); |
The suggested workaround of “excluding the packages from optimization” does resolve the issue however, I think we cannot yet provide a glob or wildcard for the whole library itself. Adding individual modules in the “exclude” list is required. For example, using something like below still optimizes the files: exclude: [ '@mesciuS /**/' ] However, I am not sure if using “self-import” is the cause of the reported issue. I have prepared a small library without using “self import” that have the following structure: @customlibrary/ ├─ wijmo.grid.pdf/ │ ├─ index.js │ ├─ package.json ├─ wijmo.grid/ │ ├─ index.js │ ├─ package.json The issue can be replicated with this library also. The target language version of the “index.js” file is “ES5” and the module is “ES2015”. Here is an offline vite example that uses a ‘@customlibrary’ for replicating the issue. Steps to reproduce the issue:
Could you please investigate this issue and let us know the root cause of the issue? Shared files description:
|
@duttabhishek6891 Hey, thanks for repro. Indeed, this is likely a bug on Vite side for pre-bundling and "self import" doesn't seem to be relevant to the issue. It took a while to track down, but it looks like dual package is happening due to package name having a suffix |
Describe the bug
We have a FlexGridPdfConverter class in our library (Wijmo). When we use the draw() method to draw the FlexGrid into a PdfDocument it produces an error in the constole: “Uncaught ** Assertion failed in Wijmo: Invalid argument: "value". Error”.
The error is caused because of failure of following check: “e instanceof PdfPen”
The reason is that the “e” variable contains the instance of “PdfPen” instead of “PdfPen2”.
You may observe the same in the images below:
Please note that I tried to run the exact code in an esbuild setup, and the issue does not occur. In esbuild setup also, the names are modifed by appending the suitable number in front of classes.
Reproduction
https://stackblitz.com/edit/vitejs-vite-msmvhy?file=index.html
Steps to reproduce
Steps to replicate the issue:
1 Extract the sample: instanceof check issue.zip
2. Run “npm i -f” and “npm run dev” to install the dependencies and run the sample.
3. Click on the “Export” button.
4. Observe the error in the console: “Uncaught ** Assertion failed in Wijmo: Invalid argument: "value". Error”
5. Click on the second link displayed in the error message.
Verifying that the issue does not occur in simple esbuild setup:
Extract the sample: esbuild-purejs.zip
Run “npm i -f” to install the dependencies and open the sample either using “live server extension” or by running “npx http-server -o” command from terminal.
Click on the “Export” button.
Observe that the FlexGrid can be exported successfully.
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: