jslike 1.6.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/interpreter/interpreter.js +30 -23
- package/dist/index.cjs +19 -14
- package/dist/index.d.cts +27 -20
- package/dist/index.d.ts +27 -20
- package/dist/index.js +19 -14
- package/package.json +1 -1
|
@@ -1671,29 +1671,36 @@ export class Interpreter {
|
|
|
1671
1671
|
throw new Error(`Cannot find module '${modulePath}'`);
|
|
1672
1672
|
}
|
|
1673
1673
|
|
|
1674
|
-
// Handle
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1674
|
+
// Handle native module exports (for libraries like React)
|
|
1675
|
+
// If resolution has 'exports' property, use it directly without parsing
|
|
1676
|
+
if (resolution.exports) {
|
|
1677
|
+
moduleExports = resolution.exports;
|
|
1678
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
1679
|
+
} else {
|
|
1680
|
+
// Handle both old (string) and new (ModuleResolution) formats
|
|
1681
|
+
const moduleCode = typeof resolution === 'string' ? resolution : resolution.code;
|
|
1682
|
+
|
|
1683
|
+
// Parse and execute module in its own environment
|
|
1684
|
+
const moduleAst = acornParse(moduleCode, {
|
|
1685
|
+
ecmaVersion: 2020,
|
|
1686
|
+
sourceType: 'module',
|
|
1687
|
+
locations: false
|
|
1688
|
+
});
|
|
1689
|
+
const moduleEnv = new Environment(this.globalEnv);
|
|
1690
|
+
|
|
1691
|
+
// Create a new interpreter for the module with shared module cache
|
|
1692
|
+
const moduleInterpreter = new Interpreter(this.globalEnv, {
|
|
1693
|
+
moduleResolver: this.moduleResolver
|
|
1694
|
+
});
|
|
1695
|
+
moduleInterpreter.moduleCache = this.moduleCache; // Share cache
|
|
1696
|
+
|
|
1697
|
+
// Execute module and collect exports
|
|
1698
|
+
await moduleInterpreter.evaluateAsync(moduleAst, moduleEnv);
|
|
1699
|
+
|
|
1700
|
+
// Cache the module exports
|
|
1701
|
+
moduleExports = moduleInterpreter.moduleExports;
|
|
1702
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
1703
|
+
}
|
|
1697
1704
|
}
|
|
1698
1705
|
|
|
1699
1706
|
// Import specified bindings into current environment
|
package/dist/index.cjs
CHANGED
|
@@ -7765,20 +7765,25 @@ var Interpreter = class _Interpreter {
|
|
|
7765
7765
|
if (!resolution) {
|
|
7766
7766
|
throw new Error(`Cannot find module '${modulePath}'`);
|
|
7767
7767
|
}
|
|
7768
|
-
|
|
7769
|
-
|
|
7770
|
-
|
|
7771
|
-
|
|
7772
|
-
|
|
7773
|
-
|
|
7774
|
-
|
|
7775
|
-
|
|
7776
|
-
|
|
7777
|
-
|
|
7778
|
-
|
|
7779
|
-
|
|
7780
|
-
|
|
7781
|
-
|
|
7768
|
+
if (resolution.exports) {
|
|
7769
|
+
moduleExports = resolution.exports;
|
|
7770
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
7771
|
+
} else {
|
|
7772
|
+
const moduleCode = typeof resolution === "string" ? resolution : resolution.code;
|
|
7773
|
+
const moduleAst = jsxParse(moduleCode, {
|
|
7774
|
+
ecmaVersion: 2020,
|
|
7775
|
+
sourceType: "module",
|
|
7776
|
+
locations: false
|
|
7777
|
+
});
|
|
7778
|
+
const moduleEnv = new Environment(this.globalEnv);
|
|
7779
|
+
const moduleInterpreter = new _Interpreter(this.globalEnv, {
|
|
7780
|
+
moduleResolver: this.moduleResolver
|
|
7781
|
+
});
|
|
7782
|
+
moduleInterpreter.moduleCache = this.moduleCache;
|
|
7783
|
+
await moduleInterpreter.evaluateAsync(moduleAst, moduleEnv);
|
|
7784
|
+
moduleExports = moduleInterpreter.moduleExports;
|
|
7785
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
7786
|
+
}
|
|
7782
7787
|
}
|
|
7783
7788
|
for (const specifier of node.specifiers) {
|
|
7784
7789
|
if (specifier.type === "ImportSpecifier") {
|
package/dist/index.d.cts
CHANGED
|
@@ -8836,29 +8836,36 @@ class Interpreter {
|
|
|
8836
8836
|
throw new Error(`Cannot find module '${modulePath}'`);
|
|
8837
8837
|
}
|
|
8838
8838
|
|
|
8839
|
-
// Handle
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8839
|
+
// Handle native module exports (for libraries like React)
|
|
8840
|
+
// If resolution has 'exports' property, use it directly without parsing
|
|
8841
|
+
if (resolution.exports) {
|
|
8842
|
+
moduleExports = resolution.exports;
|
|
8843
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
8844
|
+
} else {
|
|
8845
|
+
// Handle both old (string) and new (ModuleResolution) formats
|
|
8846
|
+
const moduleCode = typeof resolution === 'string' ? resolution : resolution.code;
|
|
8847
|
+
|
|
8848
|
+
// Parse and execute module in its own environment
|
|
8849
|
+
const moduleAst = jsxParse(moduleCode, {
|
|
8850
|
+
ecmaVersion: 2020,
|
|
8851
|
+
sourceType: 'module',
|
|
8852
|
+
locations: false
|
|
8853
|
+
});
|
|
8854
|
+
const moduleEnv = new Environment(this.globalEnv);
|
|
8849
8855
|
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8856
|
+
// Create a new interpreter for the module with shared module cache
|
|
8857
|
+
const moduleInterpreter = new Interpreter(this.globalEnv, {
|
|
8858
|
+
moduleResolver: this.moduleResolver
|
|
8859
|
+
});
|
|
8860
|
+
moduleInterpreter.moduleCache = this.moduleCache; // Share cache
|
|
8855
8861
|
|
|
8856
|
-
|
|
8857
|
-
|
|
8862
|
+
// Execute module and collect exports
|
|
8863
|
+
await moduleInterpreter.evaluateAsync(moduleAst, moduleEnv);
|
|
8858
8864
|
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8865
|
+
// Cache the module exports
|
|
8866
|
+
moduleExports = moduleInterpreter.moduleExports;
|
|
8867
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
8868
|
+
}
|
|
8862
8869
|
}
|
|
8863
8870
|
|
|
8864
8871
|
// Import specified bindings into current environment
|
package/dist/index.d.ts
CHANGED
|
@@ -8836,29 +8836,36 @@ class Interpreter {
|
|
|
8836
8836
|
throw new Error(`Cannot find module '${modulePath}'`);
|
|
8837
8837
|
}
|
|
8838
8838
|
|
|
8839
|
-
// Handle
|
|
8840
|
-
|
|
8841
|
-
|
|
8842
|
-
|
|
8843
|
-
|
|
8844
|
-
|
|
8845
|
-
|
|
8846
|
-
|
|
8847
|
-
|
|
8848
|
-
|
|
8839
|
+
// Handle native module exports (for libraries like React)
|
|
8840
|
+
// If resolution has 'exports' property, use it directly without parsing
|
|
8841
|
+
if (resolution.exports) {
|
|
8842
|
+
moduleExports = resolution.exports;
|
|
8843
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
8844
|
+
} else {
|
|
8845
|
+
// Handle both old (string) and new (ModuleResolution) formats
|
|
8846
|
+
const moduleCode = typeof resolution === 'string' ? resolution : resolution.code;
|
|
8847
|
+
|
|
8848
|
+
// Parse and execute module in its own environment
|
|
8849
|
+
const moduleAst = jsxParse(moduleCode, {
|
|
8850
|
+
ecmaVersion: 2020,
|
|
8851
|
+
sourceType: 'module',
|
|
8852
|
+
locations: false
|
|
8853
|
+
});
|
|
8854
|
+
const moduleEnv = new Environment(this.globalEnv);
|
|
8849
8855
|
|
|
8850
|
-
|
|
8851
|
-
|
|
8852
|
-
|
|
8853
|
-
|
|
8854
|
-
|
|
8856
|
+
// Create a new interpreter for the module with shared module cache
|
|
8857
|
+
const moduleInterpreter = new Interpreter(this.globalEnv, {
|
|
8858
|
+
moduleResolver: this.moduleResolver
|
|
8859
|
+
});
|
|
8860
|
+
moduleInterpreter.moduleCache = this.moduleCache; // Share cache
|
|
8855
8861
|
|
|
8856
|
-
|
|
8857
|
-
|
|
8862
|
+
// Execute module and collect exports
|
|
8863
|
+
await moduleInterpreter.evaluateAsync(moduleAst, moduleEnv);
|
|
8858
8864
|
|
|
8859
|
-
|
|
8860
|
-
|
|
8861
|
-
|
|
8865
|
+
// Cache the module exports
|
|
8866
|
+
moduleExports = moduleInterpreter.moduleExports;
|
|
8867
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
8868
|
+
}
|
|
8862
8869
|
}
|
|
8863
8870
|
|
|
8864
8871
|
// Import specified bindings into current environment
|
package/dist/index.js
CHANGED
|
@@ -7731,20 +7731,25 @@ var Interpreter = class _Interpreter {
|
|
|
7731
7731
|
if (!resolution) {
|
|
7732
7732
|
throw new Error(`Cannot find module '${modulePath}'`);
|
|
7733
7733
|
}
|
|
7734
|
-
|
|
7735
|
-
|
|
7736
|
-
|
|
7737
|
-
|
|
7738
|
-
|
|
7739
|
-
|
|
7740
|
-
|
|
7741
|
-
|
|
7742
|
-
|
|
7743
|
-
|
|
7744
|
-
|
|
7745
|
-
|
|
7746
|
-
|
|
7747
|
-
|
|
7734
|
+
if (resolution.exports) {
|
|
7735
|
+
moduleExports = resolution.exports;
|
|
7736
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
7737
|
+
} else {
|
|
7738
|
+
const moduleCode = typeof resolution === "string" ? resolution : resolution.code;
|
|
7739
|
+
const moduleAst = jsxParse(moduleCode, {
|
|
7740
|
+
ecmaVersion: 2020,
|
|
7741
|
+
sourceType: "module",
|
|
7742
|
+
locations: false
|
|
7743
|
+
});
|
|
7744
|
+
const moduleEnv = new Environment(this.globalEnv);
|
|
7745
|
+
const moduleInterpreter = new _Interpreter(this.globalEnv, {
|
|
7746
|
+
moduleResolver: this.moduleResolver
|
|
7747
|
+
});
|
|
7748
|
+
moduleInterpreter.moduleCache = this.moduleCache;
|
|
7749
|
+
await moduleInterpreter.evaluateAsync(moduleAst, moduleEnv);
|
|
7750
|
+
moduleExports = moduleInterpreter.moduleExports;
|
|
7751
|
+
this.moduleCache.set(modulePath, moduleExports);
|
|
7752
|
+
}
|
|
7748
7753
|
}
|
|
7749
7754
|
for (const specifier of node.specifiers) {
|
|
7750
7755
|
if (specifier.type === "ImportSpecifier") {
|