-
-
Notifications
You must be signed in to change notification settings - Fork 173
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: namespace fallback when use literal computed (#2022)
- Loading branch information
1 parent
83fb24e
commit 9e9e94e
Showing
11 changed files
with
111 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"@farmfe/core": patch | ||
--- | ||
|
||
fix namespace fallback when use literal computed |
2 changes: 2 additions & 0 deletions
2
crates/compiler/tests/fixtures/tree_shake/import_namespace/fallback/foo.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,2 @@ | ||
export const foo = 'foo'; | ||
export const bar = 'bar'; |
5 changes: 5 additions & 0 deletions
5
crates/compiler/tests/fixtures/tree_shake/import_namespace/fallback/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,5 @@ | ||
import * as n1 from './foo'; | ||
|
||
const field = 'foo'; | ||
|
||
console.log(n1[field]); |
87 changes: 87 additions & 0 deletions
87
crates/compiler/tests/fixtures/tree_shake/import_namespace/fallback/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,87 @@ | ||
//index.js: | ||
window['__farm_default_namespace__'] = {__FARM_TARGET_ENV__: 'browser'};function _interop_require_default(obj) { | ||
return obj && obj.__esModule ? obj : { | ||
default: obj | ||
}; | ||
}function _export_star(from, to) { | ||
Object.keys(from).forEach(function(k) { | ||
if (k !== "default" && !Object.prototype.hasOwnProperty.call(to, k)) { | ||
Object.defineProperty(to, k, { | ||
enumerable: true, | ||
get: function() { | ||
return from[k]; | ||
} | ||
}); | ||
} | ||
}); | ||
return from; | ||
}function _interop_require_wildcard(obj, nodeInterop) { | ||
if (!nodeInterop && obj && obj.__esModule) return obj; | ||
if (obj === null || typeof obj !== "object" && typeof obj !== "function") return { | ||
default: obj | ||
}; | ||
var cache = _getRequireWildcardCache(nodeInterop); | ||
if (cache && cache.has(obj)) return cache.get(obj); | ||
var newObj = { | ||
__proto__: null | ||
}; | ||
var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; | ||
for(var key in obj){ | ||
if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { | ||
var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; | ||
if (desc && (desc.get || desc.set)) Object.defineProperty(newObj, key, desc); | ||
else newObj[key] = obj[key]; | ||
} | ||
} | ||
newObj.default = obj; | ||
if (cache) cache.set(obj, newObj); | ||
return newObj; | ||
}function _getRequireWildcardCache(nodeInterop) { | ||
if (typeof WeakMap !== "function") return null; | ||
var cacheBabelInterop = new WeakMap(); | ||
var cacheNodeInterop = new WeakMap(); | ||
return (_getRequireWildcardCache = function(nodeInterop) { | ||
return nodeInterop ? cacheNodeInterop : cacheBabelInterop; | ||
})(nodeInterop); | ||
}function __commonJs(mod) { | ||
var module; | ||
return () => { | ||
if (module) { | ||
return module.exports; | ||
} | ||
module = { | ||
exports: {}, | ||
}; | ||
if(typeof mod === "function") { | ||
mod(module, module.exports); | ||
}else { | ||
mod[Object.keys(mod)[0]](module, module.exports); | ||
} | ||
return module.exports; | ||
}; | ||
}((function(){var index_js_cjs = __commonJs((module, exports)=>{ | ||
"use strict"; | ||
console.log('runtime/index.js'); | ||
window['__farm_default_namespace__'].__farm_module_system__.setPlugins([]); | ||
}); | ||
index_js_cjs(); | ||
})());(function(_){var filename = ((function(){var _documentCurrentScript = typeof document !== "undefined" ? document.currentScript : null;return typeof document === "undefined" ? require("url").pathToFileURL(__filename).href : _documentCurrentScript && _documentCurrentScript.src || new URL("index_e094.js", document.baseURI).href})());for(var r in _){_[r].__farm_resource_pot__=filename;window['__farm_default_namespace__'].__farm_module_system__.register(r,_[r])}})({"6d686e48":function (module, exports, farmRequire, farmDynamicRequire) { | ||
module._m(exports); | ||
module.o(exports, "foo", function() { | ||
return foo; | ||
}); | ||
module.o(exports, "bar", function() { | ||
return bar; | ||
}); | ||
var foo = 'foo'; | ||
var bar = 'bar'; | ||
} | ||
, | ||
"b5d64806":function (module, exports, farmRequire, farmDynamicRequire) { | ||
module._m(exports); | ||
var _f_foo = module.w(farmRequire("6d686e48")); | ||
var n1 = _f_foo; | ||
const field = 'foo'; | ||
console.log(n1[field]); | ||
} | ||
,});window['__farm_default_namespace__'].__farm_module_system__.setInitialLoadedResources([]);window['__farm_default_namespace__'].__farm_module_system__.setDynamicModuleResourcesMap([],{ });var farmModuleSystem = window['__farm_default_namespace__'].__farm_module_system__;farmModuleSystem.bootstrap();var entry = farmModuleSystem.require("b5d64806"); |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
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