Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Commit

Permalink
fix: include regenerator-runtime for UMD bundle (#13)
Browse files Browse the repository at this point in the history
* fix: include regenerator-runtime for UMD bundle

* delete umd entry point artifact

* add preset env to esm bundle for optional chaining

* Add bundlephobia badge
  • Loading branch information
ricokahler authored Dec 2, 2020
1 parent e3f6508 commit b49b0f0
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Sanity Codegen ✨ · [![codecov](https://codecov.io/gh/ricokahler/sanity-codegen/branch/main/graph/badge.svg?token=tsUGZsR5QG)](https://codecov.io/gh/ricokahler/sanity-codegen) [![github status checks](https://badgen.net/github/checks/ricokahler/sanity-codegen/main)](https://github.com/ricokahler/sanity-codegen/actions)
# Sanity Codegen ✨ · [![codecov](https://codecov.io/gh/ricokahler/sanity-codegen/branch/main/graph/badge.svg?token=tsUGZsR5QG)](https://codecov.io/gh/ricokahler/sanity-codegen) [![github status checks](https://badgen.net/github/checks/ricokahler/sanity-codegen/main)](https://github.com/ricokahler/sanity-codegen/actions) [![bundlephobia](https://badgen.net/bundlephobia/minzip/sanity-codegen)](https://bundlephobia.com/result?p=sanity-codegen)

> Generate TypeScript types from your Sanity schemas
Expand Down
5 changes: 2 additions & 3 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 package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "sanity-codegen",
"version": "0.2.0",
"version": "0.2.2",
"private": true,
"description": "",
"repository": {
Expand All @@ -24,7 +24,8 @@
"@babel/plugin-transform-runtime": "^7.12.1",
"@babel/register": "^7.12.1",
"@types/prettier": "^2.1.5",
"babel-plugin-module-resolver": "^4.0.0"
"babel-plugin-module-resolver": "^4.0.0",
"regenerator-runtime": "^0.13.7"
},
"devDependencies": {
"@babel/cli": "^7.12.8",
Expand Down
8 changes: 6 additions & 2 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@ export default [
resolve({ extensions, modulesOnly: true }),
babel({
babelrc: false,
presets: ['@babel/preset-typescript'],
presets: [
['@babel/preset-env', { targets: 'node 10 and not IE 11' }],
'@babel/preset-typescript',
],
plugins: ['@babel/plugin-transform-runtime'],
babelHelpers: 'runtime',
extensions,
Expand All @@ -24,7 +27,7 @@ export default [
external: [/^@babel\/runtime/],
},
{
input: './src/index.ts',
input: './src/index.umd.ts',
output: {
file: './dist/index.js',
format: 'umd',
Expand All @@ -40,5 +43,6 @@ export default [
extensions,
}),
],
external: ['regenerator-runtime/runtime'],
},
];
2 changes: 2 additions & 0 deletions scripts/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ async function build() {

console.log('Compiling types…');
await exec('npx tsc');
await exec('rm ./dist/index.umd.d.ts');

console.log('Compiling Non-Client JS…');
await exec(
'npx babel -x .ts,.js --ignore /**/*.test.ts,/**/*.d.ts ./src --out-dir ./dist'
);
await exec('rm ./dist/index.umd.js');

console.log('Compiling Client JS…');
await exec('npx rollup -c');
Expand Down
4 changes: 4 additions & 0 deletions src/index.umd.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// entry point for the umd bundle that includes the regenerator-runtime
import 'regenerator-runtime/runtime';
export * from './types';
export * from './client';

0 comments on commit b49b0f0

Please sign in to comment.