oven-sh / bun

Incredibly fast JavaScript runtime, bundler, test runner, and package manager – all in one
https://bun.sh
Other
73k stars 2.66k forks source link

cannot declare a var variable that shadows a let/const/class variable #5732

Closed Enubia closed 1 week ago

Enubia commented 11 months ago

What version of Bun is running?

1.0.3+cc54b62fac41c0977c7dfc4c6ba550a6408fa15f

What platform is your computer?

Darwin 22.3.0 arm64 arm

What steps can reproduce the bug?

make-error-cause (dependency of gulp-uglify) throws during a gulp build pipeline.

Example to reproduce the issue.

const { src, dest, task } = require('gulp');
const uglify = require('gulp-uglify');
const plumber = require('gulp-plumber');

task('default', (done) => {
    src('./test.js')
        .pipe(plumber((err) => {
            console.log(err);
        }))
        .pipe(uglify())
        .pipe(dest('./dist/test.js'))
        .on('end', () => {
            console.log('end');
            done();
        });
});

What is the expected behavior?

../Workspace/dev-env/test-gulp❯ npx gulp   
[13:30:43] Using gulpfile /Volumes/Workspace/dev-env/test-gulp/gulpfile.js
[13:30:43] Starting 'default'...
end
[13:30:43] Finished 'default' after 22 ms

What do you see instead?

../Workspace/dev-env/test-gulp❯ bun gulpfile.js 
 8 | function makeErrorCause(value, _super) {
 9 |     if (_super === void 0) { _super = makeErrorCause.BaseError; }
10 |     return makeError(value, _super);
11 | }
12 | var makeErrorCause;
13 | (function (makeErrorCause) {
              ^
SyntaxError: Cannot declare a var variable that shadows a let/const/class variable: 'makeErrorCause'.
      at /Volumes/Workspace/dev-env/test-gulp/node_modules/make-error-cause/dist/index.js:13:10
../Workspace/dev-env/test-gulp❯ 

Additional information

No response

Enubia commented 11 months ago

nevermind me, I did not execute this script with bunx gulp but instead tried to run the gulpfile directly with bun gulpfile.js

Enubia commented 11 months ago

reopening because I think it could be still valid tho

in case you execute the provided script with either

node gulpfile.js
npx gulp
bunx gulp

it works as intended

but if you try to run the script via

bun gulpfile.js

the aforementioned error occurs

paperdave commented 11 months ago

transpiler bug, minimal repro. @dylan-conway

function A() {
}
var A;
AxeemHaider commented 11 months ago

still same error did you able to find solution of it @paperdave

jlucaso1 commented 6 months ago

Same error when trying to run lib https://github.com/WhiskeySockets/Baileys/issues/586

var __importStar = (this && this.__importStar) || function (mod) {
    if (mod && mod.__esModule) return mod;
    var result = {};
    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
    __setModuleDefault(result, mod);
    return result;
};
SyntaxError: Cannot declare a var variable that shadows a let/const/class variable: '__importStar'.

@paperdave @dylan-conway

roysG commented 5 months ago

Any update?

Araxeus commented 2 months ago

Same error when trying to run lib WhiskeySockets/Baileys#586

This is because of transpiling issues - Baileys define an __importStar function by itself before transpilation - https://github.com/WhiskeySockets/Baileys/blob/f25f83656a7cadbcdaf66b7fea72b9d4b3a72aa0/src/Utils/messages-media.ts#L785-L787 if you clone Baileys and directly run the ts files with Bun, you avoid this error (but you get other errors about missing function from Crypto)

Jarred-Sumner commented 1 week ago

Fixedin Bun v1.1.21