marko-js / marko

A declarative, HTML-based language that makes building web apps fun
https://markojs.com/
MIT License
13.42k stars 646 forks source link

Cannot find module ./raptor-logging-impl #212

Closed stevus closed 8 years ago

stevus commented 8 years ago
Error: Cannot find module './raptor-logging-impl'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)

Offending code snippet:

module.exports = stubs;

if (!process.browser) {
    var implPath = './raptor-logging-impl';
    require(implPath);
}
},{}],497:[function(require,module,exports){
(function (__dirname){

Here is my build script:

browserify -t markoify --node -t reactify  -o dist/server.js build/source/server.js

Dependencies in package.json:

"dependencies": {
    "browserify": "^12.0.1",
    "browserify-shim": "^3.8.11",
    "bunyan": "^1.5.1",
    "bunyan-request-logger": "^1.0.2",
    "express": "^4.12.4",
    "markoify": "^1.1.2",
    "react": "^0.14.0",
    "react-dom": "^0.14.5",
    "react-tools": "^0.13.3",
    "reactify": "^1.0.0"
  },
patrick-steele-idem commented 8 years ago

Hey @stevus, it looks like you are using browserify to build a JavaScript bundle to be loaded on the server (not the browser). That's not the normal use case and it breaks "dynamic" requires. However, let me see if I can put in a workaround for you.

stevus commented 8 years ago

@patrick-steele-idem awesome, thanks. Browserify supports building server-side modules, it just requires some clever configuration, which is actually not fully adopted by browserify but seems to work for most applications.

My motivation here is to bundle all of my server side code to one file to make deploys easier, and save space on hosting instances.

patrick-steele-idem commented 8 years ago

Fixed. See: https://github.com/raptorjs/raptor-logging/issues/4

New version of raptor-logging published: raptor-logging@1.0.8

Please let me know if that works for you. Seems reasonable what you are trying to do, but you might run into edges like this again.

stevus commented 8 years ago

Fixed, but spawned this issue:

https://github.com/marko-js/marko/issues/213