debian-mirror-gitlab/debian/patches/0740-use-packaged-modules.patch
2021-03-11 21:09:22 +05:30

205 lines
7.4 KiB
Diff

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) or dependencies. Use portal protocol only for modules that
1. does not have any other dependency and 2. does not have a bin: entry
See https://github.com/yarnpkg/berry/issues/2266
- Even better, portal protocol tries to satisfy even devDependencies so avoid
it
- Modules with problems compression-webpack-plugin, copy-webpack-plugin,
jszip, mkdirp, js-yaml, font-awesome, katex, cache-loader, webpack
- babel-loader, cache-loader needs loader-utils 1.x and we already have 2.x and
no compat patch
- brace-expansion is a major version ahead in the archive
- xterm build is broken (#980406)
--- 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');
const createIncrementalWebpackCompiler = require('./helpers/incremental_webpack_compiler');
@@ -175,6 +174,8 @@
entry: generateEntries,
+ externals: [ 'canvas' ],
+
output: {
path: WEBPACK_OUTPUT_PATH,
publicPath: WEBPACK_PUBLIC_PATH,
@@ -184,13 +185,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: ['node_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: ['node_modules','/var/lib/gitlab/node_modules', '/usr/lib/nodejs','/usr/share/nodejs'],
},
module: {
@@ -203,9 +204,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'),
@@ -282,7 +287,7 @@
},
{
test: /\.(eot|ttf|woff|woff2)$/,
- include: /node_modules\/(katex\/dist\/fonts|monaco-editor)/,
+ include: /(node_modules\/monaco-editor|\/usr\/share\/fonts\/truetype\/katex)/,
loader: 'file-loader',
options: {
name: '[name].[contenthash:8].[ext]',
@@ -565,19 +570,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),
@@ -614,6 +606,7 @@
node: {
fs: 'empty', // sqljs requires fs
+ Buffer: 'mock',
setImmediate: false,
},
};
--- a/package.json
+++ b/package.json
@@ -98,26 +98,26 @@
"jquery": "^3.5.0",
"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",
+ "js-cookie": "link:/usr/share/nodejs/js-cookie",
+ "js-yaml": "link:/usr/share/nodejs/js-yaml",
+ "jszip": "link:/usr/share/nodejs/jszip",
+ "jszip-utils": "link:/usr/share/nodejs/jszip",
+ "katex": "link:/usr/share/nodejs/katex",
"lodash": "^4.17.20",
"marked": "^0.3.12",
"mathjax": "3",
- "mermaid": "^8.9.0",
- "minimatch": "^3.0.4",
+ "mermaid": "link:/usr/share/nodejs/mermaid",
+ "minimatch": "link:/usr/share/nodejs/minimatch",
"monaco-editor": "^0.20.0",
"monaco-editor-webpack-plugin": "^1.9.0",
"monaco-yaml": "^2.5.1",
"mousetrap": "1.6.5",
- "pdfjs-dist": "^2.0.943",
+ "pdfjs-dist": "link:/usr/share/nodejs/pdfjs-dist",
"pikaday": "^1.8.0",
- "popper.js": "^1.16.1",
+ "popper.js": "link:/usr/share/nodejs/popper.js",
"prismjs": "^1.21.0",
- "prosemirror-markdown": "^1.3.0",
- "prosemirror-model": "^1.6.4",
+ "prosemirror-markdown": "link:/usr/share/nodejs/prosemirror-markdown",
+ "prosemirror-model": "link:/usr/share/nodejs/prosemirror-model",
"raphael": "^2.2.7",
"raw-loader": "^4.0.2",
"select2": "3.5.2-browserify",
@@ -128,26 +128,25 @@
"style-loader": "^1.3.0",
"swagger-ui-dist": "^3.43.0",
"three": "^0.84.0",
- "three-orbit-controls": "^82.1.0",
+ "three-orbit-controls": "link:/usr/share/nodejs/three-orbit-controls",
"three-stl-loader": "^1.0.4",
- "timeago.js": "^4.0.2",
+ "timeago.js": "link:/usr/share/nodejs/timeago.js",
"tiptap": "^1.8.0",
"tiptap-commands": "^1.4.0",
"tiptap-extensions": "^1.8.0",
"url-loader": "^3.0.0",
- "uuid": "8.1.0",
+ "uuid": "link:/usr/share/nodejs/uuid",
"visibilityjs": "^1.2.4",
- "vue": "^2.6.12",
+ "vue": "link:/usr/share/nodejs/vue",
"vue-apollo": "^3.0.3",
"vue-loader": "^15.9.6",
"vue-router": "3.4.9",
- "vue-template-compiler": "^2.6.12",
+ "vue-template-compiler": "link:/usr/share/nodejs/vue-template-compiler",
"vue-virtual-scroll-list": "^1.4.4",
"vuedraggable": "^2.23.0",
"vuex": "^3.6.0",
"web-vitals": "^0.2.4",
"webpack": "^4.46.0",
- "webpack-bundle-analyzer": "^3.9.0",
"webpack-cli": "^3.3.12",
"webpack-stats-plugin": "^0.3.1",
"worker-loader": "^2.0.0",
--- a/babel.config.js
+++ b/babel.config.js
@@ -16,9 +16,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 @@
<script>
import pdfjsLib from 'pdfjs-dist/build/pdf';
-import workerSrc from 'pdfjs-dist/build/pdf.worker.min';
+import workerSrc from 'pdfjs-dist/build/pdf.worker';
import page from './page/index.vue';