diff --git a/.changeset/afraid-phones-sip.md b/.changeset/afraid-phones-sip.md new file mode 100644 index 000000000000..d256fd88e414 --- /dev/null +++ b/.changeset/afraid-phones-sip.md @@ -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 diff --git a/packages/core/rollup.config.js b/packages/core/rollup.config.js index 736c63fe7c0d..72daa9e4fc6b 100644 --- a/packages/core/rollup.config.js +++ b/packages/core/rollup.config.js @@ -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__/**'], diff --git a/packages/endpoint/rollup.config.js b/packages/endpoint/rollup.config.js index 5319f121d4f0..61c1f25f7e54 100644 --- a/packages/endpoint/rollup.config.js +++ b/packages/endpoint/rollup.config.js @@ -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__/**'], diff --git a/packages/graphql/rollup.config.js b/packages/graphql/rollup.config.js index 7d1a5f54f012..c9f7a4562e5c 100644 --- a/packages/graphql/rollup.config.js +++ b/packages/graphql/rollup.config.js @@ -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__/**'], diff --git a/packages/hooks/rollup.config.js b/packages/hooks/rollup.config.js index 911f559c4313..0d32a8914797 100644 --- a/packages/hooks/rollup.config.js +++ b/packages/hooks/rollup.config.js @@ -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]; @@ -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__/**'], diff --git a/packages/img/rollup.config.js b/packages/img/rollup.config.js index 057c0a49a996..bcccc262f572 100644 --- a/packages/img/rollup.config.js +++ b/packages/img/rollup.config.js @@ -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]; @@ -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__/**'], diff --git a/packages/normalizr/rollup.config.js b/packages/normalizr/rollup.config.js index 39d19bfe383b..084605ed820e 100644 --- a/packages/normalizr/rollup.config.js +++ b/packages/normalizr/rollup.config.js @@ -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'; diff --git a/packages/react/rollup.config.js b/packages/react/rollup.config.js index fbe89202c8e9..9b226aeb9033 100644 --- a/packages/react/rollup.config.js +++ b/packages/react/rollup.config.js @@ -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]; @@ -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, }, ], diff --git a/packages/redux/rollup.config.js b/packages/redux/rollup.config.js index 6e3ce08560db..08c6e4903b51 100644 --- a/packages/redux/rollup.config.js +++ b/packages/redux/rollup.config.js @@ -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]; @@ -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__/**'], diff --git a/packages/rest/rollup.config.js b/packages/rest/rollup.config.js index db2cfc0c8c0b..346219a967ae 100644 --- a/packages/rest/rollup.config.js +++ b/packages/rest/rollup.config.js @@ -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__/**'], diff --git a/packages/ssr/rollup.config.js b/packages/ssr/rollup.config.js index ed0dae23f2fd..5439672e9a6d 100644 --- a/packages/ssr/rollup.config.js +++ b/packages/ssr/rollup.config.js @@ -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]; @@ -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__/**'], diff --git a/packages/use-enhanced-reducer/rollup.config.js b/packages/use-enhanced-reducer/rollup.config.js index 059e4aa7ea05..8d2c316b8a97 100644 --- a/packages/use-enhanced-reducer/rollup.config.js +++ b/packages/use-enhanced-reducer/rollup.config.js @@ -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__/**'],