Use debian packaged node modules when available - Exclude packaged modules from transpiling - Remove webpack-bundle-analyzer - Resolve .json files - Add more plugins to babel.config.js - Add mkdirp 1.0 and loader-utils 2.0 to ensure compatibility for packaged modules (See #976310) - Use link protocol for modules with permission issues (which has a bin: entry in package.json) See https://github.com/yarnpkg/berry/issues/2266 --- a/config/webpack.config.js +++ b/config/webpack.config.js @@ -6,7 +6,6 @@ const StatsWriterPlugin = require('webpack-stats-plugin').StatsWriterPlugin; const CompressionPlugin = require('compression-webpack-plugin'); const MonacoWebpackPlugin = require('./plugins/monaco_webpack'); -const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin; const CopyWebpackPlugin = require('copy-webpack-plugin'); const vendorDllHash = require('./helpers/vendor_dll_hash'); @@ -150,6 +149,8 @@ entry: generateEntries, + externals: [ 'canvas' ], + output: { path: path.join(ROOT_PATH, 'public/assets/webpack'), publicPath: '/assets/webpack/', @@ -159,13 +160,13 @@ }, resolve: { - extensions: ['.js', '.gql', '.graphql'], - modules: ['/usr/share/gitlab/node_modules','/usr/share/gitlab/node_modules/mermaid/node_modules', '/usr/lib/nodejs'], + extensions: ['.js', '.gql', '.graphql', '.json'], + modules: ['/var/lib/gitlab/node_modules','/usr/share/gitlab/vendor/node_modules','/usr/share/gitlab/node_modules/mermaid/node_modules', '/usr/share/nodejs/markdown-it/node_modules/', '/usr/lib/nodejs', '/usr/share/nodejs'], alias, }, resolveLoader: { - modules: ['/usr/share/gitlab/node_modules', '/usr/lib/nodejs'], + modules: ['/var/lib/gitlab/node_modules', '/usr/lib/nodejs','/usr/share/nodejs'], }, module: { @@ -178,9 +179,13 @@ }, { test: /\.js$/, - exclude: path => + exclude: [ path => /node_modules\/(?!tributejs)|node_modules|vendor[\\/]assets/.test(path) && !/\.vue\.js/.test(path), + /\/usr\/share\/nodejs/, + /\/usr\/lib\/nodejs/, + /\/usr\/share\/javascript/ + ], loader: 'babel-loader', options: { cacheDirectory: path.join(CACHE_PATH, 'babel-loader'), @@ -516,19 +521,6 @@ // enable HMR only in webpack-dev-server DEV_SERVER_LIVERELOAD && new webpack.HotModuleReplacementPlugin(), - // optionally generate webpack bundle analysis - WEBPACK_REPORT && - new BundleAnalyzerPlugin({ - analyzerMode: 'static', - generateStatsFile: true, - openAnalyzer: false, - reportFilename: path.join(ROOT_PATH, 'webpack-report/index.html'), - statsFilename: path.join(ROOT_PATH, 'webpack-report/stats.json'), - statsOptions: { - source: false, - }, - }), - new webpack.DefinePlugin({ // This one is used to define window.gon.ee and other things properly in tests: 'process.env.IS_EE': JSON.stringify(IS_EE), @@ -563,6 +555,7 @@ node: { fs: 'empty', // sqljs requires fs + Buffer: 'mock', setImmediate: false, }, }; --- a/package.json +++ b/package.json @@ -35,12 +35,6 @@ "webpack-prod": "NODE_OPTIONS=\"--max-old-space-size=3584\" NODE_ENV=production webpack --config config/webpack.config.js" }, "dependencies": { - "@babel/core": "^7.10.1", - "@babel/plugin-proposal-class-properties": "^7.10.1", - "@babel/plugin-proposal-json-strings": "^7.10.1", - "@babel/plugin-proposal-private-methods": "^7.10.1", - "@babel/plugin-syntax-import-meta": "^7.10.1", - "@babel/preset-env": "^7.10.1", "@gitlab/at.js": "1.5.5", "@gitlab/svgs": "1.164.0", "@gitlab/ui": "21.3.1", @@ -55,29 +49,28 @@ "apollo-link": "^1.2.14", "apollo-link-batch-http": "^1.2.14", "apollo-upload-client": "^13.0.0", - "autosize": "^4.0.2", + "autosize": "portal:/usr/share/nodejs/autosize", "aws-sdk": "^2.637.0", - "axios": "^0.20.0", - "babel-loader": "^8.0.6", + "axios": "portal:/usr/share/nodejs/axios", + "babel-loader": "portal:/usr/share/nodejs/babel-loader", "babel-plugin-lodash": "^3.3.4", "bootstrap": "4.4.1", - "brace-expansion": "^1.1.8", - "cache-loader": "^4.1.0", - "clipboard": "^1.7.1", - "codemirror": "^5.48.4", + "brace-expansion": "portal:/usr/share/nodejs/brace-expansion", + "cache-loader": "portal:/usr/share/nodejs/cache-loader", + "clipboard": "portal:/usr/share/nodejs/clipboard", + "codemirror": "portal:/usr/share/nodejs/codemirror", "codesandbox-api": "0.0.23", - "compression-webpack-plugin": "^3.0.1", - "copy-webpack-plugin": "^5.0.5", - "core-js": "^3.6.4", + "core-js": "portal:/usr/share/nodejs/core-js", + "compression-webpack-plugin": "portal:/usr/share/nodejs/compression-webpack-plugin", + "copy-webpack-plugin": "portal:/usr/share/nodejs/copy-webpack-plugin", "cron-validator": "^1.1.1", "cropper": "^2.3.0", - "css-loader": "^2.1.1", - "d3": "^5.16.0", - "d3-sankey": "^0.12.3", - "d3-scale": "^2.2.2", - "d3-selection": "^1.2.0", - "dateformat": "^3.0.3", - "deckar01-task_list": "^2.3.1", + "d3": "portal:/usr/share/nodejs/d3", + "d3-sankey": "portal:/usr/share/nodejs/d3-sankey", + "d3-scale": "portal:/usr/share/nodejs/d3-scale", + "d3-selection": "portal:/usr/share/nodejs/d3-selection", + "dateformat": "portal:/usr/share/nodejs/dateformat", + "deckar01-task_list": "portal:/usr/share/nodejs/deckar01-task_list", "diff": "^3.4.0", "document-register-element": "1.14.3", "dompurify": "^2.0.11", @@ -85,81 +78,54 @@ "editorconfig": "^0.15.3", "emoji-regex": "^7.0.3", "emoji-unicode-version": "^0.2.1", - "exports-loader": "^0.7.0", - "file-loader": "^5.1.0", - "font-awesome": "4.7.0", + "font-awesome": "link:/usr/share/nodejs/font-awesome", "fuzzaldrin-plus": "^0.6.0", - "glob": "^7.1.6", "graphql": "^14.7.0", "graphql-tag": "^2.10.1", "gray-matter": "^4.0.2", "immer": "^7.0.7", - "imports-loader": "^0.8.0", "ipaddr.js": "^1.9.1", - "jed": "^1.1.1", "jest-transform-graphql": "^2.1.0", - "jquery": "^3.5.0", - "jquery-ujs": "1.2.2", + "jquery": "portal:/usr/share/nodejs/jquery", "jquery.caret": "^0.3.1", "jquery.waitforimages": "^2.2.0", - "js-cookie": "^2.2.1", - "js-yaml": "^3.13.1", - "jszip": "^3.1.3", - "jszip-utils": "^0.0.2", - "katex": "^0.10.0", - "lodash": "^4.17.20", + "katex": "link:/usr/share/nodejs/katex", + "loader-utils": "portal:/usr/share/nodejs/loader-utils", "marked": "^0.3.12", - "mermaid": "^8.5.2", "mersenne-twister": "1.1.0", - "minimatch": "^3.0.4", - "miragejs": "^0.1.40", + "miragejs": "portal:/usr/share/nodejs/miragejs", "mock-apollo-client": "^0.4.0", "monaco-editor": "^0.20.0", "monaco-editor-webpack-plugin": "^1.9.0", "monaco-yaml": "^2.4.1", - "mousetrap": "1.6.5", - "pdfjs-dist": "^2.0.943", "pikaday": "^1.8.0", - "popper.js": "^1.16.1", - "prismjs": "^1.21.0", - "prosemirror-markdown": "^1.3.0", - "prosemirror-model": "^1.6.4", "raphael": "^2.2.7", - "raw-loader": "^4.0.0", "select2": "3.5.2-browserify", "smooshpack": "^0.0.62", "sortablejs": "^1.10.2", "sql.js": "^0.4.0", "stickyfilljs": "^2.1.0", "string-hash": "1.1.3", - "style-loader": "^1.1.3", "swagger-ui-dist": "^3.32.4", "three": "^0.84.0", - "three-orbit-controls": "^82.1.0", - "three-stl-loader": "^1.0.4", - "timeago.js": "^4.0.2", "tiptap": "^1.8.0", "tiptap-commands": "^1.4.0", "tiptap-extensions": "^1.8.0", "tributejs": "5.1.3", - "url-loader": "^3.0.0", - "uuid": "8.1.0", "visibilityjs": "^1.2.4", - "vue": "^2.6.10", + "vue": "link:/usr/share/nodejs/vue", "vue-apollo": "^3.0.3", "vue-loader": "^15.9.0", "vue-router": "^3.4.3", - "vue-template-compiler": "^2.6.10", + "vue-template-compiler": "link:/usr/share/nodejs/vue-template-compiler", "vue-virtual-scroll-list": "^1.4.4", "vuedraggable": "^2.23.0", "vuex": "^3.5.1", + "webpack": "link:/usr/share/nodejs/webpack", "web-vitals": "^0.2.4", - "webpack": "^4.42.0", - "webpack-bundle-analyzer": "^3.6.0", - "webpack-cli": "^3.3.11", - "webpack-stats-plugin": "^0.3.1", - "worker-loader": "^2.0.0", - "xterm": "3.14.5" + "mkdirp": "link:/usr/share/nodejs/mkdirp", + "postcss": "portal:/usr/share/nodejs/postcss", + "schema-utils": "portal:/usr/share/nodejs/schema-utils" }, "devDependencies": { }, --- a/babel.config.js +++ b/babel.config.js @@ -34,9 +34,12 @@ // include stage 3 proposals const plugins = [ '@babel/plugin-syntax-import-meta', + '@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-class-properties', '@babel/plugin-proposal-json-strings', '@babel/plugin-proposal-private-methods', + '@babel/plugin-proposal-optional-chaining', + '@babel/plugin-proposal-nullish-coalescing-operator', // See: https://gitlab.com/gitlab-org/gitlab/-/issues/229146 '@babel/plugin-transform-arrow-functions', 'lodash', --- a/app/assets/javascripts/pdf/index.vue +++ b/app/assets/javascripts/pdf/index.vue @@ -1,6 +1,6 @@