Skip to content

Commit

Permalink
Expose react CJS module
Browse files Browse the repository at this point in the history
  • Loading branch information
jackocnr committed Apr 10, 2024
1 parent 1503f64 commit 156ca7e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@
"./data": "./build/js/data.js",
"./react": {
"types": "./react/build/IntlTelInput.d.ts",
"require": "./react/build/IntlTelInput.cjs",
"default": "./react/build/IntlTelInput.js"
},
"./*": "./*"
Expand Down
17 changes: 15 additions & 2 deletions react/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,30 +3,43 @@
const { build } = require("esbuild");
const packageJson = require("../package.json");

build({
const mainShared = {
bundle: true,
entryPoints: ["react/src/intl-tel-input/react.tsx"],
external: ["react", "react-dom", "prop-types"],
logLevel: "info",
minify: true,
define: { "process.env.VERSION": `"${packageJson.version}"` },
};

//* React Component - CommonJS
build({
...mainShared,
format: "cjs",
outfile: "react/build/IntlTelInput.cjs",
});

//* React Component - Default (ES Modules)
build({
...mainShared,
format: "esm",
outfile: "react/build/IntlTelInput.js",
});

//* Demo Files
const demoShared = {
bundle: true,
define: { "process.env.VERSION": `"${packageJson.version}"` },
format: "iife",
};

//* Simple demo app
build({
...demoShared,
entryPoints: ["react/demo/SimpleApp.tsx"],
outfile: "react/demo/simple-bundle.js",
});

//* Validation demo app
build({
...demoShared,
entryPoints: ["react/demo/ValidationApp.tsx"],
Expand Down
Loading

0 comments on commit 156ca7e

Please sign in to comment.