-
Notifications
You must be signed in to change notification settings - Fork 145
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: infer webpack module name from comment
- Loading branch information
Showing
4 changed files
with
247 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
134 changes: 134 additions & 0 deletions
134
packages/webcrack/src/unpack/test/samples/webpack5-dev.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,134 @@ | ||
// https://github.com/roots/acorn/blob/5b188cef18775b0eb9ff9448acd4a6ba442457bc/tests/Assets/__fixtures__/bud_single_runtime_dev/public/customizer.js | ||
|
||
/******/ (function() { // webpackBootstrap | ||
/******/ var __webpack_modules__ = ({ | ||
|
||
/***/ 439: | ||
/*!*****************************************!*\ | ||
!*** ./resources/scripts/customizer.js ***! | ||
\*****************************************/ | ||
/***/ (function(module, __unused_webpack_exports, __webpack_require__) { | ||
|
||
/* provided dependency */ var $ = __webpack_require__(/*! jquery */ 567); | ||
/* provided dependency */ var __react_refresh_utils__ = __webpack_require__(/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ 43); | ||
__webpack_require__.$Refresh$.runtime = __webpack_require__(/*! ./node_modules/react-refresh/runtime.js */ 930); | ||
|
||
/** | ||
* This file allows you to add functionality to the Theme Customizer | ||
* live preview. jQuery is readily available. | ||
* | ||
* @see https://codex.wordpress.org/Theme_Customization_API | ||
*/ | ||
|
||
/** | ||
* Change the blog name value. | ||
*/ | ||
wp.customize('blogname', value => { | ||
value.bind(to => $('.brand').text(to)); | ||
}); | ||
|
||
var $ReactRefreshModuleId$ = __webpack_require__.$Refresh$.moduleId; | ||
var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports( | ||
$ReactRefreshModuleId$ | ||
); | ||
|
||
function $ReactRefreshModuleRuntime$(exports) { | ||
if (true) { | ||
var errorOverlay; | ||
if (true) { | ||
errorOverlay = false; | ||
} | ||
var testMode; | ||
if (typeof __react_refresh_test__ !== 'undefined') { | ||
testMode = __react_refresh_test__; | ||
} | ||
return __react_refresh_utils__.executeRuntime( | ||
exports, | ||
$ReactRefreshModuleId$, | ||
module.hot, | ||
errorOverlay, | ||
testMode | ||
); | ||
} | ||
} | ||
|
||
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { | ||
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); | ||
} else { | ||
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); | ||
} | ||
|
||
/***/ }), | ||
|
||
/***/ 567: | ||
/*!*************************!*\ | ||
!*** external "jQuery" ***! | ||
\*************************/ | ||
/***/ (function(module) { | ||
|
||
"use strict"; | ||
module.exports = window["jQuery"]; | ||
|
||
/***/ }) | ||
|
||
/******/ }); | ||
/************************************************************************/ | ||
/******/ // The module cache | ||
/******/ var __webpack_module_cache__ = {}; | ||
/******/ | ||
/******/ // The require function | ||
/******/ function __webpack_require__(moduleId) { | ||
/******/ // Check if module is in cache | ||
/******/ var cachedModule = __webpack_module_cache__[moduleId]; | ||
/******/ if (cachedModule !== undefined) { | ||
/******/ if (cachedModule.error !== undefined) throw cachedModule.error; | ||
/******/ return cachedModule.exports; | ||
/******/ } | ||
/******/ // Create a new module (and put it into the cache) | ||
/******/ var module = __webpack_module_cache__[moduleId] = { | ||
/******/ id: moduleId, | ||
/******/ loaded: false, | ||
/******/ exports: {} | ||
/******/ }; | ||
/******/ | ||
/******/ // Execute the module function | ||
/******/ try { | ||
/******/ var execOptions = { id: moduleId, module: module, factory: __webpack_modules__[moduleId], require: __webpack_require__ }; | ||
/******/ __webpack_require__.i.forEach(function(handler) { handler(execOptions); }); | ||
/******/ module = execOptions.module; | ||
/******/ execOptions.factory.call(module.exports, module, module.exports, execOptions.require); | ||
/******/ } catch(e) { | ||
/******/ module.error = e; | ||
/******/ throw e; | ||
/******/ } | ||
/******/ | ||
/******/ // Flag the module as loaded | ||
/******/ module.loaded = true; | ||
/******/ | ||
/******/ // Return the exports of the module | ||
/******/ return module.exports; | ||
/******/ } | ||
/******/ | ||
/******/ // expose the modules object (__webpack_modules__) | ||
/******/ __webpack_require__.m = __webpack_modules__; | ||
/******/ | ||
/******/ // expose the module cache | ||
/******/ __webpack_require__.c = __webpack_module_cache__; | ||
/******/ | ||
/******/ // expose the module execution interceptor | ||
/******/ __webpack_require__.i = []; | ||
/******/ | ||
/************************************************************************/ | ||
/******/ // rest of the code removed to save space | ||
/************************************************************************/ | ||
/******/ | ||
/******/ // module cache are used so entry inlining is disabled | ||
/******/ // startup | ||
/******/ // Load entry module and return exports | ||
/******/ __webpack_require__.O(undefined, ["bud","vendor-app~editor~customizer"], function() { return __webpack_require__(9278); }) | ||
/******/ __webpack_require__.O(undefined, ["bud","vendor-app~editor~customizer"], function() { return __webpack_require__(439); }) | ||
/******/ var __webpack_exports__ = __webpack_require__.O(undefined, ["bud","vendor-app~editor~customizer"], function() { return __webpack_require__(2362); }) | ||
/******/ __webpack_exports__ = __webpack_require__.O(__webpack_exports__); | ||
/******/ | ||
/******/ })() | ||
; |
61 changes: 61 additions & 0 deletions
61
packages/webcrack/src/unpack/test/samples/webpack5-dev.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
WebpackBundle { | ||
"entryId": "", | ||
"modules": Map { | ||
"439" => WebpackModule { | ||
"ast": /* provided dependency */var $ = require( /*! jquery */"../../jQuery"); | ||
/* provided dependency */ | ||
var __react_refresh_utils__ = require( | ||
/*webcrack:missing*/ | ||
/*! ./node_modules/@pmmmwh/react-refresh-webpack-plugin/lib/runtime/RefreshUtils.js */ | ||
"../../43.js"); | ||
require.$Refresh$.runtime = require( | ||
/*webcrack:missing*/ | ||
/*! ./node_modules/react-refresh/runtime.js */ | ||
"../../930.js"); | ||
|
||
/** | ||
* This file allows you to add functionality to the Theme Customizer | ||
* live preview. jQuery is readily available. | ||
* | ||
* @see https://codex.wordpress.org/Theme_Customization_API | ||
*/ | ||
|
||
/** | ||
* Change the blog name value. | ||
*/ | ||
wp.customize('blogname', value => { | ||
value.bind(to => $('.brand').text(to)); | ||
}); | ||
var $ReactRefreshModuleId$ = require.$Refresh$.moduleId; | ||
var $ReactRefreshCurrentExports$ = __react_refresh_utils__.getModuleExports($ReactRefreshModuleId$); | ||
function $ReactRefreshModuleRuntime$(exports) { | ||
if (true) { | ||
var errorOverlay; | ||
if (true) { | ||
errorOverlay = false; | ||
} | ||
var testMode; | ||
if (typeof __react_refresh_test__ !== 'undefined') { | ||
testMode = __react_refresh_test__; | ||
} | ||
return __react_refresh_utils__.executeRuntime(exports, $ReactRefreshModuleId$, module.hot, errorOverlay, testMode); | ||
} | ||
} | ||
if (typeof Promise !== 'undefined' && $ReactRefreshCurrentExports$ instanceof Promise) { | ||
$ReactRefreshCurrentExports$.then($ReactRefreshModuleRuntime$); | ||
} else { | ||
$ReactRefreshModuleRuntime$($ReactRefreshCurrentExports$); | ||
}, | ||
"id": "439", | ||
"isEntry": false, | ||
"path": "./resources/scripts/customizer.js", | ||
}, | ||
"567" => WebpackModule { | ||
"ast": module.exports = window["jQuery"];, | ||
"id": "567", | ||
"isEntry": false, | ||
"path": "jQuery", | ||
}, | ||
}, | ||
"type": "webpack", | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters