-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Migrate from tsc to rollup for the build process (#23)
this PR migrates the build chain from tsc to rollup, as part of the changes discovered in the investigation from this [PR](yext/chat-ui-react#38): in short, using rollup, the esm path files now include `.mjs` extensions and we no longer need `"type": "module"` in our package.json. J=CLIP-556 TEST=manual see that all unit tests and the the two test repo, node-cjs, and brower-esm, still works as expected published an alpha version `[0.7.0-alpha.23](https://www.npmjs.com/package/@yext/chat-core/v/0.7.0-alpha.23)`, and see that it still works as expected in vite/pagesjs and sonic/alpha. Will publish v0.7.0 once merged
- Loading branch information
Showing
12 changed files
with
200 additions
and
33 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* \@rollup/plugin-typescript had issue with "export type": | ||
* [!] RollupError: Unexpected token (Note that you need plugins to import files that are not JavaScript) | ||
* Switched over to a fork rollup-plugin-typescript2 resolved the issue. | ||
*/ | ||
import typescript from "rollup-plugin-typescript2"; | ||
import { defineConfig } from "rollup"; | ||
|
||
export default defineConfig({ | ||
input: "src/index.ts", | ||
output: [ | ||
{ | ||
dir: "./dist/esm", | ||
/** | ||
* use mjs extension so NodeJS will recognize the bundle as ES modules | ||
* https://nodejs.org/api/packages.html#determining-module-system | ||
*/ | ||
entryFileNames: "[name].mjs", | ||
format: "esm", | ||
/** preserve original module files instead of compressing all to one file */ | ||
preserveModules: true, | ||
sourcemap: true, | ||
/** | ||
* set to "auto" to follow TypeScript's esModuleInterop behavior to ensures compatibility | ||
* of default, namespace, and dynamic imports from external deps (e.g. react-textarea-autosize). | ||
*/ | ||
interop: "auto", | ||
}, | ||
{ | ||
dir: "./dist/commonjs", | ||
format: "cjs", | ||
preserveModules: true, | ||
sourcemap: true, | ||
interop: "auto", | ||
}, | ||
], | ||
plugins: [ | ||
typescript({ | ||
tsconfig: "./tsconfig.json", | ||
}), | ||
], | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.