@aeriajs/compiler 0.0.39 → 0.0.40
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.
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type * as AST from '../ast.js';
|
|
2
|
-
export declare const generateExports: (ast: AST.ProgramNode,
|
|
2
|
+
export declare const generateExports: (ast: AST.ProgramNode, options?: {
|
|
3
|
+
hasContracts: boolean;
|
|
4
|
+
}) => {
|
|
3
5
|
main: {
|
|
4
6
|
js: string;
|
|
5
7
|
dts: string;
|
|
@@ -2,7 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.generateExports = void 0;
|
|
4
4
|
const utils_js_1 = require("./utils.js");
|
|
5
|
-
const generateExports = (ast,
|
|
5
|
+
const generateExports = (ast, options = {
|
|
6
|
+
hasContracts: false,
|
|
7
|
+
}) => {
|
|
6
8
|
const symbolsToExport = Object.values(ast.collections.reduce((symbols, node) => {
|
|
7
9
|
const id = (0, utils_js_1.getCollectionId)(node.name);
|
|
8
10
|
symbols[id] = {
|
|
@@ -18,19 +20,19 @@ const generateExports = (ast, hasContracts = false) => {
|
|
|
18
20
|
dts: `export { ${symbolsToExport.map((symbol) => `${symbol.id}`).join(', ')} } from './collections.js'`,
|
|
19
21
|
},
|
|
20
22
|
main: {
|
|
21
|
-
js: (hasContracts
|
|
23
|
+
js: (options.hasContracts
|
|
22
24
|
? 'export * as contracts from \'./contracts/index.js\'\n'
|
|
23
25
|
: '') +
|
|
24
26
|
'export * as collections from \'./collections/index.js\'\n' +
|
|
25
27
|
`export { ${symbolsToExport.map((symbol) => symbol.extend).join(', ')} } from './collections/collections.js'`,
|
|
26
|
-
dts: (hasContracts
|
|
28
|
+
dts: (options.hasContracts
|
|
27
29
|
? 'export * as contracts from \'./contracts/index.js\'\n'
|
|
28
30
|
: '') +
|
|
29
31
|
'export * as collections from \'./collections/index.js\'\n' +
|
|
30
32
|
`export { ${symbolsToExport.map((symbol) => `${symbol.extend}, ${symbol.schema}`).join(', ')} } from './collections/collections.js'`,
|
|
31
33
|
},
|
|
32
34
|
};
|
|
33
|
-
if (hasContracts) {
|
|
35
|
+
if (options.hasContracts) {
|
|
34
36
|
exports.contracts = {
|
|
35
37
|
js: 'export * from \'./contracts.js\'',
|
|
36
38
|
dts: 'export * from \'./contracts.js\'',
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
import { resizeFirstChar, getExtendName, getCollectionId } from "./utils.mjs";
|
|
3
|
-
export const generateExports = (ast,
|
|
3
|
+
export const generateExports = (ast, options = {
|
|
4
|
+
hasContracts: false
|
|
5
|
+
}) => {
|
|
4
6
|
const symbolsToExport = Object.values(ast.collections.reduce((symbols, node) => {
|
|
5
7
|
const id = getCollectionId(node.name);
|
|
6
8
|
symbols[id] = {
|
|
@@ -16,13 +18,13 @@ export const generateExports = (ast, hasContracts = false) => {
|
|
|
16
18
|
dts: `export { ${symbolsToExport.map((symbol) => `${symbol.id}`).join(", ")} } from './collections.mjs'`
|
|
17
19
|
},
|
|
18
20
|
main: {
|
|
19
|
-
js: (hasContracts ? "export * as contracts from './contracts/index.mjs'\n" : "") + `export * as collections from './collections/index.mjs'
|
|
21
|
+
js: (options.hasContracts ? "export * as contracts from './contracts/index.mjs'\n" : "") + `export * as collections from './collections/index.mjs'
|
|
20
22
|
export { ${symbolsToExport.map((symbol) => symbol.extend).join(", ")} } from './collections/collections.mjs'`,
|
|
21
|
-
dts: (hasContracts ? "export * as contracts from './contracts/index.mjs'\n" : "") + `export * as collections from './collections/index.mjs'
|
|
23
|
+
dts: (options.hasContracts ? "export * as contracts from './contracts/index.mjs'\n" : "") + `export * as collections from './collections/index.mjs'
|
|
22
24
|
export { ${symbolsToExport.map((symbol) => `${symbol.extend}, ${symbol.schema}`).join(", ")} } from './collections/collections.mjs'`
|
|
23
25
|
}
|
|
24
26
|
};
|
|
25
|
-
if (hasContracts) {
|
|
27
|
+
if (options.hasContracts) {
|
|
26
28
|
exports.contracts = {
|
|
27
29
|
js: "export * from './contracts.mjs'",
|
|
28
30
|
dts: "export * from './contracts.mjs'"
|
package/dist/codegen.js
CHANGED
|
@@ -72,7 +72,9 @@ const generateFileMap = async (fileTree, outDir = '.') => {
|
|
|
72
72
|
};
|
|
73
73
|
const generateCode = async (ast, options) => {
|
|
74
74
|
const contracts = (0, index_js_1.generateContracts)(ast.contracts);
|
|
75
|
-
const exports = (0, index_js_1.generateExports)(ast,
|
|
75
|
+
const exports = (0, index_js_1.generateExports)(ast, {
|
|
76
|
+
hasContracts: !!contracts,
|
|
77
|
+
});
|
|
76
78
|
const fileTree = {
|
|
77
79
|
['collections']: {
|
|
78
80
|
['collections.d.ts']: (0, index_js_1.generateTSCollections)(ast.collections),
|
package/dist/codegen.mjs
CHANGED
|
@@ -23,7 +23,9 @@ const generateFileMap = async (fileTree, outDir = ".") => {
|
|
|
23
23
|
};
|
|
24
24
|
export const generateCode = async (ast, options) => {
|
|
25
25
|
const contracts = generateContracts(ast.contracts);
|
|
26
|
-
const exports = generateExports(ast,
|
|
26
|
+
const exports = generateExports(ast, {
|
|
27
|
+
hasContracts: !!contracts
|
|
28
|
+
});
|
|
27
29
|
const fileTree = {
|
|
28
30
|
["collections"]: {
|
|
29
31
|
["collections.d.ts"]: generateTSCollections(ast.collections),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aeriajs/compiler",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.40",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -21,8 +21,8 @@
|
|
|
21
21
|
"dist"
|
|
22
22
|
],
|
|
23
23
|
"peerDependencies": {
|
|
24
|
-
"@aeriajs/common": "^0.0.
|
|
25
|
-
"@aeriajs/types": "^0.0.
|
|
24
|
+
"@aeriajs/common": "^0.0.145",
|
|
25
|
+
"@aeriajs/types": "^0.0.127"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@aeriajs/common": "link:../common",
|