-
Notifications
You must be signed in to change notification settings - Fork 244
fix(compass-web): bundle type definitions COMPASS-9733 #7227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 6 commits
c392ead
22c3d0c
3466db5
491dbe8
771266d
16ee949
f78da17
837439e
d00e798
813bb5c
300e5bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "$schema": "https://developer.microsoft.com/json-schemas/api-extractor/v7/api-extractor.schema.json", | ||
| "mainEntryPointFilePath": "./dist/index.d.ts", | ||
| "newlineKind": "lf", | ||
| "bundledPackages": [ | ||
| "@mongodb-js/*", | ||
| "@mongodb-js/mdb-experiment-js", | ||
| "@mongodb-js/connection-info", | ||
| "bson-transpilers", | ||
| "compass-e2e-tests", | ||
| "compass-preferences-model", | ||
| "hadron-build", | ||
| "hadron-document", | ||
| "hadron-ipc", | ||
| "hadron-type-checker", | ||
| "mongodb-instance-model", | ||
| "mongodb-explain-compat", | ||
| "mongodb-query-util", | ||
| "mongodb-data-service", | ||
| "mongodb-database-model", | ||
| "mongodb-collection-model", | ||
| "mongodb-compass" | ||
| ], | ||
| "compiler": { | ||
| "tsconfigFilePath": "./tsconfig-build.json" | ||
| }, | ||
| "dtsRollup": { | ||
| "enabled": true, | ||
| "untrimmedFilePath": "", | ||
| "publicTrimmedFilePath": "./dist/<unscopedPackageName>.d.ts" | ||
| }, | ||
| "apiReport": { | ||
| "enabled": false | ||
| }, | ||
| "docModel": { | ||
| "enabled": false | ||
| } | ||
| } | ||
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -33,13 +33,17 @@ | |||||||
| ".": "./src/index.tsx", | ||||||||
| "./package.json": "./package.json" | ||||||||
| }, | ||||||||
| "types": "./dist/index.d.ts", | ||||||||
| "types": "./dist/compass-web.d.ts", | ||||||||
| "scripts": { | ||||||||
| "prepublishOnly": "npm run compile && compass-scripts check-exports-exist", | ||||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Check in CI is currently failing because we don't have a bootstrap script in compass-web (it was just not needed before). Now that check depends on some assets being produced, we probably should add it. I don't think we need to waste CI (and local bootstrap for that matter) time building compass-web completely, but definitely looks like we'd need types built
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||||||||
| "compile": "npm run webpack -- --mode production", | ||||||||
| "webpack": "webpack-compass", | ||||||||
| "postcompile": "npm run typescript", | ||||||||
| "typescript": "tsc -p tsconfig-build.json --emitDeclarationOnly", | ||||||||
| "posttypescript": "npm run api-extractor", | ||||||||
| "api-extractor": "api-extractor run --local", | ||||||||
| "postapi-extractor": "node scripts/clean-dts.mjs", | ||||||||
| "test-types": "cd test/types && npm install && npm test", | ||||||||
| "prestart": "npm run compile -w @mongodb-js/webpack-config-compass", | ||||||||
| "start": "electron ./scripts/electron-proxy.js", | ||||||||
| "analyze": "npm run webpack -- --mode production --analyze", | ||||||||
|
|
@@ -52,6 +56,7 @@ | |||||||
| "depcheck": "depcheck", | ||||||||
| "check": "npm run typecheck && npm run lint && npm run depcheck", | ||||||||
| "check-ci": "npm run check", | ||||||||
| "pretest": "npm run test-types", | ||||||||
| "test": "mocha", | ||||||||
| "test-cov": "nyc --compact=false --produce-source-map=false -x \"**/*.spec.*\" --reporter=lcov --reporter=text --reporter=html npm run test", | ||||||||
| "test-watch": "npm run test -- --watch", | ||||||||
|
|
@@ -63,6 +68,7 @@ | |||||||
| "react-dom": "^17.0.2" | ||||||||
| }, | ||||||||
| "devDependencies": { | ||||||||
| "@microsoft/api-extractor": "^7.52.11", | ||||||||
| "@mongodb-js/atlas-service": "^0.56.0", | ||||||||
| "@mongodb-js/compass-aggregations": "^9.73.0", | ||||||||
| "@mongodb-js/compass-app-registry": "^9.4.20", | ||||||||
|
|
@@ -130,6 +136,7 @@ | |||||||
| "readable-stream": "^4.5.0", | ||||||||
| "sinon": "^17.0.1", | ||||||||
| "timers-browserify": "^2.0.12", | ||||||||
| "tsd": "^0.33.0", | ||||||||
| "util": "^0.12.5", | ||||||||
| "vm-browserify": "^1.1.2", | ||||||||
| "whatwg-url": "^13.0.0", | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import fs from 'node:fs/promises'; | ||
| import path from 'node:path'; | ||
|
|
||
| const distDir = path.join(import.meta.dirname, '..', 'dist'); | ||
|
|
||
| await Promise.all( | ||
| ( | ||
| await fs.readdir(distDir) | ||
| ) | ||
| .filter((file) => file.endsWith('.d.ts') || file.endsWith('.d.ts.map')) | ||
| .filter((file) => file !== 'compass-web.d.ts') | ||
| .map((file) => fs.unlink(path.join(distDir, file))) | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,14 @@ | ||
| export { CompassWeb } from './entrypoint'; | ||
| export type { CompassWebProps, TrackFunction } from './entrypoint'; | ||
| export * from './url-builder'; | ||
| export type { | ||
| OpenWorkspaceOptions, | ||
| WorkspaceTab, | ||
| } from '@mongodb-js/compass-workspaces'; | ||
|
|
||
| export { CompassExperimentationProvider } from '@mongodb-js/compass-telemetry'; | ||
|
|
||
| export type { CollectionTabInfo } from '@mongodb-js/compass-workspaces'; | ||
| export type { AllPreferences } from 'compass-preferences-model/provider'; | ||
| export type { AtlasClusterMetadata } from '@mongodb-js/connection-info'; | ||
| export type { LogFunction, LogMessage, DebugFunction } from './logger'; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { expectError } from 'tsd'; | ||
| import { CompassWeb } from '@mongodb-js/compass-web'; | ||
|
|
||
| // Test basic props structure | ||
| const basicProps = { | ||
| orgId: 'test-org', | ||
| projectId: 'test-project', | ||
| onActiveWorkspaceTabChange: () => {}, | ||
| onFailToLoadConnections: () => {}, | ||
| }; | ||
|
|
||
| // Test that the component can be called with basic props | ||
| void CompassWeb(basicProps); | ||
|
|
||
| // Test preference property validation | ||
| // This should work - optInGenAIFeatures is the correct external property name | ||
| void CompassWeb({ | ||
| ...basicProps, | ||
| initialPreferences: { | ||
| optInGenAIFeatures: true, | ||
| }, | ||
| }); | ||
|
|
||
| // This should cause an error - optInDataExplorerGenAIFeatures is an old name | ||
| expectError( | ||
| CompassWeb({ | ||
| ...basicProps, | ||
| initialPreferences: { | ||
| optInDataExplorerGenAIFeatures: true, | ||
| }, | ||
| }) | ||
| ); |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| { | ||
| "name": "@mongodb-js/compass-web-types-test", | ||
| "version": "1.0.0", | ||
| "private": true, | ||
| "description": "Test package to verify compass-web types work correctly for external consumers", | ||
| "scripts": { | ||
| "test": "tsd --typings ./node_modules/@mongodb-js/compass-web/dist/compass-web.d.ts --files ./*.test-d.ts" | ||
| }, | ||
| "dependencies": { | ||
| "@mongodb-js/compass-web": "file:../../", | ||
| "react": "^17.0.2", | ||
| "react-dom": "^17.0.2" | ||
| }, | ||
| "devDependencies": { | ||
| "@types/react": "^17.0.2", | ||
| "@types/react-dom": "^17.0.2", | ||
| "tsd": "^0.31.0", | ||
| "typescript": "^5.0.0" | ||
| } | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| { | ||
| "compilerOptions": { | ||
| "target": "ES2020", | ||
| "lib": ["ES2020", "DOM"], | ||
| "module": "commonjs", | ||
| "moduleResolution": "node", | ||
| "strict": true, | ||
| "esModuleInterop": true, | ||
| "skipLibCheck": true, | ||
| "forceConsistentCasingInFileNames": true, | ||
| "declaration": false, | ||
| "noEmit": true, | ||
| "typeRoots": ["./node_modules/@types"] | ||
| }, | ||
| "include": ["**/*.test-d.ts"] | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: I think not providing a value at all basically has the same effect
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea an old version of api-extractor required this exist, anyway, gone!