Skip to content

Commit 9ea5f13

Browse files
committed
Fixup entry points
1 parent 9ed6388 commit 9ea5f13

File tree

10 files changed

+19
-69
lines changed

10 files changed

+19
-69
lines changed

packages/engine/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
index.js
2-
engine.d.ts
32
types
43
!Specs/types
54
Build

packages/engine/engine.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./index.js";

packages/engine/package.json

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@
5656
"type": "module",
5757
"scripts": {
5858
"build": "gulp build --workspace @cesium/engine",
59-
"build-ts": "rm -rf engine.d.ts && tsc --build --clean && tsc --build",
60-
"test-ts": "tsd --files Specs/types/*.test-d.ts",
59+
"build-ts": "tsc --build --clean && tsc --build",
60+
"test-ts": "tsd",
6161
"coverage": "gulp coverage --workspace @cesium/engine",
6262
"test": "gulp test --workspace @cesium/engine",
6363
"postversion": "gulp postversion --workspace @cesium/engine"
@@ -74,5 +74,8 @@
7474
},
7575
"bugs": {
7676
"url": "https://github.com/CesiumGS/cesium/issues"
77+
},
78+
"tsd": {
79+
"directory": "Specs/types"
7780
}
7881
}

packages/engine/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
],
99
"compilerOptions": {
1010
"strict": true,
11-
"verbatimModuleSyntax": true,
1211
"composite": true,
1312
"allowJs": true,
1413
"declaration": true,

packages/widgets/.gitignore

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
Build
22
Specs/SpecList.js
33
index.js
4-
widgets.d.ts
5-
types
4+
types
5+
!Specs/types
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { expectType } from "tsd";
2+
3+
import {
4+
Viewer
5+
} from "@cesium/widgets";
6+
7+
expectType<Viewer>(new Viewer("test"));

packages/widgets/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,8 @@
5353
},
5454
"bugs": {
5555
"url": "https://github.com/CesiumGS/cesium/issues"
56+
},
57+
"tsd": {
58+
"directory": "Specs/types"
5659
}
5760
}

packages/widgets/tsconfig.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"include": ["Source/**/*.js"],
33
"compilerOptions": {
44
"strict": true,
5-
"verbatimModuleSyntax": true,
65
"composite": true,
76
"allowJs": true,
87
"declaration": true,

packages/widgets/widgets.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from "./index.js";

scripts/build.js

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -890,62 +890,6 @@ export async function createIndexJs(workspace) {
890890
return contents;
891891
}
892892

893-
/**
894-
* Creates the type declaration entry point for a package.
895-
*
896-
* @param {string} workspace The workspace for which to create the entry point
897-
* @param {string="index"} entryName The base file name for the entry point
898-
* @returns {string} The file contents
899-
*/
900-
export async function createDeclarationIndex(workspace, entryName="index") {
901-
const rootDir = path.resolve(path.join(__dirname, "..", "packages", workspace));
902-
const tsConfig = require(path.join(rootDir, "tsconfig.json"));
903-
const typesDir = path.join(rootDir, tsConfig.compilerOptions.outDir);
904-
905-
let contents = "";
906-
907-
const files = await globby(tsConfig.include.map(glob => path.join(rootDir, glob)));
908-
const excludes = tsConfig.exclude ? await globby(tsConfig.exclude.map(glob => path.join(rootDir, glob))) : [];
909-
files.forEach(function (file) {
910-
const { name, dir } = path.parse(file);
911-
const relativePath = path.relative(rootDir, dir);
912-
let modulePrefix = relativePath;
913-
914-
// Prioritize neighbor files
915-
let declaration = path.join(dir, `${name}.d.ts`);
916-
if (!existsSync(declaration)) {
917-
// Fallback to generated types
918-
modulePrefix = path.join(path.relative(rootDir, typesDir), relativePath);
919-
declaration = path.join(rootDir, modulePrefix, `${name}.d.ts`);
920-
}
921-
922-
// Don't export shader file types
923-
const isShader = relativePath.indexOf("Source/Shaders/") === 0;
924-
if (!existsSync(declaration) || isShader) {
925-
926-
if (!isShader && !excludes.includes(file)) {
927-
console.warn(`No declaration found for ${file}. Do you need to run build-ts?`);
928-
}
929-
930-
return;
931-
}
932-
933-
const moduleId = path.posix.format({
934-
dir: modulePrefix,
935-
base: name
936-
});
937-
938-
const assignmentName = name.replace(/(\.|-)/g, "_");
939-
contents += `export type { default as ${assignmentName} } from './${moduleId}.d.ts';${EOL}`;
940-
});
941-
942-
await writeFile(`packages/${workspace}/${entryName}.d.ts`, contents, {
943-
encoding: "utf-8",
944-
});
945-
946-
return contents;
947-
}
948-
949893
/**
950894
* Creates a single entry point file by importing all individual spec files.
951895
* @param {string[]} files The individual spec files.
@@ -1070,9 +1014,6 @@ export const buildEngine = async (options) => {
10701014
// Create index.js
10711015
await createIndexJs("engine");
10721016

1073-
// Create engine.d.ts
1074-
await createDeclarationIndex("engine", "engine");
1075-
10761017
// Build workers.
10771018
await bundleWorkers({
10781019
...options,
@@ -1113,9 +1054,6 @@ export const buildWidgets = async (options) => {
11131054
// Create index.js
11141055
await createIndexJs("widgets");
11151056

1116-
// Create widgets.d.ts
1117-
await createDeclarationIndex("widgets", "widgets");
1118-
11191057
// Create SpecList.js
11201058
const specFiles = await globby(workspaceSpecFiles["widgets"]);
11211059
const specListFile = path.join("packages/widgets/Specs", "SpecList.js");

0 commit comments

Comments
 (0)