Skip to content

Commit

Permalink
Update buildchain to use rollup in order to improve esm support
Browse files Browse the repository at this point in the history
The library exported an esm version, however it didn't work
with all esm tools becase some require "type": "module" to be
set, or the files to end in ".mjs". By moving over to rollup,
we can output the esm files with the ".mjs" extension which
makes this library work with vite.

This change is based on the approach which Chat decided on:
yext/chat-ui-react#38

J=BACK-2527
TEST=manual

Manually ran the test site locally and confirmed the requests
still fire correctly. I still need to test this with vite.
  • Loading branch information
cea2aj committed Sep 12, 2023
1 parent f9371f1 commit cbcd4ac
Show file tree
Hide file tree
Showing 4 changed files with 328 additions and 16 deletions.
281 changes: 275 additions & 6 deletions package-lock.json

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

15 changes: 8 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "2.4.0",
"description": "Typescript Networking Library for the Yext Search API",
"main": "./dist/commonjs/src/index.js",
"module": "./dist/esm/src/index.js",
"module": "./dist/esm/src/index.mjs",
"types": "./dist/bundle.d.ts",
"sideEffects": false,
"keywords": [
Expand All @@ -30,13 +30,11 @@
"scripts": {
"test": "npm run lint && jest",
"lint": "eslint . --max-warnings=0",
"tsc-cjs": "tsc -p tsconfig.cjs.json",
"tsc-esm": "tsc -p tsconfig.esm.json",
"tsc": "npm run tsc-cjs && npm run tsc-esm",
"build-legacy-bundle": "npx webpack",
"build": "rm -rf dist/** && npm run tsc && npm run build-legacy-bundle && npm run api-extractor && npm run generate-docs",
"build-ci": "npm run tsc-cjs && npm run api-extractor && npm run generate-docs",
"dev": "npm run tsc-esm -- --watch",
"build:js": "rollup --config rollup.config.mjs",
"build": "rm -rf dist/** && npm run build:js && npm run build-legacy-bundle && npm run api-extractor && npm run generate-docs",
"build-ci": "npm run build:js && npm run api-extractor && npm run generate-docs",
"dev": "npm run build:js -- --watch",
"prepublishOnly": "npm run build",
"api-extractor": "api-extractor run --local --verbose",
"generate-docs": "api-documenter markdown --input-folder temp --output-folder docs && rm -rf temp && npm run generate-notices",
Expand All @@ -59,6 +57,7 @@
"@babel/preset-typescript": "^7.12.1",
"@microsoft/api-documenter": "^7.13.76",
"@microsoft/api-extractor": "^7.19.2",
"@rollup/plugin-json": "^6.0.0",
"@types/jest": "^28.1.1",
"@typescript-eslint/eslint-plugin": "^5.16.0",
"@typescript-eslint/parser": "^5.16.0",
Expand All @@ -72,6 +71,8 @@
"generate-license-file": "^1.3.0",
"jest": "^28.1.0",
"jest-environment-jsdom": "^28.1.0",
"rollup": "^3.29.1",
"rollup-plugin-typescript2": "^0.35.0",
"ts-loader": "^8.4.0",
"typescript": "^4.0.3",
"webpack": "^5.73.0",
Expand Down
Loading

0 comments on commit cbcd4ac

Please sign in to comment.