Closed dy closed 5 years ago
// a.js var _ = require('./b')
// b.js exports.a = exports.b = function () {}
browserify -p common-shakeify a.js produces
browserify -p common-shakeify a.js
(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 (.
Uncaught SyntaxError: Unexpected token (
Because we can't just do function () {} in javascript.
function () {}
@goto-bus-stop
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?
void 0,
That seems to affect only functions, I wonder if there there are the other cases
browserify -p common-shakeify a.js
producesWhich is
Uncaught SyntaxError: Unexpected token (
.Because we can't just do
function () {}
in javascript.@goto-bus-stop