From 99111f7d3d351800bfcb2c424e052e1b0a943098 Mon Sep 17 00:00:00 2001 From: Tasso Evangelista Date: Fri, 13 Nov 2020 01:47:47 -0300 Subject: [PATCH] Set a conservative output.environment on Webpack bundles --- packages/fuselage-ui-kit/webpack.config.js | 17 +++-- packages/fuselage/webpack.config.js | 11 ++- packages/ui-kit/.eslintignore | 1 + packages/ui-kit/webpack.config.js | 9 +++ yarn.lock | 89 ++-------------------- 5 files changed, 38 insertions(+), 89 deletions(-) diff --git a/packages/fuselage-ui-kit/webpack.config.js b/packages/fuselage-ui-kit/webpack.config.js index 5aa0ad1d53..05ada8d07f 100644 --- a/packages/fuselage-ui-kit/webpack.config.js +++ b/packages/fuselage-ui-kit/webpack.config.js @@ -12,11 +12,20 @@ module.exports = (env, { mode = 'production' }) => ({ 'fuselage-ui-kit': path.resolve(__dirname, 'src/index.js'), }, output: { - filename: `[name].${ mode }.js`, + filename: `[name].${mode}.js`, path: path.resolve(__dirname, 'dist'), library: 'RocketChatFuselageUiKit', libraryTarget: 'umd', umdNamedDefine: true, + environment: { + arrowFunction: false, + bigIntLiteral: false, + const: false, + destructuring: false, + dynamicImport: false, + forOf: false, + module: false, + }, }, devtool: mode === 'production' ? false : 'source-map', module: { @@ -28,11 +37,7 @@ module.exports = (env, { mode = 'production' }) => ({ }, ], }, - externals: [ - 'react', - 'react-dom', - /^@rocket.chat\//, - ], + externals: ['react', 'react-dom', /^@rocket.chat\//], plugins: [ new webpack.DefinePlugin({ 'process.env.VERSION': JSON.stringify(pkg.version), diff --git a/packages/fuselage/webpack.config.js b/packages/fuselage/webpack.config.js index 5dace7ed08..2e862ad024 100644 --- a/packages/fuselage/webpack.config.js +++ b/packages/fuselage/webpack.config.js @@ -9,11 +9,20 @@ module.exports = (env, { mode = 'production' }) => ({ fuselage: path.resolve(__dirname, 'src/index.js'), }, output: { - filename: `[name].${ mode }.js`, + filename: `[name].${mode}.js`, path: path.resolve(__dirname, 'dist'), library: 'RocketChatFuselage', libraryTarget: 'umd', umdNamedDefine: true, + environment: { + arrowFunction: false, + bigIntLiteral: false, + const: false, + destructuring: false, + dynamicImport: false, + forOf: false, + module: false, + }, }, devtool: mode === 'production' ? false : 'source-map', module: { diff --git a/packages/ui-kit/.eslintignore b/packages/ui-kit/.eslintignore index 56db724d70..e87b40057a 100644 --- a/packages/ui-kit/.eslintignore +++ b/packages/ui-kit/.eslintignore @@ -1,3 +1,4 @@ /node_modules /dist !/.eslintrc.js +/webpack.config.js diff --git a/packages/ui-kit/webpack.config.js b/packages/ui-kit/webpack.config.js index 34c75e5607..2a35c45757 100644 --- a/packages/ui-kit/webpack.config.js +++ b/packages/ui-kit/webpack.config.js @@ -16,6 +16,15 @@ module.exports = (env, argv) => ({ library: 'RocketChatUiKit', libraryTarget: 'umd', umdNamedDefine: true, + environment: { + arrowFunction: false, + bigIntLiteral: false, + const: false, + destructuring: false, + dynamicImport: false, + forOf: false, + module: false, + }, }, resolve: { extensions: ['.ts', '.tsx', '.js'], diff --git a/yarn.lock b/yarn.lock index bd61ffc2ce..726d71b3e9 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1426,38 +1426,6 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@eslint/eslintrc@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" - integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== - dependencies: - ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^12.1.0" - ignore "^4.0.6" - import-fresh "^3.2.1" - js-yaml "^3.13.1" - lodash "^4.17.19" - minimatch "^3.0.4" - strip-json-comments "^3.1.1" - -"@eslint/eslintrc@^0.2.1": - version "0.2.1" - resolved "https://registry.yarnpkg.com/@eslint/eslintrc/-/eslintrc-0.2.1.tgz#f72069c330461a06684d119384435e12a5d76e3c" - integrity sha512-XRUeBZ5zBWLYgSANMpThFddrZZkEbGHgUdt5UJjZfnlN9BGCiUBrf+nvbRupSjMvqzwnQN0qwCmOxITt1cfywA== - dependencies: - ajv "^6.12.4" - debug "^4.1.1" - espree "^7.3.0" - globals "^12.1.0" - ignore "^4.0.6" - import-fresh "^3.2.1" - js-yaml "^3.13.1" - lodash "^4.17.19" - minimatch "^3.0.4" - strip-json-comments "^3.1.1" - "@evocateur/libnpmaccess@^3.1.2": version "3.1.2" resolved "https://registry.yarnpkg.com/@evocateur/libnpmaccess/-/libnpmaccess-3.1.2.tgz#ecf7f6ce6b004e9f942b098d92200be4a4b1c845" @@ -8417,49 +8385,6 @@ eslint@^7.13.0: text-table "^0.2.0" v8-compile-cache "^2.0.3" -eslint@^7.13.0: - version "7.13.0" - resolved "https://registry.yarnpkg.com/eslint/-/eslint-7.13.0.tgz#7f180126c0dcdef327bfb54b211d7802decc08da" - integrity sha512-uCORMuOO8tUzJmsdRtrvcGq5qposf7Rw0LwkTJkoDbOycVQtQjmnhZSuLQnozLE4TmAzlMVV45eCHmQ1OpDKUQ== - dependencies: - "@babel/code-frame" "^7.0.0" - "@eslint/eslintrc" "^0.2.1" - ajv "^6.10.0" - chalk "^4.0.0" - cross-spawn "^7.0.2" - debug "^4.0.1" - doctrine "^3.0.0" - enquirer "^2.3.5" - eslint-scope "^5.1.1" - eslint-utils "^2.1.0" - eslint-visitor-keys "^2.0.0" - espree "^7.3.0" - esquery "^1.2.0" - esutils "^2.0.2" - file-entry-cache "^5.0.1" - functional-red-black-tree "^1.0.1" - glob-parent "^5.0.0" - globals "^12.1.0" - ignore "^4.0.6" - import-fresh "^3.0.0" - imurmurhash "^0.1.4" - is-glob "^4.0.0" - js-yaml "^3.13.1" - json-stable-stringify-without-jsonify "^1.0.1" - levn "^0.4.1" - lodash "^4.17.19" - minimatch "^3.0.4" - natural-compare "^1.4.0" - optionator "^0.9.1" - progress "^2.0.0" - regexpp "^3.1.0" - semver "^7.2.1" - strip-ansi "^6.0.0" - strip-json-comments "^3.1.0" - table "^5.2.3" - text-table "^0.2.0" - v8-compile-cache "^2.0.3" - espree@^7.2.0, espree@^7.3.0: version "7.3.0" resolved "https://registry.yarnpkg.com/espree/-/espree-7.3.0.tgz#dc30437cf67947cf576121ebd780f15eeac72348" @@ -14656,11 +14581,6 @@ prelude-ls@~1.1.2: resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54" integrity sha1-IZMqVJ9eUv/ZqCf1cOBL5iqX2lQ= -prepend-http@^1.0.0: - version "1.0.4" - resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc" - integrity sha1-1PRWKwzjaW5BrFLQ4ALlemNdxtw= - prettier-linter-helpers@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz#d23d41fe1375646de2d0104d3454a3008802cf7b" @@ -14668,11 +14588,16 @@ prettier-linter-helpers@^1.0.0: dependencies: fast-diff "^1.1.2" -prettier@^2.1.2: +prettier@2.1.2, prettier@^2.1.2: version "2.1.2" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.1.2.tgz#3050700dae2e4c8b67c4c3f666cdb8af405e1ce5" integrity sha512-16c7K+x4qVlJg9rEbXl7HEGmQyZlG4R9AgP+oHKRMsMsuk8s+ATStlf1NpDqyBI1HpVyfjLOeMhH2LvuNvV5Vg== - + +prettier@~2.0.5: + version "2.0.5" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.0.5.tgz#d6d56282455243f2f92cc1716692c08aa31522d4" + integrity sha512-7PtVymN48hGcO4fGjybyBSIWDsLU4H4XlvOHfq91pz9kkGlonzwTfYkaIEwiRg/dAJF9YlbsduBAgtYLi+8cFg== + pretty-bytes@^3.0.0: version "3.0.1" resolved "https://registry.yarnpkg.com/pretty-bytes/-/pretty-bytes-3.0.1.tgz#27d0008d778063a0b4811bb35c79f1bd5d5fbccf"