Skip to content
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

Inconsistent output file between windows and ubuntu #2033

Closed
scp-r opened this issue Mar 23, 2022 · 5 comments
Closed

Inconsistent output file between windows and ubuntu #2033

scp-r opened this issue Mar 23, 2022 · 5 comments

Comments

@scp-r
Copy link

scp-r commented Mar 23, 2022

Hi there, I'm trying to bundle same code on windows and ubuntu, and use gulp-uglify to compress the output files. Most of the output files are identical (with the same checksum) but only one is different. Don't know if browserify has any guarantees for this kind of cross-platform consistency, but it might be an issue worth looking into.

Below is a minimal POC that I've found by constantly trying. My project relies on echarts@^4.2.1, and uses gulp to run browserify to generate the bundle and finally compress it through gulp-uglify. In most cases this process will produce the same files on different platforms (at least in my current project).

browserify-gulp-example.zip

The output is the same on Ubuntu and macOS, but not on Windows. The difference is only some digital labels (causing inconsistent order of modules):
ScreenShot 2022-03-23 171347

From what I've tried, echarts/lib/component/axis/AxisView is causing this inconsistency. However, if I add bundle.require('echarts/lib/component/axis/AxisView'); after line 10 of gulpfile.js, the output becomes consistent.

Below is the content of gulpfile.js. All files are available in zip archives.

const gulp = require('gulp');
const browserify = require('browserify');
const source = require('vinyl-source-stream');
const uglify = require('gulp-uglify');
const rev = require('gulp-rev');

function buildMain() {
    let bundle = browserify({
        entries: './main.js',
    });
    // uncomment next line the output will be consistent.
    // bundle.require('echarts/lib/component/axis/AxisView');
    return bundle.bundle()
        .pipe(source('main.js'))
        .pipe(gulp.dest('./bundle'));
}

gulp.task('build', gulp.series(buildMain, (done) => {
    return gulp.src(`./bundle/*.js`)
        .pipe(uglify())
        .pipe(rev())
        .pipe(gulp.dest(`./dist/scripts`))
        .pipe(rev.manifest())
        .pipe(gulp.dest('./bundle'));
}));

main.js has only one line:

require('echarts/lib/component/axis/AxisView');

Environment:

  • Node version: 16.14.2 on all platforms, installed via nvm and nvm-windows.
  • OS version: Windows 11, Ubuntu 20.04 and macOS 12.3.
  • npm version: 8.5.5 on all platforms.
@scp-r
Copy link
Author

scp-r commented Mar 23, 2022

BTW, the problem can also be reproduced by executing npx browserify main.js > bundle.js.

@scp-r scp-r closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2023
@mikixing

This comment was marked as spam.

@ljharb
Copy link
Member

ljharb commented Aug 8, 2023

Did you figure this out?

@scp-r
Copy link
Author

scp-r commented Aug 8, 2023

Did you figure this out?

No, just cleared up issues that no one responded. I migrated all my build machines to ubuntu so this issue doesn't affect us anymore

@ljharb
Copy link
Member

ljharb commented Aug 8, 2023

I'd prefer to leave it open, if that's ok with you, in case anyone else runs into it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

3 participants