debian-mirror-gitlab/debian/patches/nodejs/0040-use-packaged-modules.patch
2022-10-18 15:59:10 +05:30

204 lines
7 KiB
Diff

Use debian packaged node modules when available
- Exclude packaged modules from transpiling
- Remove webpack-bundle-analyzer
- Resolve .json files
- 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
@@ -17,7 +17,6 @@
const VUE_VERSION = require('vue/package.json').version;
const webpack = require('webpack');
-const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
const { StatsWriterPlugin } = require('webpack-stats-plugin');
const WEBPACK_VERSION = require('webpack/package.json').version;
@@ -257,6 +256,8 @@
entry: generateEntries,
+ externals: [ 'canvas' ],
+
output: {
path: WEBPACK_OUTPUT_PATH,
publicPath: WEBPACK_PUBLIC_PATH,
@@ -268,10 +269,15 @@
},
resolve: {
- extensions: ['.js'],
+ 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: ['node_modules','/var/lib/gitlab/node_modules', '/usr/lib/nodejs','/usr/share/nodejs'],
+ },
+
module: {
strictExportPresence: true,
rules: [
@@ -370,7 +376,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]',
@@ -773,6 +779,7 @@
node: {
fs: 'empty', // editorconfig requires 'fs'
+ Buffer: 'mock',
setImmediate: false,
},
};
--- 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';
--- a/package.json
+++ b/package.json
@@ -47,8 +47,8 @@
"dependencies": {
"@_ueberdosis/prosemirror-tables": "^1.1.3",
"@apollo/client": "^3.5.10",
- "@babel/core": "^7.18.5",
- "@babel/preset-env": "^7.18.2",
+ "@babel/core": "link:/usr/share/nodejs/@babel/core",
+ "@babel/preset-env": "link:/usr/share/nodejs/@babel/preset-env",
"@codesandbox/sandpack-client": "^1.2.2",
"@gitlab/at.js": "1.5.7",
"@gitlab/favicon-overlay": "2.0.0",
@@ -56,7 +56,7 @@
"@gitlab/ui": "43.16.0",
"@gitlab/visual-review-tools": "1.7.3",
"@gitlab/web-ide": "0.0.1-dev-20220815034418",
- "@rails/actioncable": "6.1.4-7",
+ "@rails/actioncable": "link:/usr/share/nodejs/@rails/actioncable",
"@rails/ujs": "6.1.4-7",
"@sentry/browser": "5.30.0",
"@sourcegraph/code-host-integration": "0.0.60",
@@ -95,23 +95,23 @@
"autosize": "^5.0.1",
"axios": "^0.24.0",
"babel-loader": "^8.2.5",
- "babel-plugin-lodash": "^3.3.4",
+ "babel-plugin-lodash": "link:/usr/share/nodejs/babel-plugin-lodash",
"bootstrap": "4.5.3",
"cache-loader": "^4.1.0",
"canvas-confetti": "^1.4.0",
- "clipboard": "^2.0.8",
+ "clipboard": "link:/usr/share/nodejs/clipboard",
"codesandbox-api": "0.0.23",
"compression-webpack-plugin": "^5.0.2",
"copy-webpack-plugin": "^6.4.1",
"core-js": "^3.25.1",
- "cron-validator": "^1.1.1",
+ "cron-validator": "link:/usr/share/nodejs/cron-validator",
"cronstrue": "^1.122.0",
"cropper": "^2.3.0",
"css-loader": "^2.1.1",
- "d3": "^5.16.0",
- "d3-sankey": "^0.12.3",
- "d3-selection": "^1.2.0",
- "dateformat": "^5.0.1",
+ "d3": "link:/usr/share/nodejs/d3",
+ "d3-sankey": "link:/usr/share/nodejs/d3-sankey",
+ "d3-selection": "link:/usr/share/nodejs/d3-selection",
+ "dateformat": "link:/usr/share/nodejs/dateformat",
"deckar01-task_list": "^2.3.1",
"diff": "^3.4.0",
"dompurify": "^2.4.0",
@@ -129,29 +129,29 @@
"jed": "^1.1.1",
"jquery": "^3.6.0",
"jquery.caret": "^0.3.1",
- "js-cookie": "^3.0.0",
- "js-yaml": "^3.13.1",
+ "js-cookie": "link:/usr/share/nodejs/js-cookie",
+ "js-yaml": "link:/usr/share/nodejs/js-yaml",
"jszip": "^3.1.3",
- "katex": "^0.13.2",
- "lodash": "^4.17.20",
+ "katex": "link:/usr/share/nodejs/katex",
+ "lodash": "link:/usr/share/nodejs/lodash",
"lowlight": "^2.6.1",
"marked": "^4.0.18",
"mathjax": "3",
"mdurl": "^1.0.1",
"mermaid": "^9.1.3",
"micromatch": "^4.0.5",
- "minimatch": "^3.0.4",
+ "minimatch": "link:/usr/share/nodejs/minimatch",
"monaco-editor": "^0.30.1",
"monaco-editor-webpack-plugin": "^6.0.0",
"monaco-yaml": "3.0.0",
"mousetrap": "1.6.5",
"papaparse": "^5.3.1",
"patch-package": "^6.4.7",
- "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",
"portal-vue": "^2.1.7",
- "postcss": "8.4.14",
+ "postcss": "link:/usr/share/nodejs/postcss",
"prosemirror-markdown": "1.9.1",
"prosemirror-model": "^1.18.1",
"prosemirror-state": "^1.4.1",
@@ -170,26 +170,25 @@
"style-loader": "^2.0.0",
"swagger-ui-dist": "4.12.0",
"three": "^0.143.0",
- "timeago.js": "^4.0.2",
+ "timeago.js": "link:/usr/share/nodejs/timeago.js",
"unified": "^10.1.2",
"unist-builder": "^3.0.0",
"unist-util-visit-parents": "^5.1.0",
"url-loader": "^4.1.1",
- "uuid": "8.1.0",
+ "uuid": "link:/usr/share/nodejs/uuid",
"visibilityjs": "^1.2.4",
- "vue": "2.6.14",
+ "vue": "link:/usr/share/nodejs/vue",
"vue-apollo": "^3.0.7",
"vue-loader": "15.9.6",
"vue-observe-visibility": "^1.0.0",
"vue-resize": "^1.0.1",
"vue-router": "3.4.9",
- "vue-template-compiler": "2.6.14",
+ "vue-template-compiler": "link:/usr/share/nodejs/vue-template-compiler",
"vue-virtual-scroll-list": "^1.4.7",
"vuedraggable": "^2.23.0",
"vuex": "^3.6.2",
"web-vitals": "^0.2.4",
"webpack": "^4.46.0",
- "webpack-bundle-analyzer": "^4.6.1",
"webpack-cli": "^4.10.0",
"webpack-stats-plugin": "^0.3.1",
"worker-loader": "^2.0.0",