webpack/examples/coffee-script/README.md

143 lines
3.4 KiB
Markdown
Raw Normal View History

2012-03-27 06:00:51 +08:00
# example.js
2019-04-09 02:29:40 +08:00
```javascript
2013-02-13 18:58:13 +08:00
console.log(require("./cup1"));
2012-03-27 06:00:51 +08:00
```
# cup1.coffee
2019-04-09 02:29:40 +08:00
```coffee-script
2012-03-27 06:00:51 +08:00
module.exports =
cool: "stuff"
answer: 42
external: require "./cup2.coffee"
2013-02-13 18:58:13 +08:00
again: require "./cup2"
2012-03-27 06:00:51 +08:00
```
# cup2.coffee
2019-04-09 02:29:40 +08:00
```coffee-script
2012-03-27 06:00:51 +08:00
console.log "yeah coffee-script"
module.exports = 42
```
# dist/output.js
2012-03-27 06:00:51 +08:00
2019-04-09 02:29:40 +08:00
```javascript
2019-10-11 05:11:05 +08:00
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */,
2017-12-14 17:58:03 +08:00
/* 1 */
2013-02-13 18:58:13 +08:00
/*!*********************!*\
2015-06-13 23:41:14 +08:00
!*** ./cup1.coffee ***!
2013-02-13 18:58:13 +08:00
\*********************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
/*! runtime requirements: module, __webpack_require__ */
2020-09-21 04:39:12 +08:00
/*! CommonJS bailout: module.exports is used directly at 1:0-14 */
2019-10-11 05:11:05 +08:00
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
2013-02-13 18:58:13 +08:00
2016-09-07 18:28:56 +08:00
module.exports = {
cool: "stuff",
answer: 42,
2017-12-14 17:58:03 +08:00
external: __webpack_require__(/*! ./cup2.coffee */ 2),
again: __webpack_require__(/*! ./cup2 */ 2)
2016-09-07 18:28:56 +08:00
};
2013-10-31 07:49:59 +08:00
2013-02-13 18:58:13 +08:00
2017-12-14 17:58:03 +08:00
/***/ }),
/* 2 */
/*!*********************!*\
!*** ./cup2.coffee ***!
\*********************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
2018-12-19 21:05:17 +08:00
/*! runtime requirements: module */
2020-09-21 04:39:12 +08:00
/*! CommonJS bailout: module.exports is used directly at 3:0-14 */
2019-10-09 05:45:47 +08:00
/***/ ((module) => {
2017-12-14 17:58:03 +08:00
console.log("yeah coffee-script");
module.exports = 42;
2017-03-31 02:25:01 +08:00
/***/ })
2019-10-11 05:11:05 +08:00
/******/ ]);
```
<details><summary><code>/* webpack runtime code */</code></summary>
``` js
2019-10-11 05:11:05 +08:00
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
2021-08-20 14:12:50 +08:00
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
2019-10-11 05:11:05 +08:00
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
2020-05-21 05:26:51 +08:00
/******/ // no module.id needed
/******/ // no module.loaded needed
2019-10-11 05:11:05 +08:00
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/************************************************************************/
```
</details>
``` js
2021-08-20 14:12:50 +08:00
var __webpack_exports__ = {};
// This entry need to be wrapped in an IIFE because it need to be isolated against other modules in the chunk.
2020-05-21 05:26:51 +08:00
(() => {
2019-10-11 05:11:05 +08:00
/*!********************!*\
!*** ./example.js ***!
\********************/
2020-05-21 05:26:51 +08:00
/*! unknown exports (runtime-defined) */
2019-10-11 05:11:05 +08:00
/*! runtime requirements: __webpack_require__ */
console.log(__webpack_require__(/*! ./cup1 */ 1));
2020-05-21 05:26:51 +08:00
})();
2019-10-11 05:11:05 +08:00
/******/ })()
;
2012-03-27 06:00:51 +08:00
```
# Info
2017-12-14 17:58:03 +08:00
## Unoptimized
2012-03-27 06:00:51 +08:00
```
2021-08-20 14:12:50 +08:00
asset output.js 2.27 KiB [emitted] (name: main)
chunk (runtime: main) output.js (main) 206 bytes [entry] [rendered]
2020-09-21 04:39:12 +08:00
> ./example.js main
dependent modules 175 bytes [dependent] 2 modules
./example.js 31 bytes [built] [code generated]
[used exports unknown]
entry ./example.js main
2021-08-20 14:12:50 +08:00
webpack 5.51.1 compiled successfully
2012-03-27 06:00:51 +08:00
```
2017-12-14 17:58:03 +08:00
## Production mode
2012-03-27 06:00:51 +08:00
```
2021-08-20 14:12:50 +08:00
asset output.js 294 bytes [emitted] [minimized] (name: main)
2020-09-21 04:39:12 +08:00
chunk (runtime: main) output.js (main) 206 bytes [entry] [rendered]
> ./example.js main
dependent modules 175 bytes [dependent] 2 modules
./example.js 31 bytes [built] [code generated]
[no exports used]
entry ./example.js main
2021-08-20 14:12:50 +08:00
webpack 5.51.1 compiled successfully
2019-04-09 02:29:40 +08:00
```