Skip to content

Commit

Permalink
fix: unpkg bundle holds everything needed and refers to peers correct…
Browse files Browse the repository at this point in the history
…ly (#2818)
  • Loading branch information
ntucker authored Sep 18, 2023
1 parent 8c14e04 commit fc00928
Show file tree
Hide file tree
Showing 12 changed files with 82 additions and 19 deletions.
28 changes: 28 additions & 0 deletions .changeset/afraid-phones-sip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
'@data-client/use-enhanced-reducer': patch
'@data-client/normalizr': patch
'@data-client/endpoint': patch
'@data-client/graphql': patch
'@data-client/hooks': patch
'@data-client/react': patch
'@data-client/redux': patch
'@data-client/core': patch
'@data-client/rest': patch
'@data-client/img': patch
'@data-client/ssr': patch
---

Fix unpkg bundles and update names

- Client packages namespace into RDC
- @data-client/react - RDC
- @data-client/core - RDC.Core
- @data-client/redux - RDC.Redux
- Definition packages namespace top level
- @data-client/rest - Rest
- @data-client/graphql - GraphQL
- @data-client/img - Img
- @data-client/endpoint - Endpoint
- Utility
- @data-client/normalizr - normalizr
- @data-client/use-enhanced-reducer - EnhancedReducer
2 changes: 1 addition & 1 deletion packages/core/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientCore' }],
output: [{ file: pkg.unpkg, format: 'umd', name: 'RDC.Core' }],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
2 changes: 1 addition & 1 deletion packages/endpoint/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientEndpoint' }],
output: [{ file: pkg.unpkg, format: 'umd', name: 'Endpoint' }],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
3 changes: 1 addition & 2 deletions packages/graphql/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
// browser-friendly UMD build
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientRest' }],
output: [{ file: pkg.unpkg, format: 'umd', name: 'GraphQL' }],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
5 changes: 3 additions & 2 deletions packages/hooks/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import pkg from './package.json';
const dependencies = Object.keys(pkg.dependencies)
.concat(Object.keys(pkg.peerDependencies))
.filter(dep => !['@babel/runtime'].includes(dep));
const peers = Object.keys(pkg.peerDependencies);

const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node'];
const nativeExtensions = ['.native.ts', ...extensions];
Expand All @@ -32,8 +33,8 @@ export default [
// browser-friendly UMD build
{
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientHooks' }],
external: id => peers.some(dep => dep === id || id.startsWith(dep)),
output: [{ file: pkg.unpkg, format: 'umd', name: 'RDC.Hooks' }],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
14 changes: 12 additions & 2 deletions packages/img/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import pkg from './package.json';
const dependencies = Object.keys(pkg.dependencies)
.concat(Object.keys(pkg.peerDependencies))
.filter(dep => !['@babel/runtime'].includes(dep));
const peers = Object.keys(pkg.peerDependencies);

const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node'];
const nativeExtensions = ['.native.ts', ...extensions];
Expand All @@ -25,8 +26,17 @@ export default [
// browser-friendly UMD build
{
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientImg' }],
external: id => peers.some(dep => dep === id || id.startsWith(dep)),
output: [
{
file: pkg.unpkg,
format: 'umd',
name: 'Img',
globals: {
'@data-client/react': 'RDC',
},
},
],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
4 changes: 2 additions & 2 deletions packages/normalizr/rollup.config.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import babel from 'rollup-plugin-babel';
import commonjs from 'rollup-plugin-commonjs';
import dts from 'rollup-plugin-dts';
import filesize from 'rollup-plugin-filesize';
import resolve from 'rollup-plugin-node-resolve';
import { terser } from 'rollup-plugin-terser';
import dts from 'rollup-plugin-dts';

import { name } from './package.json';
const name = 'normalizr';

const isProduction = process.env.NODE_ENV === 'production';

Expand Down
5 changes: 3 additions & 2 deletions packages/react/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const dependencies = Object.keys(pkg.dependencies)
dep =>
!['@data-client/use-enhanced-reducer', '@babel/runtime'].includes(dep),
);
const peers = Object.keys(pkg.peerDependencies);

const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node', '.jsx'];
const nativeExtensions = ['.native.ts', ...extensions];
Expand All @@ -29,12 +30,12 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
// browser-friendly UMD build
configs.push({
input: 'lib/index.js',
external: isExternal,
external: id => peers.some(dep => dep === id || id.startsWith(dep)),
output: [
{
file: pkg.unpkg,
format: 'umd',
name: 'dataClientCore',
name: 'RDC',
inlineDynamicImports: true,
},
],
Expand Down
16 changes: 14 additions & 2 deletions packages/redux/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { typeConfig } from '../../scripts/rollup-utils';
const dependencies = Object.keys(pkg.dependencies)
.concat(Object.keys(pkg.peerDependencies))
.filter(dep => !['@babel/runtime'].includes(dep));
const peers = Object.keys(pkg.peerDependencies);

const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node', '.jsx'];
const nativeExtensions = ['.native.ts', ...extensions];
Expand All @@ -26,8 +27,19 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
// browser-friendly UMD build
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientCore' }],
external: id => peers.some(dep => dep === id || id.startsWith(dep)),
output: [
{
file: pkg.unpkg,
format: 'umd',
name: 'RDC.Redux',
globals: {
'@data-client/react': 'RDC',
redux: 'Redux',
react: 'React',
},
},
],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
3 changes: 1 addition & 2 deletions packages/rest/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
// browser-friendly UMD build
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientRest' }],
output: [{ file: pkg.unpkg, format: 'umd', name: 'Rest' }],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
17 changes: 15 additions & 2 deletions packages/ssr/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const dependencies = Object.keys(pkg.dependencies)
.concat(Object.keys(pkg.peerDependencies))
.concat(['@data-client/core', 'data-client'])
.filter(dep => !['@babel/runtime'].includes(dep));
const peers = Object.keys(pkg.peerDependencies);

const extensions = ['.js', '.ts', '.tsx', '.mjs', '.json', '.node'];
const nativeExtensions = ['.native.ts', ...extensions];
Expand All @@ -25,8 +26,20 @@ if (process.env.BROWSERSLIST_ENV !== 'node12') {
// browser-friendly UMD build
configs.push({
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClientRest' }],
external: id => peers.some(dep => dep === id || id.startsWith(dep)),
output: [
{
file: pkg.unpkg,
format: 'umd',
name: 'RDC.SSR',
globals: {
'@data-client/react': 'RDC',
'@data-client/redux': 'RDC.Redux',
redux: 'Redux',
react: 'React',
},
},
],
plugins: [
babel({
exclude: ['node_modules/**', '/**__tests__/**'],
Expand Down
2 changes: 1 addition & 1 deletion packages/use-enhanced-reducer/rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ export default [
{
input: 'lib/index.js',
external: isExternal,
output: [{ file: pkg.unpkg, format: 'umd', name: 'dataClient' }],
output: [{ file: pkg.unpkg, format: 'umd', name: 'EnhancedReducer' }],
plugins: [
babel({
exclude: ['node_modules/**', '**/__tests__/**'],
Expand Down

0 comments on commit fc00928

Please sign in to comment.