This commit is contained in:
InversionSpaces 2023-12-06 11:33:35 +00:00
parent 5044dd030d
commit 46ab9e223f
12 changed files with 102 additions and 4 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -0,0 +1,12 @@
aqua Main
export versionBC, versionAC
use "A.aqua"
use "B.aqua"
func versionAC() -> string:
<- A.versionC()
func versionBC() -> string:
<- B.versionC()

View File

@ -0,0 +1,8 @@
{
"name": "Project",
"version": "0.1.0",
"dependencies": {
"A": "file:../A-0.1.0.tgz",
"B": "file:../B-0.1.0.tgz"
}
}

View File

@ -0,0 +1,34 @@
import { gatherImportsFromNpm } from "../imports.js";
describe("imports", () => {
it("should resolve transitive dependencies", async () => {
const imports = await gatherImportsFromNpm(
"./__test__/data/transitive-deps/project",
);
const projectPath = Object.keys(imports).find((p) => p.endsWith("project"));
expect(projectPath).toBeDefined();
const projectImports = imports[projectPath!];
expect(projectImports.length).toEqual(2);
const [dep1Path, dep2Path] = projectImports;
const dep1Imports = imports[dep1Path];
const dep2Imports = imports[dep2Path];
expect(dep1Imports.length).toEqual(1);
expect(dep2Imports.length).toEqual(1);
const [dep1Transitive] = dep1Imports;
const [dep2Transitive] = dep2Imports;
expect(dep1Transitive.endsWith("C")).toBeTruthy();
expect(dep2Transitive.endsWith("C")).toBeTruthy();
// Transitive dependency should be resolved to different paths
expect(dep1Transitive).not.toEqual(dep2Transitive);
});
});

View File

@ -1,6 +1,6 @@
import Arborist from "@npmcli/arborist";
import type { Imports } from "./index.d.ts";
export declare type Imports = Record<string, string[]>;
/**
* Gather imports for aqua compiler from

View File

@ -21,8 +21,6 @@ export declare class CompilationResult {
generatedSources: GeneratedSource[];
}
export type Imports = Record<string, string[]> | string[];
/** Common arguments for all compile functions */
type CommonArgs = {
/** Paths to directories, which you want to import .aqua files from. Example: ["./path/to/dir"] */

View File

@ -0,0 +1,16 @@
/** @type {import('ts-jest').JestConfigWithTsJest} */
module.exports = {
extensionsToTreatAsEsm: [".ts"],
preset: "ts-jest/presets/default-esm",
moduleNameMapper: {
"^(\\.{1,2}/.*)\\.js$": "$1",
},
transform: {
"^.+\\.tsx?$": [
"ts-jest",
{
useESM: true,
},
],
},
};

View File

@ -27,12 +27,21 @@
"url": "https://github.com/fluencelabs/aqua/issues"
},
"homepage": "https://github.com/fluencelabs/aqua#readme",
"scripts": {
"test": "NODE_OPTIONS=--experimental-vm-modules npx jest --detectOpenHandles"
},
"optionalDependencies": {
"@npmcli/arborist": "7.2.1",
"treeverse": "3.0.0"
},
"devDependencies": {
"@fluencelabs/interfaces": "0.9.0",
"prettier": "3.0.0"
"@types/jest": "29.5.2",
"@types/node": "^20.10.3",
"prettier": "3.0.0",
"jest": "29.5.0",
"ts-jest": "29.1.0",
"ts-node": "10.9.1",
"typescript": "5.1.3"
}
}

21
api/api-npm/tsconfig.json Normal file
View File

@ -0,0 +1,21 @@
{
"compilerOptions": {
"allowJs": true,
"target": "ESNext",
"module": "ESNext",
"lib": ["es2015", "dom"],
"declaration": true,
"outDir": "dist",
"moduleResolution": "nodenext",
"strict": true,
"esModuleInterop": true,
"noImplicitAny": false,
"strictNullChecks": false,
"skipLibCheck": true
},
"exclude": ["node_modules", "dist", "bundle"],
"include": ["__test__/**/*"],
"ts-node": {
"esm": true
}
}