diff --git a/.changeset/nice-ladybugs-carry.md b/.changeset/nice-ladybugs-carry.md new file mode 100644 index 00000000000..b77d11e75de --- /dev/null +++ b/.changeset/nice-ladybugs-carry.md @@ -0,0 +1,10 @@ +--- +"@talend/scripts-config-react-webpack": major +--- + +feat(script): remove cdn option. + +You must review your build process with that new plugin as many things will not work. +Especially the @talend/assets-api call you may end up with weird behavior. + +The good part is once you have fixed it moving out from @talend/scripts* to an other build tool like vite becomes easy. diff --git a/.changeset/tired-donkeys-add.md b/.changeset/tired-donkeys-add.md new file mode 100644 index 00000000000..cbd7f77d1cd --- /dev/null +++ b/.changeset/tired-donkeys-add.md @@ -0,0 +1,30 @@ +--- +'@talend/react-faceted-search-query-client': major +'@talend/scripts-config-react-webpack': major +'@talend/scripts-config-storybook-lib': major +'@talend/json-schema-form-core': major +'@talend/react-faceted-search': major +'@talend/storybook-docs': major +'@talend/design-system': major +'@talend/design-tokens': major +'@talend/react-flow-designer': major +'@talend/router-bridge': major +'@talend/ui-storybook-one': major +'@talend/react-bootstrap': major +'@talend/design-docs': major +'@talend/assets-api': major +'@talend/react-cmf-router': major +'@talend/react-components': major +'@talend/react-containers': major +'@talend/ui-playground': major +'@talend/react-cmf-cqrs': major +'@talend/react-dataviz': major +'@talend/react-stepper': major +'@talend/react-forms': major +'@talend/react-sagas': major +'@talend/bootstrap-theme': major +'@talend/http': major +'@talend/react-cmf': major +--- + +chore: drop UMD format diff --git a/fork/json-schema-form-core/package.json b/fork/json-schema-form-core/package.json index a554e488ff0..64e86325684 100644 --- a/fork/json-schema-form-core/package.json +++ b/fork/json-schema-form-core/package.json @@ -7,11 +7,11 @@ "exports": { ".": { "import": "./lib-esm/index.js", - "require": "./dist/index.js" + "require": "./lib/index.js" } }, "scripts": { - "build:lib": "rimraf dist && talend-scripts build --umd", + "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "watch": "webpack --watch", "dist-untested": "webpack --config webpack.config.dist.js", diff --git a/fork/react-bootstrap/package.json b/fork/react-bootstrap/package.json index 1c382b6f9fa..308c560a669 100644 --- a/fork/react-bootstrap/package.json +++ b/fork/react-bootstrap/package.json @@ -17,10 +17,7 @@ } }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", "build:lib:esm": "talend-scripts build --esm", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "lint": "talend-scripts lint", "test": "talend-scripts test", diff --git a/packages/assets-api/package.json b/packages/assets-api/package.json index 31cfb25c00f..b0ea2f0b45a 100644 --- a/packages/assets-api/package.json +++ b/packages/assets-api/package.json @@ -12,7 +12,6 @@ }, "license": "Apache-2.0", "scripts": { - "pre-release": "talend-scripts build --umd && talend-scripts build --umd --dev", "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", diff --git a/packages/assets-api/src/index.test.ts b/packages/assets-api/src/index.test.ts index def049485c0..c3ce7a2e58e 100644 --- a/packages/assets-api/src/index.test.ts +++ b/packages/assets-api/src/index.test.ts @@ -10,9 +10,9 @@ describe('assets-api', () => { jest.restoreAllMocks(); }); - it('should return unpkg url', () => { + it('should return static url', () => { const url = assetsApi.getURL(bundlePath, '@talend/icons', '6.60.1'); - expect(url).toBe(`https://unpkg.com/@talend/icons@6.60.1${bundlePath}`); + expect(url).toBe(`https://statics.cloud.talend.com/@talend/icons/6.60.1${bundlePath}`); }); it('should return /cdn url', () => { diff --git a/packages/assets-api/src/index.ts b/packages/assets-api/src/index.ts index 1896d1594ea..5ee805577c4 100644 --- a/packages/assets-api/src/index.ts +++ b/packages/assets-api/src/index.ts @@ -191,7 +191,7 @@ if (!window.Talend.getCDNUrl) { } return `${CDN_URL}/${info.name}/${info.version}${info.path}`; } - return `https://unpkg.com/${info.name}@${info.version}${info.path}`; + return `https://statics.cloud.talend.com/${info.name}/${info.version}${info.path}`; }; } diff --git a/packages/cmf-cqrs/package.json b/packages/cmf-cqrs/package.json index 3cfbaf2ced5..01b8a6ed740 100644 --- a/packages/cmf-cqrs/package.json +++ b/packages/cmf-cqrs/package.json @@ -4,11 +4,19 @@ "main": "lib/index.js", "mainSrc": "src/index.ts", "types": "lib/index.d.ts", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", + "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", "test": "talend-scripts test", "test:watch": "talend-scripts test --watch", diff --git a/packages/cmf-router/package.json b/packages/cmf-router/package.json index 64c91faa4f1..8bb05090891 100644 --- a/packages/cmf-router/package.json +++ b/packages/cmf-router/package.json @@ -17,10 +17,7 @@ "author": "Talend Frontend (http://www.talend.com)", "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", "build:lib:esm": "talend-scripts build --esm", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "start": "echo nothing to start", "test": "talend-scripts test", diff --git a/packages/cmf/package.json b/packages/cmf/package.json index 627f0f58dc8..12e875a78f8 100644 --- a/packages/cmf/package.json +++ b/packages/cmf/package.json @@ -16,10 +16,7 @@ } }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", "build:lib:esm": "talend-scripts build --esm", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "start": "echo nothing to start", "test": "talend-scripts test", diff --git a/packages/components/package.json b/packages/components/package.json index cec1d0cfd2c..7562886eda7 100644 --- a/packages/components/package.json +++ b/packages/components/package.json @@ -15,9 +15,6 @@ }, "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build && yarn run tsc", "build:lib:esm": "talend-scripts build --esm", "watch": "talend-scripts build --watch", diff --git a/packages/components/src/DateTimePickers/DateRange/Picker/__snapshots__/Picker.component.test.js.snap b/packages/components/src/DateTimePickers/DateRange/Picker/__snapshots__/Picker.component.test.js.snap index 4dacabdbb93..83f5c265555 100644 --- a/packages/components/src/DateTimePickers/DateRange/Picker/__snapshots__/Picker.component.test.js.snap +++ b/packages/components/src/DateTimePickers/DateRange/Picker/__snapshots__/Picker.component.test.js.snap @@ -91,7 +91,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2022 + 2023
  • @@ -100,7 +100,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2023 + 2024
  • @@ -109,7 +109,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2024 + 2025
  • @@ -118,7 +118,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="0" type="button" > - 2025 + 2026
  • @@ -127,7 +127,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2026 + 2027
  • @@ -136,7 +136,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2027 + 2028
  • @@ -145,7 +145,7 @@ exports[`DateRange.Picker should render 1`] = ` tabindex="-1" type="button" > - 2028 + 2029
  • diff --git a/packages/components/src/DateTimePickers/views/DateView/__snapshots__/DateView.test.js.snap b/packages/components/src/DateTimePickers/views/DateView/__snapshots__/DateView.test.js.snap index 4ba1c09a97c..d146a715a84 100644 --- a/packages/components/src/DateTimePickers/views/DateView/__snapshots__/DateView.test.js.snap +++ b/packages/components/src/DateTimePickers/views/DateView/__snapshots__/DateView.test.js.snap @@ -109,7 +109,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2022 + 2023
  • @@ -118,7 +118,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2023 + 2024
  • @@ -127,7 +127,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2024 + 2025
  • @@ -136,7 +136,7 @@ exports[`DateView should render 1`] = ` tabindex="0" type="button" > - 2025 + 2026
  • @@ -145,7 +145,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2026 + 2027
  • @@ -154,7 +154,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2027 + 2028
  • @@ -163,7 +163,7 @@ exports[`DateView should render 1`] = ` tabindex="-1" type="button" > - 2028 + 2029
  • diff --git a/packages/containers/package.json b/packages/containers/package.json index 5b7bfc4ec7b..807159a7e8c 100644 --- a/packages/containers/package.json +++ b/packages/containers/package.json @@ -16,9 +16,6 @@ }, "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "start": "talend-scripts start-storybook -p 6007", diff --git a/packages/dataviz/package.json b/packages/dataviz/package.json index fb44dd02e9c..ab4326ffff1 100644 --- a/packages/dataviz/package.json +++ b/packages/dataviz/package.json @@ -13,9 +13,6 @@ }, "license": "Apache-2.0", "scripts": { - "pre-release": "yarn build:umd:dev && yarn build:umd:prod", - "build:umd:dev": "talend-scripts build --umd --dev", - "build:umd:prod": "talend-scripts build --umd", "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "build-storybook": "talend-scripts build-storybook", diff --git a/packages/design-system/package.json b/packages/design-system/package.json index 02ae5e90650..1aefa1ff01a 100644 --- a/packages/design-system/package.json +++ b/packages/design-system/package.json @@ -17,10 +17,7 @@ }, "scripts": { "build:lib": "talend-scripts build", - "build:lib:umd": "talend-scripts build --umd --dev", - "build:lib:umd:min": "talend-scripts build --umd --prod", "build:lib:esm": "talend-scripts build --esm", - "pre-release": "npm run build:lib:umd && npm run build:lib:umd:min", "watch": "talend-scripts build --watch", "test": "talend-scripts test", "extract-i18n": "i18next-scanner --config i18next-scanner.config.js", diff --git a/packages/design-tokens/package.json b/packages/design-tokens/package.json index aab1736e546..4014c46a503 100644 --- a/packages/design-tokens/package.json +++ b/packages/design-tokens/package.json @@ -28,14 +28,11 @@ } }, "scripts": { - "pre-release": "echo nothing", - "build:umd:dev": "talend-scripts build --umd --dev", - "build:umd:prod": "talend-scripts build --umd", - "build:lib": "talend-scripts build && yarn build:umd:dev && yarn build:umd:prod && yarn test:umd", + "build:lib": "talend-scripts build && npm run build:css", "build:lib:esm": "talend-scripts build --esm", + "build:css": "sass src/index.scss dist/TalendDesignTokens.css --no-source-map --style=compressed", "test": "echo no test for @talend/design-tokens", "test:cov": "echo no test for @talend/design-tokens", - "test:umd": "jest scripts/umd.test.js", "lint": "talend-scripts lint" }, "keywords": [ @@ -57,6 +54,7 @@ "access": "public" }, "devDependencies": { + "sass": "^1.93.2", "@talend/eslint-config": "^13.5.0", "@talend/eslint-plugin": "^1.6.0", "@talend/scripts-core": "^16.8.0", diff --git a/packages/faceted-search-query-client/package.json b/packages/faceted-search-query-client/package.json index aa3b779433c..bea879fcc62 100644 --- a/packages/faceted-search-query-client/package.json +++ b/packages/faceted-search-query-client/package.json @@ -16,9 +16,6 @@ }, "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "test": "cross-env TZ=UTC talend-scripts test", diff --git a/packages/faceted-search/package.json b/packages/faceted-search/package.json index 77fe1e172d1..a862e42771a 100644 --- a/packages/faceted-search/package.json +++ b/packages/faceted-search/package.json @@ -16,9 +16,6 @@ }, "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "build:lib:esm": "talend-scripts build --esm", "test": "cross-env TZ=UTC talend-scripts test", diff --git a/packages/faceted-search/src/components/Badges/BadgeDate/__snapshots__/BadgeDateForm.component.test.js.snap b/packages/faceted-search/src/components/Badges/BadgeDate/__snapshots__/BadgeDateForm.component.test.js.snap index 5b1b20acc5b..5fb6626f115 100644 --- a/packages/faceted-search/src/components/Badges/BadgeDate/__snapshots__/BadgeDateForm.component.test.js.snap +++ b/packages/faceted-search/src/components/Badges/BadgeDate/__snapshots__/BadgeDateForm.component.test.js.snap @@ -159,7 +159,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2022 + 2023
  • @@ -168,7 +168,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2023 + 2024
  • @@ -177,7 +177,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2024 + 2025
  • @@ -186,7 +186,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="0" type="button" > - 2025 + 2026
  • @@ -195,7 +195,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2026 + 2027
  • @@ -204,7 +204,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2027 + 2028
  • @@ -213,7 +213,7 @@ exports[`BadgeDateForm should mount a badge and change date 1`] = ` tabindex="-1" type="button" > - 2028 + 2029
  • diff --git a/packages/flow-designer/package.json b/packages/flow-designer/package.json index 00905809cf2..a2ea4bd9c78 100644 --- a/packages/flow-designer/package.json +++ b/packages/flow-designer/package.json @@ -5,11 +5,21 @@ "types": "lib/index.d.ts", "main": "lib/index.js", "mainSrc": "src/index.js", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { "build:lib": "talend-scripts build", + "build:lib:esm": "talend-scripts build --esm", "lint": "talend-scripts lint", - "test": "talend-scripts test", - "pre-release": "talend-scripts build --umd" + "test": "talend-scripts test" }, "repository": { "type": "git", diff --git a/packages/forms/package.json b/packages/forms/package.json index 38c739ff159..388862fbeef 100644 --- a/packages/forms/package.json +++ b/packages/forms/package.json @@ -16,11 +16,8 @@ }, "license": "Apache-2.0", "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", "build:lib:esm": "talend-scripts build --esm", "build-storybook": "talend-scripts build-storybook", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", "test": "cross-env TZ=UTC talend-scripts test", "test:watch": "talend-scripts test --watch", diff --git a/packages/forms/src/UIForm/fields/Code/Code.component.tsx b/packages/forms/src/UIForm/fields/Code/Code.component.tsx index 75de7bd8dc4..bc590209958 100644 --- a/packages/forms/src/UIForm/fields/Code/Code.component.tsx +++ b/packages/forms/src/UIForm/fields/Code/Code.component.tsx @@ -1,37 +1,18 @@ -import { DetailedHTMLProps, LabelHTMLAttributes, lazy, Suspense, useEffect, useState } from 'react'; +import { DetailedHTMLProps, LabelHTMLAttributes, useEffect, useState } from 'react'; import { IAceEditorProps } from 'react-ace'; import { useTranslation } from 'react-i18next'; - -import assetsApi from '@talend/assets-api'; +import ReactAce from 'react-ace'; +import 'ace-builds/src-noconflict/ext-language_tools'; import { VisuallyHidden } from '@talend/design-system'; import { I18N_DOMAIN_FORMS } from '../../../constants'; import { generateDescriptionId, generateErrorId, generateId } from '../../Message/generateId'; import FieldTemplate from '../FieldTemplate'; -import CodeSkeleton from './CodeSkeleton.component'; -// Define ace namespace to avoid compiler error -// And use it during react-ace lazy load without importing it (that will break lazy loading) -// eslint-disable-next-line @typescript-eslint/no-explicit-any declare const ace: any; -const ReactAce = lazy(() => - // eslint-disable-next-line @typescript-eslint/no-explicit-any - assetsApi.getUMD('react-ace').then((mod: any) => { - const extUrl = assetsApi.getURL('/src-min-noconflict/ext-language_tools.js', 'ace-builds'); - ace.config.set('basePath', extUrl.replace('ext-language_tools.js', '')); - assetsApi.addScript({ src: extUrl }); - // wait for ext-language_tools.js to be loaded before return the ace module - return new Promise(resolve => { - const cancel = setInterval(() => { - if (ace.require('ace/ext/language_tools')) { - clearInterval(cancel); - resolve(assetsApi.toDefaultModule(mod.default)); - } - }, 100); - }); - }), -); +// setup CDN so ace is able to load its modes and themes +ace.config.set('basePath', 'https://statics.cloud.talend.com/ace-builds/1.10.1/src-min-noconflict'); const DEFAULT_SET_OPTIONS = { enableBasicAutocompletion: true, @@ -60,7 +41,7 @@ export interface CodeProps { ) => void; onFinish: (event: Event, payload: { schema: Partial }) => void; schema?: Partial; - value?: string | number; + value?: string; valueIsUpdating?: boolean; showInstructions?: boolean; } @@ -121,29 +102,27 @@ export default function Code({ )} - }> - onFinish(event, { schema })} - onLoad={(component: unknown) => setEditor(component)} - onChange={(newValue: string | number, event: Event) => - onChange(event, { schema: schema, value: newValue }) - } - // disabled is not supported by ace use readonly - // https://github.com/ajaxorg/ace/issues/406 - readOnly={readOnly || schema.disabled || valueIsUpdating} - setOptions={DEFAULT_SET_OPTIONS} - showGutter={false} - showPrintMargin={false} - value={value} - width="auto" - {...options} - /> - + onFinish(event, { schema })} + onLoad={(component: unknown) => setEditor(component)} + onChange={(newValue: string | number, event: Event) => + onChange(event, { schema: schema, value: newValue }) + } + // disabled is not supported by ace use readonly + // https://github.com/ajaxorg/ace/issues/406 + readOnly={readOnly || schema.disabled || valueIsUpdating} + setOptions={DEFAULT_SET_OPTIONS} + showGutter={false} + showPrintMargin={false} + value={value} + width="auto" + {...options} + /> ); diff --git a/packages/http/package.json b/packages/http/package.json index 56b4ef9bb3a..0657ea43ad1 100644 --- a/packages/http/package.json +++ b/packages/http/package.json @@ -17,11 +17,19 @@ "types": "lib/index.d.ts", "main": "lib/index.js", "mainSrc": "src/index.ts", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { "build:lib": "talend-scripts build", - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", + "build:lib:esm": "talend-scripts build --esm", "start": "echo nothing to start", "test": "talend-scripts test", "lint": "talend-scripts lint" diff --git a/packages/playground/package.json b/packages/playground/package.json index 1e2e8f61a32..75c88693a0b 100644 --- a/packages/playground/package.json +++ b/packages/playground/package.json @@ -7,7 +7,6 @@ "scripts": { "build": "cross-env BASENAME='/playground' talend-scripts build", "test": "echo nothing to test in playground", - "test:demo:umd": "cross-env BASENAME='/playground/' INITIATOR_URL='/playground/inject.js' talend-scripts build --prod", "start": "cross-env BASENAME='/' INITIATOR_URL='/inject.js' talend-scripts start --open http://localhost:3000", "start-dist": "talend-scripts build && node serve-dist", "lint": "talend-scripts lint" diff --git a/packages/playground/src/app/index.jsx b/packages/playground/src/app/index.jsx index f8bdc5a3927..9b51d5c5989 100644 --- a/packages/playground/src/app/index.jsx +++ b/packages/playground/src/app/index.jsx @@ -6,15 +6,16 @@ * and other style can override it */ // eslint-disable-next-line @talend/import-depth -import { initI18n } from './i18n'; +// eslint-disable-next-line @talend/import-depth import '@talend/bootstrap-theme/dist/bootstrap.css'; import cmf from '@talend/react-cmf'; import getRouter from '@talend/react-cmf-router'; -import { AppLoader, IconsProvider as BaseIconsProvider } from '@talend/react-components'; +import { AppLoader, IconsProvider } from '@talend/react-components'; import containersModule from '@talend/react-containers'; import ComponentForm from '@talend/react-containers/lib/ComponentForm'; +import { initI18n } from './i18n'; import actions from './actions'; import ComponentFormSandbox from './components/ComponentFormSandbox'; import { Dataviz } from './components/Dataviz'; @@ -31,13 +32,6 @@ if (basename === '/') { const router = getRouter({ basename }); initI18n(); -const allsvg = `${basename || ''}/cdn/@talend/icons/${ - process.env.ICONS_VERSION -}/dist/svg-bundle/all.svg`; - -function IconsProvider() { - return ; -} const app = { components: { diff --git a/packages/playground/webpack.config.dev.js b/packages/playground/webpack.config.dev.js index 3045a69dba4..4c648542a14 100644 --- a/packages/playground/webpack.config.dev.js +++ b/packages/playground/webpack.config.dev.js @@ -1,60 +1,7 @@ -const path = require('path'); -const webpack = require('webpack'); -const resolve = require('@talend/dynamic-cdn-webpack-plugin/src/resolve-pkg'); -const CopyWebpackPlugin = require('copy-webpack-plugin'); - const mockBackend = require('./mockBackend/server'); -/* - * because we are in dev mode our webpack config do not detect cdn resources in the yarn.lock. - * so we compute the path of the resources to copy. - */ - -function getPath(pkg) { - const pkgPath = resolve(pkg, { cwd: process.cwd() }); - if (!pkgPath) { - console.error(`ValueError: can t find pkg of ${pkg}`); - } - return pkgPath - .replace('main.js', '') - .replace('lib/index.js', '') - .replace('dist/bootstrap.js', '') - .replace('dist/TalendIcons.js', ''); -} - -function getVersion(pkg) { - return require(`${getPath(pkg)}/package.json`).version; -} - -const PKGS = [ - '@talend/assets-api', - '@talend/design-tokens', - '@talend/design-system', - '@talend/react-components', - '@talend/react-containers', - '@talend/react-cmf', - '@talend/react-cmf-router', - '@talend/react-dataviz', - '@talend/react-faceted-search', - '@talend/react-forms', - '@talend/bootstrap-theme', - '@talend/icons', -]; - -const to = pkg => path.relative(process.cwd(), path.resolve(`cdn/${pkg}/${getVersion(pkg)}/dist/`)); -const patterns = PKGS.map(pkg => ({ - from: path.resolve(getPath(pkg), 'dist'), - to: `${to(pkg)}/`, - info: { minimized: true }, -})); - const webpackConfig = { - plugins: [ - new CopyWebpackPlugin({ patterns }), - new webpack.DefinePlugin({ - 'process.env.ICONS_VERSION': JSON.stringify(getVersion('@talend/icons')), - }), - ], + plugins: [], output: { publicPath: process.env.BASENAME || '/', }, diff --git a/packages/router-bridge/package.json b/packages/router-bridge/package.json index 4f36fa56d84..7afeb8d0eb5 100644 --- a/packages/router-bridge/package.json +++ b/packages/router-bridge/package.json @@ -3,11 +3,19 @@ "version": "2.3.0", "description": "Bridge on top of cmf-router or react-router v5 + connected-react-router", "main": "lib/index.js", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", + "build:lib:esm": "talend-scripts build --esm", "build": "talend-scripts build", "lint": "talend-scripts lint", "test": "talend-scripts test" diff --git a/packages/sagas/package.json b/packages/sagas/package.json index 4293cb62f24..40340e7add3 100644 --- a/packages/sagas/package.json +++ b/packages/sagas/package.json @@ -5,11 +5,19 @@ "main": "lib/index.js", "mainSrc": "src/index.js", "license": "Apache-2.0", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", + "build:lib:esm": "talend-scripts build --esm", "test": "talend-scripts test", "test:watch": "talend-scripts test --watch", "test:cov": "talend-scripts test --coverage", diff --git a/packages/stepper/package.json b/packages/stepper/package.json index 5eb75caca0d..cb74d9f1d65 100644 --- a/packages/stepper/package.json +++ b/packages/stepper/package.json @@ -5,11 +5,19 @@ "mainSrc": "src/index.js", "types": "lib/index.d.ts", "license": "Apache-2.0", + "exports": { + ".": { + "import": "./lib-esm/index.js", + "require": "./lib/index.js" + }, + "./lib/*": { + "import": "./lib-esm/*", + "require": "./lib/*" + } + }, "scripts": { - "build:dev": "talend-scripts build --umd --dev", - "build:prod": "talend-scripts build --umd --prod", - "pre-release": "yarn build:dev && yarn build:prod", "build:lib": "talend-scripts build", + "build:lib:esm": "talend-scripts build --esm", "extract-i18n": "i18next-scanner --config i18next-scanner.config.js", "test": "cross-env TZ=UTC talend-scripts test", "test:noisy": "cross-env TZ=UTC talend-scripts test", diff --git a/packages/theme/example/index.html b/packages/theme/example/index.html index 4f868c4ae12..b81dda8017f 100644 --- a/packages/theme/example/index.html +++ b/packages/theme/example/index.html @@ -1,4 +1,4 @@ - + diff --git a/tools/scripts-config-react-webpack/config/webpack.config.js b/tools/scripts-config-react-webpack/config/webpack.config.js index 81e2a2a1f85..3c6c64a645e 100644 --- a/tools/scripts-config-react-webpack/config/webpack.config.js +++ b/tools/scripts-config-react-webpack/config/webpack.config.js @@ -15,10 +15,8 @@ const { DuplicatesPlugin } = require('inspectpack/plugin'); const SentryWebpackPlugin = require('@sentry/webpack-plugin'); const ReactCMFWebpackPlugin = require('@talend/react-cmf-webpack-plugin'); -const cdn = require('@talend/scripts-config-cdn'); const utils = require('@talend/scripts-utils'); const LICENSE_BANNER = require('./licence'); -const inject = require('./inject'); const icons = require('./icons'); const AppLoader = require('./loader'); const { @@ -30,9 +28,6 @@ const { getFileNameForExtension, } = require('./webpack.config.common'); -const INITIATOR_URL = process.env.INITIATOR_URL || '@@INITIATOR_URL@@'; -const cdnMode = !!process.env.INITIATOR_URL; - const DEFAULT_INDEX_TEMPLATE_PATH = 'src/app/index.html'; const BASE_TEMPLATE_PATH = path.join(__dirname, 'index.tpl.html'); @@ -40,9 +35,6 @@ const TALEND_LIB_PREFIX = '@talend/'; const BASENAME = process.env.BASENAME || '/'; -// set @talend packages in module-to-cdn -cdn.configureTalendModules(); - // Check if Typescript is setup const useTypescript = utils.fs.tsConfig(); @@ -118,32 +110,21 @@ function getTalendVersions() { } function getVersions() { - const talendLibraries = cdn - .getModulesFromLockFile() - .filter(Boolean) - .map(info => ({ version: info.version, name: info.name })); // eslint-disable-next-line const packageJson = require(path.join(process.cwd(), 'package.json')); return { version: packageJson.version, - talendLibraries, revision: getGitRevision(), }; } const VERSIONS = getVersions(); // meta for html webpack plugin -const meta = VERSIONS.talendLibraries.reduce( - (acc, lib) => { - acc[lib.name] = lib.version; - return acc; - }, - { - 'app-version': VERSIONS.version, - 'app-revision': VERSIONS.revision, - }, -); +const meta = { + 'app-version': VERSIONS.version, + 'app-revision': VERSIONS.revision, +}; function renderMeta() { return Object.keys(meta) @@ -151,7 +132,7 @@ function renderMeta() { .join('\n'); } -function getCopyConfig(env, userCopyConfig = [], noDynamicCdn) { +function getCopyConfig(env, userCopyConfig = []) { const config = [...userCopyConfig]; const assetsOverridden = config.some(nextAsset => typeof nextAsset === 'object' ? nextAsset.from === 'src/assets' : nextAsset === 'src/assets', @@ -159,13 +140,10 @@ function getCopyConfig(env, userCopyConfig = [], noDynamicCdn) { if (!assetsOverridden && fs.existsSync(path.join(process.cwd(), 'src/assets'))) { config.push({ from: 'src/assets' }); } - if (!cdnMode && !noDynamicCdn) { - cdn.getCopyConfig().forEach(c => config.push(c)); - } return config; } -async function getIndexTemplate(env, mode, indexTemplatePath, useInitiator = true) { +async function getIndexTemplate(env, mode, indexTemplatePath) { const headPath = path.join(process.cwd(), '.talend', 'head.html'); const headExists = await utils.fs.isFile(headPath); @@ -182,28 +160,11 @@ async function getIndexTemplate(env, mode, indexTemplatePath, useInitiator = tru * Let's bypass this issue by setting a process.env.NODE_ENV */ let headScript = ''; - if (useInitiator) { - // meta are not injected if inject is false - headScript = `${renderMeta()} - `; - } else { - headScript = `${renderMeta()} + headScript = `${renderMeta()} `; - } const header = `${customHead} @@ -240,7 +201,6 @@ module.exports = ({ getUserConfig, mode }) => { const userSassData = getUserConfig('sass', {}); const userCopyConfig = getUserConfig('copy', []); const cmf = getUserConfig('cmf'); - const dcwpConfig = getUserConfig('dynamic-cdn-webpack-plugin'); const sentryConfig = getUserConfig('sentry', {}); const { theme } = userSassData; @@ -254,12 +214,7 @@ module.exports = ({ getUserConfig, mode }) => { meta['app-id'] = userHtmlConfig.appId || theme; - const indexTemplate = await getIndexTemplate( - env, - mode, - indexTemplatePath, - dcwpConfig !== false, - ); + const indexTemplate = await getIndexTemplate(env, mode, indexTemplatePath); const isEnvDevelopment = mode === 'development'; const isEnvProduction = mode === 'production'; @@ -363,13 +318,12 @@ module.exports = ({ getUserConfig, mode }) => { appLoaderStyle: AppLoader.getLoaderStyle(appLoaderIcon), ...userHtmlConfig, b64favicon, - inject: dcwpConfig === false, + inject: true, template: indexTemplate, meta: { ...meta, ...(userHtmlConfig.meta || {}) }, }), - cdn.getWebpackPlugin(env, dcwpConfig), new CopyWebpackPlugin({ - patterns: getCopyConfig(env, userCopyConfig, dcwpConfig === false), + patterns: getCopyConfig(env, userCopyConfig), }), new webpack.BannerPlugin({ banner: LICENSE_BANNER, entryOnly: true }), cmf && new ReactCMFWebpackPlugin({ watch: isEnvDevelopment }), diff --git a/tools/scripts-config-react-webpack/config/webpack.config.umd.js b/tools/scripts-config-react-webpack/config/webpack.config.umd.js deleted file mode 100644 index 34a40d79c83..00000000000 --- a/tools/scripts-config-react-webpack/config/webpack.config.umd.js +++ /dev/null @@ -1,97 +0,0 @@ -const path = require('path'); -const MiniCssExtractPlugin = require('mini-css-extract-plugin'); -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; -const CopyWebpackPlugin = require('copy-webpack-plugin'); -const { DuplicatesPlugin } = require('inspectpack/plugin'); -const CircularDependencyPlugin = require('circular-dependency-plugin'); - -const cdn = require('@talend/scripts-config-cdn'); - -const utils = require('@talend/scripts-utils'); - -const { - getCommonStyleLoaders, - getSassLoaders, - getJSAndTSLoader, - getSassData, - getAssetsRules, -} = require('./webpack.config.common'); - -cdn.configureTalendModules(); - -module.exports = options => { - const dcwpConfig = options.getUserConfig('dynamic-cdn-webpack-plugin'); - const cssModulesEnabled = options.getUserConfig(['css', 'modules'], true); - const userCopyConfig = options.getUserConfig('copy', []); - const useTypescript = utils.fs.tsConfig(); - const userSassData = options.getUserConfig('sass', {}); - const sassData = getSassData(userSassData); - const isEnvProd = options.mode === 'production'; - - return (env = {}) => { - const name = (env && env.umd) || 'Talend'; - return { - mode: options.mode, - optimization: { - minimize: isEnvProd, - }, - entry: './src/index', - output: { - path: path.join(process.cwd(), './dist'), - filename: isEnvProd ? `${name}.min.js` : `${name}.js`, - library: name, - libraryTarget: 'umd', - globalObject: 'this', - }, - devtool: 'source-map', - resolve: { - extensions: ['.js', useTypescript && '.ts', useTypescript && '.tsx'].filter(Boolean), - fallback: { - url: false, - path: false, - querystring: require.resolve('querystring-es3'), - }, - }, - module: { - rules: [ - { - test: useTypescript ? /\.(js|jsx|ts|tsx)$/ : /\.js$/, - exclude: /node_modules/, - use: getJSAndTSLoader(), - }, - { - test: /\.scss$/, - use: getSassLoaders(cssModulesEnabled, sassData, false), - }, - { - test: /\.css$/, - use: getCommonStyleLoaders(false, false), - }, - ...getAssetsRules(false), - ], - }, - stats: { children: false }, // remove warnings of all plugins ... - plugins: [ - new DuplicatesPlugin(), - new CircularDependencyPlugin({ - exclude: /node_modules/, - cwd: process.cwd(), - failOnError: true, - }), - new BundleAnalyzerPlugin({ - analyzerMode: 'static', - openAnalyzer: false, - logLevel: 'error', - defaultSizes: 'stat', - reportFilename: isEnvProd ? `${name}.min.js.report.html` : `${name}.js.report.html`, - }), - new MiniCssExtractPlugin({ - filename: isEnvProd ? `${name}.min.css` : `${name}.css`, - chunkFilename: isEnvProd ? `${name}.min.css` : `${name}.css`, - }), - cdn.getWebpackPlugin(env, dcwpConfig), - userCopyConfig.length > 0 && new CopyWebpackPlugin({ patterns: userCopyConfig }), - ].filter(Boolean), - }; - }; -}; diff --git a/tools/scripts-config-react-webpack/index.js b/tools/scripts-config-react-webpack/index.js index ab58d52ccc9..5eba467aebc 100644 --- a/tools/scripts-config-react-webpack/index.js +++ b/tools/scripts-config-react-webpack/index.js @@ -1,11 +1,10 @@ -const getUMDWebpackConfig = require('./config/webpack.config.umd'); const getCommonWebpackConfig = require('./config/webpack.config'); const getDevWebpackConfig = require('./config/webpack.config.dev'); const getProdWebpackConfig = require('./config/webpack.config.prod'); module.exports = function getWebpackConfiguration(presetApi, option) { if (option && option.umd) { - return getUMDWebpackConfig(presetApi); + throw new Error('UMD not supported'); } const webpackConfigurations = [getCommonWebpackConfig(presetApi)];