I wrote a lot of things using the CommonJS modules, I collected the whole thing using a webpack into one file, but when I try to use one of the classes in the browser, it says that there is no such class. I do not fully understand how to use all this happiness.

Pages.ts:

export default class Pages { ...... } 

Compiled in Pages.js:

 var Pages = (function () { function Pages(pathResolver) { ...... } }()); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Pages; 

Going to out.js:

 (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { ................................ }) /************************************************************************/ /******/ ([ /* 0 */ /***/ function(module, exports, __webpack_require__) { var Pages = function () { function Pages(pathResolver) { ................................ }(); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = Pages; 

I use this:

 <script src="js/app.js"></script> <script> var pages = new Pages(null); </script> 

At the same time I get this error

 Uncaught ReferenceError: Pages is not defined(…) 

    1 answer 1

    Try in the webpack config add library setting: nameOfYourLibrary

    This class will be available as nameOfYourLibrary.default.