0

I'm not an expert with javascript.

I'm wondering, from which library you get the require method

For example, in main.js : (https://github.com/marmelab/ng-admin-demo/blob/master/js/main.js)

require('./customers/config')(nga, admin);

Thank you !

Xero
  • 3,951
  • 4
  • 41
  • 73
  • RequireJS is one. I don't know if Angular supplies it itself. You'll also see it in NodeJS code; in that instance, it's provided by Node. – T.J. Crowder Nov 11 '16 at 16:45

1 Answers1

0

There are multiple ways to support modules in the browser: AMD, CommonJS, UMD and RequireJS(browser only). In your particular example, I think webpack will pack all the modules together(see dev dependecies in that project and webpack config in the project). See:

  1. https://webpack.github.io/docs/api-in-modules.html
  2. How to require CommonJS modules in the browser?
  3. https://pixelsvsbytes.com/2013/02/js-require-for-browsers-better-faster-stronger/
  4. https://addyosmani.com/writing-modular-js/

In the NodeJS require is a global function: See: How does require() in node.js work?

Community
  • 1
  • 1
Dennis R
  • 1,769
  • 12
  • 13