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

Problem with standalone functionality #1537

Closed
johnkjoseph opened this issue Mar 30, 2016 · 6 comments

Comments

Projects
None yet
2 participants
@johnkjoseph
Copy link

commented Mar 30, 2016

Standalone functionality doesn't seem to work for files with certain folder names.

https://github.com/johnkjoseph/browserify-problem

In the above project standalone works for the component in test folder. But it doesn't work for component's in es6-component folder. The only difference is in the folder name. This can be reproduced by cloning the above repo and opening the index.html files in using some server dist/test and dist/es6-component. Browser console will show that the standalone global variable has the right value for test folder and empty in case of es6-component folder. Is this expected behaviour?

@jmm

This comment has been minimized.

Copy link
Collaborator

commented Apr 3, 2016

Thanks for the repro. I haven't run it, but I bet this is #1120 / #1390. Can you try adding your entry file via .add() after the polyfill instead of passing it to the constructor?

@johnkjoseph

This comment has been minimized.

Copy link
Author

commented Apr 11, 2016

I tried that. Changed

browserify(sourceItem.component+sourceItem.file,
        { debug: true ,paths: ['./'], standalone: 'standalone'})
        .add(require.resolve('babel-polyfill'))
        .transform(babelify, {presets: ['es2015']})

to

 browserify()
        .add(require.resolve('babel-polyfill'))
        .add(sourceItem.component+sourceItem.file,{debug: true ,paths: ['./'], standalone: 'standalone'})
        .transform(babelify, {presets: ['es2015']})

But doesn't seem to work. I am looking at other similar bugs. Please let me know if i should try anything else.

@jmm

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2016

You moved your Browserify options (standalone, etc.) to the .add() call -- those should still be in the constructor.

When posting multi-line code please mark it up with triple backticks and a language ID. For more info see https://github.com/substack/node-browserify/wiki/How-to-report-issues-with-browserify#formatting.

@johnkjoseph

This comment has been minimized.

Copy link
Author

commented Apr 11, 2016

Tried it:

      browserify({ entry: true,debug: true ,paths: ['./'], standalone: 'standalone'})
        .add(require.resolve('babel-polyfill'))
        .add(sourceItem.component+sourceItem.file)
        .transform(babelify, {presets: ['es2015']})

Tried for both the folder separately. Works for "test" folder. Doesn't work for "es6-component" folder.

This may sound stupid. But does folder name has any play in this anywhere? I am not talking about multiple modules or anything. Even when building separately the one in "es6-component" folder, standalone doesn't work.

@jmm

This comment has been minimized.

Copy link
Collaborator

commented Apr 11, 2016

This may sound stupid. But does folder name has any play in this anywhere?

That's a fair question. I'd have to look into it more to know for sure, but it's possible. There could be a sort or something that affects the behavior. You can see that here I suggested adding an {expose: "z"} because there seemed to be something like that going on. standalone is billed as working with a single entry file, so for your case the most straightforward thing might be to just point Browserify to your entry file and have that require the polyfill.

@johnkjoseph

This comment has been minimized.

Copy link
Author

commented Apr 18, 2016

Weird. That worked ! Thank you for your time!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.