small medium large xlarge

Generic-user-small
15 Nov 2016, 02:45
Ryan Pool (6 posts)

Seems to be something not related to the code in the book but a problem with web pack based on the google searches I’ve done. I’m very new to all things Javascript so do you have any pointers on working around this?

TypeError: webpack_require(151) is not a function. (In ‘webpack_require(151)(‘anchor’, function(createHTML){ return function anchor(name){ return createHTML(this, ‘a’, ‘name’, name); } })’, ‘webpack_require(151)’ is “var $export = require(‘./_export’) , fails = require(‘./_fails’) , defined = require(‘./_defined’) , quot = /”/g; // B.2.3.2.1 CreateHTML(string, tag, attribute, value) var createHTML = function(string, tag, attribute, value) { var S = String(defined(string)) , p1 = ‘<’ + tag; if(attribute !== ‘‘)p1 += ‘ ‘ + attribute + ‘=”’ + String(value).replace(quot, ‘"’) + ‘”’; return p1 + ‘>’ + S + ‘</’ + tag + ‘>’; }; module.exports = function(NAME, exec){ var O = {}; O[NAME] = exec(createHTML); $export($export.P + $export.F * fails(function(){ var test = ‘‘NAME; return test !== test.toLowerCase() || test.split(‘”’).length > 3; }), ‘String’, O); };”)

Dmfcb_pragsmall
15 Nov 2016, 14:01
David Copeland (433 posts)

It’s hard to debug this. Can you post a link to the current state of your repo?

If not, can you try formatting the error using ~~~ before and after your paste so we can see what it says?

Generic-user-small
15 Nov 2016, 16:15
Ryan Pool (6 posts)

Sorry I should have done that from the beginning.

I believe this has something to do with the raw loader. After trying a lot of different things I ended up moving my templates back into inline strings and commented out the raw loader and it works.

Even with the templates still as inline strings and nothing actually using the raw loader, if it is included in the modules loaders in webpack.config.js, I get the error.

TypeError: __webpack_require__(151) is not a function. (In '__webpack_require__(151)('anchor', function(createHTML){
  return function anchor(name){
    return createHTML(this, 'a', 'name', name);
  }
})', '__webpack_require__(151)' is "var $export = require('./_export')
  , fails   = require('./_fails')
  , defined = require('./_defined')
  , quot    = /"/g;
// B.2.3.2.1 CreateHTML(string, tag, attribute, value)
var createHTML = function(string, tag, attribute, value) {
  var S  = String(defined(string))
    , p1 = '<' + tag;
  if(attribute !== '')p1 += ' ' + attribute + '="' + String(value).replace(quot, '&quot;') + '"';
  return p1 + '>' + S + '</' + tag + '>';
};
module.exports = function(NAME, exec){
  var O = {};
  O[NAME] = exec(createHTML);
  $export($export.P + $export.F * fails(function(){
    var test = ''[NAME]('"');
    return test !== test.toLowerCase() || test.split('"').length > 3;
  }), 'String', O);
};")
Generic-user-small
15 Nov 2016, 16:25
Ryan Pool (6 posts)

Never mind.

After adding that last comment I realized I had compared everything between your source files and mine except webpack.config.js. It turns out I had a typo in the regex for the raw loader. I fixed that and everything is good again.

I feel dumb and almost wish we could delete this topic.

Thanks, Ryan

Dmfcb_pragsmall
15 Nov 2016, 18:32
David Copeland (433 posts)

You should not feel dumb :) The config format of Webpack is one of the worst things I’ve ever seen. But, webpack does work and work well. It’s just susceptible to massive failures for minor issues. I once spent an entire day trying to get JavaScript tests to run because I had a syntax error somewhere that we being swallowed. The whole ecosystem is sadly like this :(

You must be logged in to comment