From 2b676586229f24a5de9517adfb02f98cf998cfdd Mon Sep 17 00:00:00 2001 From: Aaron Shafovaloff Date: Mon, 7 Aug 2023 16:44:10 -0600 Subject: [PATCH] Remove CJS build from RCE test plan - build passes flag=none refs FOO-3705 Change-Id: I6d14ad05133ec09206f88a86d0cd350a030d5f72 Reviewed-on: https://gerrit.instructure.com/c/canvas-lms/+/324612 Reviewed-by: Jacob DeWar QA-Review: Jacob DeWar Product-Review: Aaron Shafovaloff Build-Review: Andrea Cirulli Tested-by: Service Cloud Jenkins --- docker-compose.spring.yml | 1 - jest.config.js | 5 ----- jest/jest-setup.js | 2 +- packages/canvas-rce/jest.config.js | 4 ++-- packages/canvas-rce/package.json | 7 ++----- packages/canvas-rce/scripts/build-canvas | 1 - packages/canvas-rce/scripts/build.js | 21 ------------------- packages/canvas-rce/scripts/generateSvgs.js | 2 +- packages/canvas-rce/src/format-message.js | 4 ++-- .../EquationEditorToolbar/buttons.js | 4 ++-- .../instructure_equation/MathIcon/svgs.js | 4 ++-- packages/canvas-rce/webpack.shared.config.js | 15 +++++++------ .../canvas-rce/webpack.testcafe.config.js | 3 --- 13 files changed, 21 insertions(+), 52 deletions(-) diff --git a/docker-compose.spring.yml b/docker-compose.spring.yml index 4b1158cebb9..80d81157c38 100644 --- a/docker-compose.spring.yml +++ b/docker-compose.spring.yml @@ -25,7 +25,6 @@ services: - canvas-media_node_modules:/usr/src/app/packages/canvas-media/node_modules - canvas-planner_node_modules:/usr/src/app/packages/canvas-planner/node_modules - canvas-rce_canvas:/usr/src/app/packages/canvas-rce/canvas - - canvas-rce_lib:/usr/src/app/packages/canvas-rce/lib - canvas-rce_node_modules:/usr/src/app/packages/canvas-rce/node_modules - jest-moxios-utils_node_modules:/usr/src/app/packages/jest-moxios-utils/node_modules - js-utils_es:/usr/src/app/packages/js-utils/es diff --git a/jest.config.js b/jest.config.js index 72b0065468c..3a6196147de 100644 --- a/jest.config.js +++ b/jest.config.js @@ -27,11 +27,6 @@ module.exports = { '^Backbone$': '/public/javascripts/Backbone.js', // jest can't import the icons '@instructure/ui-icons/es/svg': '/packages/canvas-rce/src/rce/__tests__/_mockIcons.js', - // redirect imports from es/rce to lib - '@instructure/canvas-rce/es/rce/tinyRCE': '/packages/canvas-rce/lib/rce/tinyRCE.js', - '@instructure/canvas-rce/es/rce/RCE': '/packages/canvas-rce/lib/rce/RCE.js', - '@instructure/canvas-rce/es/rce/plugins/shared/Upload/CategoryProcessor': - '/packages/canvas-rce/lib/rce/plugins/shared/Upload/CategoryProcessor', // mock the tinymce-react Editor react component '@tinymce/tinymce-react': '/packages/canvas-rce/src/rce/__mocks__/tinymceReact.js', 'decimal.js/decimal.mjs': 'decimal.js/decimal.js', diff --git a/jest/jest-setup.js b/jest/jest-setup.js index 8819793965c..a7c7c2d9853 100644 --- a/jest/jest-setup.js +++ b/jest/jest-setup.js @@ -20,7 +20,7 @@ import CoreTranslations from '../public/javascripts/translations/en.json' import Enzyme from 'enzyme' import Adapter from 'enzyme-adapter-react-16' import {filterUselessConsoleMessages} from '@instructure/js-utils' -import rceFormatMessage from '@instructure/canvas-rce/lib/format-message' +import rceFormatMessage from '@instructure/canvas-rce/es/format-message' import {up as configureDateTime} from '../ui/boot/initializers/configureDateTime' import {up as configureDateTimeMomentParser} from '../ui/boot/initializers/configureDateTimeMomentParser' import {useTranslations} from '@canvas/i18n' diff --git a/packages/canvas-rce/jest.config.js b/packages/canvas-rce/jest.config.js index a8bc625f5e7..25e9d9862b4 100644 --- a/packages/canvas-rce/jest.config.js +++ b/packages/canvas-rce/jest.config.js @@ -37,9 +37,9 @@ module.exports = { '/jest/jest-setup-framework.js', '/../../jest/stubInstUi.js', ], - testPathIgnorePatterns: ['/node_modules', '/lib', '/canvas'], + testPathIgnorePatterns: ['/node_modules', '/canvas'], testMatch: ['**/__tests__/**/?(*.)(spec|test).[jt]s?(x)'], - modulePathIgnorePatterns: ['/es', '/lib', '/canvas'], + modulePathIgnorePatterns: ['/es', '/canvas'], transformIgnorePatterns: [`/node_modules/(?!${esModules})`], testEnvironment: '../../jest/strictTimeLimitEnvironment.js', moduleNameMapper: { diff --git a/packages/canvas-rce/package.json b/packages/canvas-rce/package.json index 07796fb5e09..20c236068a2 100644 --- a/packages/canvas-rce/package.json +++ b/packages/canvas-rce/package.json @@ -2,8 +2,7 @@ "name": "@instructure/canvas-rce", "version": "5.7.0", "description": "A component wrapping Canvas's usage of Tinymce", - "main": "lib/index.js", - "module": "es/index.js", + "main": "es/index.js", "scripts": { "i18n:extract": "format-message extract \"src/**/*.[jt]s*\" -g underscored_crc32 -o locales/en.json", "integration-test": "nightwatch --env integration", @@ -37,17 +36,15 @@ "build:all": "scripts/build.js", "build:es": "babel --out-dir es src --ignore '**/__tests__,**/__mocks__' --extensions '.ts,.tsx,.js,.jsx'", "build:types": "tsc", - "build:cjs": "babel --out-dir lib src --ignore '**/__tests__,**/__mocks__' --config-file=./babel.config.cjs.js --extensions '.ts,.tsx,.js,.jsx'", "build:canvas": "scripts/build-canvas", "build:watch": "yarn clean:es && yarn build:es --watch", - "build:cjs:watch": "yarn build:cjs --watch", "build:cafe": "wp --config webpack.testcafe.config.js", "prepublishOnly": "yarn build:all && yarn test", "fmt:check": "prettier -l '**/*.js*' '**/*.ts*'", "fmt:fix": "prettier --write '**/*.js*' '**/*.ts*'", "clean": "rm -rf lib && yarn clean:es && rm -rf coverage && yarn demo:clean", "clean:es": "rm -rf es", - "generate-svgs": "yarn build:cjs && scripts/generateSvgs.js && prettier --write src/rce/plugins/instructure_equation/MathIcon/svgs.js", + "generate-svgs": "yarn build:es && node --experimental-modules scripts/generateSvgs.js && prettier --write src/rce/plugins/instructure_equation/MathIcon/svgs.js", "publishToNpm": "scripts/publishToNpm.sh" }, "keywords": [ diff --git a/packages/canvas-rce/scripts/build-canvas b/packages/canvas-rce/scripts/build-canvas index e6a0883a5fb..6ebd8b9998f 100755 --- a/packages/canvas-rce/scripts/build-canvas +++ b/packages/canvas-rce/scripts/build-canvas @@ -14,5 +14,4 @@ rm -rf es/* yarn build:types yarn installTranslations -yarn build:cjs yarn build:es diff --git a/packages/canvas-rce/scripts/build.js b/packages/canvas-rce/scripts/build.js index 2cacc997044..116077b5d33 100755 --- a/packages/canvas-rce/scripts/build.js +++ b/packages/canvas-rce/scripts/build.js @@ -22,8 +22,6 @@ const shell = require('shelljs') const promisify = require('util').promisify -const exec = promisify(require('child_process').exec) -const getTranslationList = require('@instructure/translations/bin/get-translation-list') shell.set('-e') @@ -46,22 +44,3 @@ shell.exec( shell.echo('Building ES Modules version') shell.exec("npx babel --out-dir es src --ignore '**/__tests__' --extensions '.ts,.tsx,.js,.jsx'") - -shell.echo(`building pretranslated output in lib/translated in mulitple processes`) -getTranslationList('canvas-rce') - .then(translationFiles => { - const locales = translationFiles.map(tf => tf.split('.')[0]) - const processPromises = locales.map(locale => { - return exec( - `BUILD_LOCALE=${locale} npx babel --out-dir lib/translated/${locale}/modules --ignore locales* src --extensions '.ts,.tsx,.js,.jsx'` - ) - }) - Promise.all(processPromises) - .then(() => { - console.log('Translations complete') - }) - .catch(e => { - throw e - }) - }) - .catch(e => console.error(e)) diff --git a/packages/canvas-rce/scripts/generateSvgs.js b/packages/canvas-rce/scripts/generateSvgs.js index 49f89a6ad0c..876a0783ebf 100755 --- a/packages/canvas-rce/scripts/generateSvgs.js +++ b/packages/canvas-rce/scripts/generateSvgs.js @@ -34,7 +34,7 @@ const fs = require('fs') const mathjax = require('mathjax') const buttons = - require('../lib/rce/plugins/instructure_equation/EquationEditorToolbar/buttons').default + require('../es/rce/plugins/instructure_equation/EquationEditorToolbar/buttons') const OUTPUT_PATH = 'src/rce/plugins/instructure_equation/MathIcon/svgs.js' const SVGS_TEMPLATE = `/* diff --git a/packages/canvas-rce/src/format-message.js b/packages/canvas-rce/src/format-message.js index 6ba7172e607..bb96dcae1d9 100644 --- a/packages/canvas-rce/src/format-message.js +++ b/packages/canvas-rce/src/format-message.js @@ -16,7 +16,7 @@ * with this program. If not, see . */ -import formatMessage from 'format-message' +const formatMessage = require('format-message') const ns = formatMessage.namespace() @@ -24,4 +24,4 @@ ns.addLocale = translations => { ns.setup({translations: {...ns.setup().translations, ...translations}}) } -export default ns +module.exports = ns diff --git a/packages/canvas-rce/src/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js b/packages/canvas-rce/src/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js index 7ddff120418..bc4d8dc9399 100644 --- a/packages/canvas-rce/src/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js +++ b/packages/canvas-rce/src/rce/plugins/instructure_equation/EquationEditorToolbar/buttons.js @@ -16,9 +16,9 @@ * with this program. If not, see . */ -import formatMessage from '../../../../format-message' +const formatMessage = require('../../../../format-message') -export default [ +module.exports = [ { name: formatMessage('Basic'), commands: [ diff --git a/packages/canvas-rce/src/rce/plugins/instructure_equation/MathIcon/svgs.js b/packages/canvas-rce/src/rce/plugins/instructure_equation/MathIcon/svgs.js index de640c01c56..6df7fb67381 100644 --- a/packages/canvas-rce/src/rce/plugins/instructure_equation/MathIcon/svgs.js +++ b/packages/canvas-rce/src/rce/plugins/instructure_equation/MathIcon/svgs.js @@ -16,8 +16,8 @@ * with this program. If not, see . */ -/** *** This is an auto-generated file. Please do not modify manually **** */ -/** ********** If you need to update, run 'yarn generate-svgs' *********** */ +/***** This is an auto-generated file. Please do not modify manually *****/ +/************ If you need to update, run 'yarn generate-svgs' ************/ export default { '_{\\placeholder{}}': diff --git a/packages/canvas-rce/webpack.shared.config.js b/packages/canvas-rce/webpack.shared.config.js index 6a58c70439f..9607765c77d 100644 --- a/packages/canvas-rce/webpack.shared.config.js +++ b/packages/canvas-rce/webpack.shared.config.js @@ -28,17 +28,20 @@ module.exports = { test: /\.(js|jsx)$/, exclude: /node_modules/, loader: 'babel-loader', - include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'demo')] + include: [path.resolve(__dirname, 'src'), path.resolve(__dirname, 'demo')], }, {test: /(\.css$)/, include: /node_modules/, loaders: ['style-loader', 'css-loader']}, - {test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000'} - ] + {test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000'}, + ], + noParse: [ + /i18nliner\/dist\/lib\/i18nliner/, // i18nLiner has a `require('fs')` that it doesn't actually need, ignore it. + ], }, plugins: [ new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 'process.env.DEBUG': JSON.stringify(process.env.DEBUG), - ENV: JSON.stringify(process.env.NODE_ENV) - }) - ] + ENV: JSON.stringify(process.env.NODE_ENV), + }), + ], } diff --git a/packages/canvas-rce/webpack.testcafe.config.js b/packages/canvas-rce/webpack.testcafe.config.js index f26563a5024..9cb284346ec 100644 --- a/packages/canvas-rce/webpack.testcafe.config.js +++ b/packages/canvas-rce/webpack.testcafe.config.js @@ -38,9 +38,6 @@ module.exports = { {test: /(\.css$)/, include: /node_modules/, loaders: ['style-loader', 'css-loader']}, {test: /\.(png|woff|woff2|eot|ttf|svg)$/, loader: 'url-loader?limit=100000'}, ], - noParse: [ - /i18nliner\/dist\/lib\/i18nliner/, // i18nLiner has a `require('fs')` that it doesn't actually need, ignore it. - ], }, resolve: { extensions: ['.ts', '.js', '.tsx', '.jsx'],