Skip to content

Commit

Permalink
feat: remove umd
Browse files Browse the repository at this point in the history
  • Loading branch information
myandrienko committed Jun 11, 2024
1 parent 68b6bba commit 12f97d6
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 51 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,6 @@
"@commitlint/config-conventional": "^18.4.3",
"@emoji-mart/data": "^1.1.2",
"@emoji-mart/react": "^1.1.1",
"@fal-works/esbuild-plugin-global-externals": "^2.1.2",
"@ladle/react": "^0.16.0",
"@playwright/test": "^1.42.1",
"@semantic-release/changelog": "^6.0.2",
Expand Down Expand Up @@ -247,5 +246,6 @@
">0.2%",
"not ie <= 11",
"not op_mini all"
]
],
"packageManager": "[email protected]+sha1.1959a18351b811cdeedbd484a8f86c3cc3bbaf72"
}
45 changes: 1 addition & 44 deletions scripts/bundle.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,12 @@
import { dirname, resolve } from 'node:path';
import { fileURLToPath } from 'node:url';
import * as esbuild from 'esbuild';
import { globalExternals } from '@fal-works/esbuild-plugin-global-externals';

// import.meta.dirname is not available before Node 20
const __dirname = dirname(fileURLToPath(import.meta.url));

const sdkEntrypoint = resolve(__dirname, '../src/index.ts');
const emojiEntrypoint = resolve(__dirname, '../src/components/Emojis/index.ts');
const browserBundleEntrypoint = resolve(__dirname, '../src/index_UMD.ts');
const outDir = resolve(__dirname, '../dist');

// Those dependencies are distributed as ES modules, and cannot be externalized
Expand Down Expand Up @@ -44,45 +42,4 @@ const cjsBundleConfig = {
sourcemap: 'linked',
};

const browserBundleConfig = {
entryPoints: [browserBundleEntrypoint],
bundle: true,
format: 'iife',
target: 'es2020',
external: ['react', 'react-dom', 'stream-chat', '@emoji-mart'],
plugins: [
globalExternals({
react: {
varName: 'React',
type: 'cjs',
},
'react/jsx-runtime': {
varName: 'React',
type: 'cjs',
},
'react-dom': {
varName: 'ReactDOM',
type: 'cjs',
},
'stream-chat': {
varName: 'StreamChat',
type: 'cjs',
},
}),
],
globalName: 'StreamChatReact',
outfile: resolve(outDir, 'browser.full-bundle.js'),
sourcemap: 'linked',
};

const browserBundleMinConfig = {
...browserBundleConfig,
minify: true,
outfile: resolve(outDir, 'browser.full-bundle.min.js'),
};

await Promise.all([
esbuild.build(cjsBundleConfig),
esbuild.build(browserBundleConfig),
esbuild.build(browserBundleMinConfig),
]);
await esbuild.build(cjsBundleConfig);
5 changes: 0 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1564,11 +1564,6 @@
minimatch "^3.0.4"
strip-json-comments "^3.1.1"

"@fal-works/esbuild-plugin-global-externals@^2.1.2":
version "2.1.2"
resolved "https://registry.yarnpkg.com/@fal-works/esbuild-plugin-global-externals/-/esbuild-plugin-global-externals-2.1.2.tgz#c05ed35ad82df8e6ac616c68b92c2282bd083ba4"
integrity sha512-cEee/Z+I12mZcFJshKcCqC8tuX5hG3s+d+9nZ3LabqKF1vKdF41B92pJVCBggjAGORAeOzyyDDKrZwIkLffeOQ==

"@gar/promisify@^1.1.3":
version "1.1.3"
resolved "https://registry.yarnpkg.com/@gar/promisify/-/promisify-1.1.3.tgz#555193ab2e3bb3b6adc3d551c9c030d9e860daf6"
Expand Down

0 comments on commit 12f97d6

Please sign in to comment.