Skip to content

Commit

Permalink
chore: 🤖 update add variable usage
Browse files Browse the repository at this point in the history
  • Loading branch information
IWANABETHATGUY committed Oct 16, 2023
1 parent dec606e commit 085f0de
Show file tree
Hide file tree
Showing 10 changed files with 208 additions and 146 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ source: crates/rspack_testing/src/run_fixture.rs
"./answer.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
'use strict';
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
'answer': function() { return answer; }
});
const answer = 103330; // export default answer;
},
"./app.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
Expand All @@ -20,7 +23,7 @@ __webpack_require__.d(__webpack_exports__, {
function render() {
function test() {
const container = document.getElementById("root");
container.innerHTML = `adddd333:${secret}:${myanswer}`;
container.innerHTML = `adddd333:${_lib__WEBPACK_IMPORTED_MODULE_0_.secret}:${_lib__WEBPACK_IMPORTED_MODULE_0_.myanswer}`;
}
}
function result() {}
Expand All @@ -35,10 +38,14 @@ __webpack_require__.r(__webpack_exports__);
"./lib.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
'use strict';
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
'secret': function() { return secret; },
'myanswer': function() { return myanswer; }
});
/* harmony import */var _answer__WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(/* ./answer */"./answer.js");
const secret = "888";
const myanswer = answer, result = 20000;
const myanswer = _answer__WEBPACK_IMPORTED_MODULE_0_.answer, result = 20000;
},
},function(__webpack_require__) {
Expand Down
37 changes: 0 additions & 37 deletions crates/rspack/tests/tree-shaking/default_export/snapshot/snap.diff

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@ __webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
'test': function() { return test; }
});
/* harmony import */var _module__WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(/* ./module */"./module.js");
function test() {
doSomething({
(0, _module__WEBPACK_IMPORTED_MODULE_0_["default"])({
type: "inline"
});
}
Expand All @@ -36,6 +37,46 @@ it("should generate correct code when pure expressions are in dead branches", ()
]);
});
},
"./module.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
'use strict';
__webpack_require__.r(__webpack_exports__);
__webpack_require__.d(__webpack_exports__, {
'default': function() { return __WEBPACK_DEFAULT_EXPORT__; }
});
function getType(obj) {
return obj.type;
}
// Local functions
function doSomethingWithBlock(obj) {
return Block.doSomething(obj);
}
function doSomethingWithInline(obj) {
return Inline.doSomething(obj);
}
function doSomethingWithDocument(obj) {
return Document.doSomething(obj);
}
// Exported functions
function doSomething(obj) {
const type = getType(obj);
switch(type){
case "document":
return doSomethingWithDocument(obj);
case "block":
return doSomethingWithBlock(obj);
case "inline":
return doSomethingWithInline(obj);
default:
throw new Error();
}
}
function useDocument(obj) {
return doSomethingWithDocument(obj);
}
var __WEBPACK_DEFAULT_EXPORT__ = doSomething;
},
},function(__webpack_require__) {
var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) }
Expand Down
Original file line number Diff line number Diff line change
@@ -1,74 +1,48 @@
--- expected
+++ actual
@@ -20,10 +20,9 @@
@@ -43,20 +43,19 @@
__webpack_require__.d(__webpack_exports__, {
'test': function() { return test; }
'default': function() { return __WEBPACK_DEFAULT_EXPORT__; }
});
-/* harmony import */var _module__WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(/* ./module */"./module.js");
-/* harmony import */var _some_module__WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(/* ./some-module */"./some-module.js");

function test() {
- (0, _module__WEBPACK_IMPORTED_MODULE_0_["default"])({
+ doSomething({
type: "inline"
});
function getType(obj) {
return obj.type;
}
@@ -37,47 +36,17 @@
]);
});
},
-"./module.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
-'use strict';
-__webpack_require__.r(__webpack_exports__);
-__webpack_require__.d(__webpack_exports__, {
- 'default': function() { return __WEBPACK_DEFAULT_EXPORT__; }
-});
-/* harmony import */var _some_module__WEBPACK_IMPORTED_MODULE_0_ = __webpack_require__(/* ./some-module */"./some-module.js");
// Local functions
function doSomethingWithBlock(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Block.doSomething(obj);
+ return Block.doSomething(obj);
}
function doSomethingWithInline(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Inline.doSomething(obj);
+ return Inline.doSomething(obj);
}
function doSomethingWithDocument(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Document.doSomething(obj);
+ return Document.doSomething(obj);
}
// Exported functions
function doSomething(obj) {
@@ -78,6 +77,17 @@

-function getType(obj) {
- return obj.type;
var __WEBPACK_DEFAULT_EXPORT__ = doSomething;
},
+
+},function(__webpack_require__) {
+var __webpack_exec__ = function(moduleId) { return __webpack_require__(__webpack_require__.s = moduleId) }
+var __webpack_exports__ = (__webpack_exec__("./index.js"));
+
}
-// Local functions
-function doSomethingWithBlock(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Block.doSomething(obj);
-}
-function doSomethingWithInline(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Inline.doSomething(obj);
-}
-function doSomethingWithDocument(obj) {
- return _some_module__WEBPACK_IMPORTED_MODULE_0_.Document.doSomething(obj);
-}
-// Exported functions
-function doSomething(obj) {
- const type = getType(obj);
- switch(type){
- case "document":
- return doSomethingWithDocument(obj);
- case "block":
- return doSomethingWithBlock(obj);
- case "inline":
- return doSomethingWithInline(obj);
- default:
- throw new Error();
- }
-}
-function useDocument(obj) {
- return doSomethingWithDocument(obj);
-}
+}
+]);
+```

-var __WEBPACK_DEFAULT_EXPORT__ = doSomething;
-},
+
+```js title=some-module_js.js
+(self['webpackChunkwebpack'] = self['webpackChunkwebpack'] || []).push([["some-module_js"], {
"./some-module.js": function (__unused_webpack_module, __webpack_exports__, __webpack_require__) {
'use strict';
__webpack_require__.r(__webpack_exports__);
@@ -98,10 +67,5 @@
@@ -98,10 +108,5 @@

},

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ impl ModuleDependency for HarmonyImportSpecifierDependency {
}

fn get_condition(&self) -> Option<DependencyCondition> {
// dbg!(&self.ids, self.request(), self.used_by_exports.as_ref());
get_dependency_used_by_exports_condition(self.id, self.used_by_exports.as_ref())
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl ParserAndGenerator for JavaScriptParserAndGenerator {
RawSource::from(content).boxed()
}
if let Some(mut inner_graph) = inner_graph {
dbg!(module_identifier);

Check failure on line 211 in crates/rspack_plugin_javascript/src/parser_and_generator/mod.rs

View workflow job for this annotation

GitHub Actions / Rust check

the `dbg!` macro is intended as a debugging tool
inner_graph.infer_dependency_usage();
}

Expand Down
Loading

0 comments on commit 085f0de

Please sign in to comment.