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

require('os') is broken #24

Closed
dy opened this issue Jan 27, 2019 · 2 comments
Closed

require('os') is broken #24

dy opened this issue Jan 27, 2019 · 2 comments
Labels

Comments

@dy
Copy link
Contributor

dy commented Jan 27, 2019

// a.js
var _ = require('./b')
// b.js
exports.a = exports.b = function () {}

browserify -p common-shakeify a.js produces

(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
/* common-shake removed: exports.a = */ /* common-shake removed: exports.b = */ function () {}

},{}],2:[function(require,module,exports){
var a = require( './b' )

},{"./b":1}]},{},[2]);

Which is Uncaught SyntaxError: Unexpected token (.

Because we can't just do function () {} in javascript.

@goto-bus-stop

@goto-bus-stop
Copy link
Member

oh right, this was the case that prepending void 0, was solving. maybe that condition needs a tweak so it would be added in this case?

@dy
Copy link
Contributor Author

dy commented Jan 27, 2019

That seems to affect only functions, I wonder if there there are the other cases

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

No branches or pull requests

2 participants