-
-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: tree shake use self defined idents
- Loading branch information
brightwwu
committed
May 6, 2024
1 parent
4fc6237
commit d960dd2
Showing
6 changed files
with
79 additions
and
11 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
crates/compiler/tests/fixtures/tree_shake/decl/self-ref/dep.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,29 @@ | ||
/** Used to compose unicode character classes. */ | ||
var rsAstralRange = '\\ud800-\\udfff', | ||
rsComboMarksRange = '\\u0300-\\u036f', | ||
reComboHalfMarksRange = '\\ufe20-\\ufe2f', | ||
rsComboSymbolsRange = '\\u20d0-\\u20ff', | ||
rsComboRange = | ||
rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, | ||
rsVarRange = '\\ufe0e\\ufe0f'; | ||
|
||
/** Used to compose unicode capture groups. */ | ||
var rsZWJ = '\\u200d'; | ||
|
||
/** Used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */ | ||
var reHasUnicode = RegExp( | ||
'[' + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + ']' | ||
); | ||
|
||
/** | ||
* Checks if `string` contains Unicode symbols. | ||
* | ||
* @private | ||
* @param {string} string The string to inspect. | ||
* @returns {boolean} Returns `true` if a symbol is found, else `false`. | ||
*/ | ||
function hasUnicode(string) { | ||
return reHasUnicode.test(string); | ||
} | ||
|
||
export default hasUnicode; |
3 changes: 3 additions & 0 deletions
3
crates/compiler/tests/fixtures/tree_shake/decl/self-ref/index.ts
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,3 @@ | ||
import dep from './dep.js'; | ||
|
||
console.log(dep('123')); |
34 changes: 34 additions & 0 deletions
34
crates/compiler/tests/fixtures/tree_shake/decl/self-ref/output.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,34 @@ | ||
//index.js: | ||
(globalThis || window || global)['__farm_default_namespace__'] = {__FARM_TARGET_ENV__: 'browser'};(function(r,e){var t={};function n(r){return Promise.resolve(o(r))}function o(e){if(t[e])return t[e].exports;var i={id:e,exports:{}};r[e](i,i.exports,o,n);t[e]=i;return i.exports}o(e)})({"ec853507":function (module, exports, farmRequire, farmDynamicRequire) { | ||
console.log("runtime/index.js")(globalThis || window || global)["__farm_default_namespace__"].__farm_module_system__.setPlugins([]); | ||
} | ||
,},"ec853507");(function(_){for(var r in _){_[r].__farm_resource_pot__='index_d7d4.js';(globalThis || window || global)['__farm_default_namespace__'].__farm_module_system__.register(r,_[r])}})({"3e3af5b6":function (module, exports, farmRequire, farmDynamicRequire) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
Object.defineProperty(exports, "default", { | ||
enumerable: true, | ||
get: function() { | ||
return _default; | ||
} | ||
}); | ||
var rsAstralRange = "\ud800-\udfff", rsComboMarksRange = "\\u0300-\\u036f", reComboHalfMarksRange = "\\ufe20-\\ufe2f", rsComboSymbolsRange = "\\u20d0-\\u20ff", rsComboRange = rsComboMarksRange + reComboHalfMarksRange + rsComboSymbolsRange, rsVarRange = "\\ufe0e\\ufe0f"; | ||
var rsZWJ = "\\u200d"; | ||
var reHasUnicode = RegExp("[" + rsZWJ + rsAstralRange + rsComboRange + rsVarRange + "]"); | ||
function hasUnicode(string) { | ||
return reHasUnicode.test(string); | ||
} | ||
var _default = hasUnicode; | ||
} | ||
, | ||
"b5d64806":function (module, exports, farmRequire, farmDynamicRequire) { | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
}); | ||
var _interop_require_default = farmRequire("@swc/helpers/_/_interop_require_default"); | ||
var _dep = _interop_require_default._(farmRequire("3e3af5b6")); | ||
console.log((0, _dep.default)("123")); | ||
} | ||
,});(globalThis || window || global)['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);(globalThis || window || global)['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap({ });var farmModuleSystem = (globalThis || window || global)['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806"); |
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
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
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