mirror of
https://github.com/denoland/deno.git
synced 2024-11-24 15:19:26 -05:00
parent
6066e069d1
commit
a9708037c9
9 changed files with 51 additions and 7 deletions
|
@ -86,7 +86,7 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
|
|||
permissions: &dyn NodePermissions,
|
||||
) -> Result<String, AnyError> {
|
||||
let mut temp_var_count = 0;
|
||||
let mut handled_reexports: HashSet<String> = HashSet::default();
|
||||
let mut handled_reexports: HashSet<ModuleSpecifier> = HashSet::default();
|
||||
|
||||
let analysis = self.cjs_code_analyzer.analyze_cjs(specifier, source)?;
|
||||
|
||||
|
@ -114,12 +114,6 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
|
|||
}
|
||||
|
||||
while let Some((reexport, referrer)) = reexports_to_handle.pop_front() {
|
||||
if handled_reexports.contains(&reexport) {
|
||||
continue;
|
||||
}
|
||||
|
||||
handled_reexports.insert(reexport.to_string());
|
||||
|
||||
// First, resolve the reexport specifier
|
||||
let reexport_specifier = self.resolve(
|
||||
&reexport,
|
||||
|
@ -131,6 +125,10 @@ impl<TCjsCodeAnalyzer: CjsCodeAnalyzer> NodeCodeTranslator<TCjsCodeAnalyzer> {
|
|||
permissions,
|
||||
)?;
|
||||
|
||||
if !handled_reexports.insert(reexport_specifier.clone()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Second, resolve its exports and re-exports
|
||||
let analysis = self
|
||||
.cjs_code_analyzer
|
||||
|
|
|
@ -0,0 +1 @@
|
|||
module.exports.main = 1;
|
|
@ -0,0 +1,14 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
// specifier here is the same as in sub/index.js
|
||||
__exportStar(require("./api"), exports);
|
||||
__exportStar(require("./sub"), exports);
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"name": "@denotest/cjs-reexport-same-specifier-in-sub-folder",
|
||||
"version": "1.0.0"
|
||||
}
|
|
@ -0,0 +1 @@
|
|||
module.exports.sub = 2;
|
|
@ -0,0 +1,12 @@
|
|||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
__exportStar(require("./api"), exports);
|
|
@ -0,0 +1,4 @@
|
|||
{
|
||||
"args": "run main.ts",
|
||||
"output": "main.out"
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
Download http://localhost:4260/@denotest/cjs-reexport-same-specifier-in-sub-folder
|
||||
Download http://localhost:4260/@denotest/cjs-reexport-same-specifier-in-sub-folder/1.0.0.tgz
|
||||
[Module: null prototype] {
|
||||
default: { main: [Getter], sub: [Getter] },
|
||||
main: 1,
|
||||
sub: 2
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
import * as module from "npm:@denotest/cjs-reexport-same-specifier-in-sub-folder";
|
||||
|
||||
console.log(module);
|
Loading…
Reference in a new issue