Skip to content
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

feat: automatically import and define Calcite Components when importing their React wrapper #7185

Merged
merged 13 commits into from
Jun 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions packages/calcite-components-react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"description": "A set of React components that wrap calcite components",
"license": "SEE LICENSE.md",
"scripts": {
"build": "rimraf dist && npm run compile",
"build": "rimraf dist && npm run util:patch-jsx-import && npm run compile",
"clean": "rimraf dist node_modules .turbo",
"compile": "npm run tsc",
"tsc": "tsc"
"tsc": "tsc",
"util:patch-jsx-import": "ts-node --esm ./support/patchImportPathJSX.ts"
},
"main": "./dist/index.js",
"module": "./dist/index.js",
Expand Down
22 changes: 22 additions & 0 deletions packages/calcite-components-react/support/patchImportPathJSX.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// patch needed due to Stencil creating the wrong import path to the JSX type
(async function () {
const {
promises: { readFile, writeFile }
} = await import("fs");
const { resolve } = await import("path");

try {
const filePath = resolve(__dirname, "..", "src", "components.ts");
const contents = await readFile(filePath, { encoding: "utf8" });
await writeFile(
filePath,
contents.replace(
"import type { JSX } from '@esri/calcite-components/dist/components'",
"import type { JSX } from '@esri/calcite-components'"
)
);
} catch (err) {
console.error(err);
process.exit(1);
}
})();
2 changes: 1 addition & 1 deletion packages/calcite-components-react/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"experimentalDecorators": true,
"esModuleInterop": true,
"lib": ["dom", "es2015"],
"module": "es2015",
"module": "esnext",
"moduleResolution": "node",
"noImplicitAny": true,
"noImplicitReturns": true,
Expand Down
2 changes: 1 addition & 1 deletion packages/calcite-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
"@esri/eslint-plugin-calcite-components": "0.2.2",
"@stencil-community/eslint-plugin": "0.5.0",
"@stencil/postcss": "2.1.0",
"@stencil/react-output-target": "0.4.0",
"@stencil/react-output-target": "0.5.3",
"@stencil/sass": "3.0.4",
"@stencil/state-tunnel": "1.0.1"
},
Expand Down
4 changes: 3 additions & 1 deletion packages/calcite-components/stencil.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,9 @@ export const create: () => Config = () => ({
reactOutputTarget({
componentCorePackage: "@esri/calcite-components",
proxiesFile: "../calcite-components-react/src/components.ts",
excludeComponents: ["context-consumer"]
excludeComponents: ["context-consumer"],
customElementsDir: "dist/components",
includeImportCustomElements: true
}),
{ type: "dist-hydrate-script" },
{ type: "dist-custom-elements", autoDefineCustomElements: true },
Expand Down