Skip to content
This repository has been archived by the owner on Jul 27, 2022. It is now read-only.

fix: correct UMD format #70

Merged
merged 1 commit into from
Nov 8, 2020
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
5 changes: 5 additions & 0 deletions .changeset/happy-singers-allow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"react-cool-form": patch
---

fix: correct UMD format
3 changes: 3 additions & 0 deletions rollup/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import createConfig from "./createConfig";

const isDev = process.env.BUILD !== "production";
const name = "index";
const umdName = "ReactCoolForm";
const options = [
{
name,
Expand All @@ -19,11 +20,13 @@ const options = [
},
{
name,
umdName,
format: "umd",
env: "development",
},
{
name,
umdName,
format: "umd",
env: "production",
},
Expand Down
10 changes: 7 additions & 3 deletions rollup/createConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ const makeExternalPredicate = (external) =>
? () => false
: (id) => new RegExp(`^(${external.join("|")})($|/)`).test(id);

export default ({ name, format, env, size }) => {
export default ({ name, umdName, format, env, size }) => {
const extensions = [".ts"];
const isUmd = format === "umd";
const isProd = env === "production";
Expand All @@ -31,7 +31,7 @@ export default ({ name, format, env, size }) => {
output: {
file: `dist/${fileName}`,
format,
name: pkg.name,
name: umdName,
sourcemap: true,
globals: { react: "React" },
exports: "named",
Expand All @@ -44,7 +44,11 @@ export default ({ name, format, env, size }) => {
plugins: [
[
"@babel/plugin-transform-runtime",
{ version: babelRuntimeVersion, helpers: !isUmd },
{
version: babelRuntimeVersion,
useESModules: format !== "cjs",
helpers: !isUmd,
},
],
],
babelHelpers: isUmd ? "bundled" : "runtime",
Expand Down