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
Run npm run build in the project root to reproduce the build error.
Describe the bug
In this repro stackblitz, I have a simple Vite project that uses the vue-ts template. I have included the unimport plugin that uses the Vue preset.
Outside the src folder, I have a my-module module that simulates an npm package.
This module has index.js that contains one of the auto imported function from Vue as a variable name. In the example, I used ref
const u = Object.defineProperty,
ref = Object.getOwnPropertyNames;
export function getProperties(obj) {
return ref.call(null, obj);
}
I consume this module in src/main.ts and when I try to build using Vite, I get the following error.
Identifier 'ref' has already been declared
If I were to change the my-module/index.js to this format
const u = Object.defineProperty;
const ref = Object.getOwnPropertyNames;
export function getProperties(obj) {
return ref.call(null, obj);
}
And rebuild using Vite. Everything goes fine. It seems to have issue when variables are declared like const foo = 'bar', ref = 'baz'.
I can fix this issue my ignoring ref from the import. But similar issues could occur for any other identifier e.g. h
So I think this issue needs to be addressed by unimport itself.
Additional context
No response
Logs
Identifier 'ref' has already been declared
file: /home/projects/vitejs-vite-z2qfyt/my-module/index.js:7:0
5: // BREAKS
6: const u = Object.defineProperty,
7: ref = Object.getOwnPropertyNames;
^
8:
9: exportfunctiongetProperties(obj) {
error during build:
RollupError: Identifier 'ref' has already been declared
at error (file://file:///home/projects/vitejs-vite-z2qfyt/node_modules/rollup/dist/es/shared/node-entry.js:2130:30)
at Module.error (file://file:///home/projects/vitejs-vite-z2qfyt/node_modules/rollup/dist/es/shared/node-entry.js:13199:16)
at Module.tryParse (file://file:///home/projects/vitejs-vite-z2qfyt/node_modules/rollup/dist/es/shared/node-entry.js:13876:25)
at Module.setSource (file://file:///home/projects/vitejs-vite-z2qfyt/node_modules/rollup/dist/es/shared/node-entry.js:13486:39)
at ModuleLoader.addModuleSource (file://file:///home/projects/vitejs-vite-z2qfyt/node_modules/rollup/dist/es/shared/node-entry.js:23447:20)
The text was updated successfully, but these errors were encountered:
Environment
unimport: 3.0.2,
npm: '8.1.2',
node: '16.13.2',
Reproduction
https://stackblitz.com/edit/vitejs-vite-z2qfyt
Run
npm run build
in the project root to reproduce the build error.Describe the bug
In this repro stackblitz, I have a simple Vite project that uses the vue-ts template. I have included the unimport plugin that uses the Vue preset.
Outside the src folder, I have a
my-module
module that simulates an npm package.This module has
index.js
that contains one of the auto imported function from Vue as a variable name. In the example, I usedref
I consume this module in
src/main.ts
and when I try to build using Vite, I get the following error.Identifier 'ref' has already been declared
If I were to change the
my-module/index.js
to this formatAnd rebuild using Vite. Everything goes fine. It seems to have issue when variables are declared like
const foo = 'bar', ref = 'baz'
.I can fix this issue my ignoring
ref
from the import. But similar issues could occur for any other identifier e.g.h
So I think this issue needs to be addressed by
unimport
itself.Additional context
No response
Logs
The text was updated successfully, but these errors were encountered: