Skip to content

Commit 49e3b2d

Browse files
committed
npm/node updates
Signed-off-by: Ryan Swanson <ryan.swanson@loft.sh>
1 parent 42028f9 commit 49e3b2d

20 files changed

Lines changed: 731 additions & 1022 deletions

File tree

.github/workflows/npm.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- uses: actions/checkout@v1
1616
- uses: actions/setup-node@v1
1717
with:
18-
node-version: 12
18+
node-version: 20
1919
registry-url: https://registry.npmjs.org/
2020
- run: |
2121
npm install -g
@@ -38,7 +38,7 @@ jobs:
3838
- uses: actions/checkout@v1
3939
- uses: actions/setup-node@v1
4040
with:
41-
node-version: 12
41+
node-version: 20
4242
registry-url: https://registry.npmjs.org/
4343
- run: |
4444
npm install -g

assets/assets.go

Lines changed: 124 additions & 46 deletions
Large diffs are not rendered by default.

dist/npm/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@ const execSync = require("child_process").execSync;
55
const fetch = require("node-fetch");
66
const Spinner = require("cli-spinner").Spinner;
77
const inquirer = require('inquirer');
8-
const findProcess = require('find-process');
8+
const findProcessModule = require('find-process');
9+
const findProcess =
10+
typeof findProcessModule === 'function'
11+
? findProcessModule
12+
: findProcessModule.default;
913

1014
const downloadPathTemplate =
1115
"https://github.com/devspace-sh/devspace/releases/download/v{{version}}/devspace-{{platform}}-{{arch}}";

hack/build-ui.bash

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
DEVSPACE_ROOT=$(git rev-parse --show-toplevel)
66

77
# Install dependencies
8-
cd ui && npm install && npm run build
8+
cd ui && npm install --legacy-peer-deps && npm run build
99

1010
# Pack ui
1111
echo "Packing ui"

ui/config/webpack.config.dev.js

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,13 @@ module.exports = {
8888
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
8989
'react-native': 'react-native-web',
9090
},
91+
fallback: {
92+
dgram: false,
93+
fs: false,
94+
net: false,
95+
tls: false,
96+
child_process: false,
97+
},
9198
plugins: [
9299
// Prevents users from importing files from outside of src/ (or node_modules/).
93100
// This often causes confusion because we only process files within src/ with babel.
@@ -150,7 +157,7 @@ module.exports = {
150157
},
151158
{
152159
test: /\.module\.s(a|c)ss$/,
153-
loader: [
160+
use: [
154161
require.resolve('style-loader'),
155162
// isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
156163
{
@@ -266,7 +273,10 @@ module.exports = {
266273
// solution that requires the user to opt into importing specific locales.
267274
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
268275
// You can remove this if you don't use Moment.js:
269-
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
276+
new webpack.IgnorePlugin({
277+
resourceRegExp: /^\.\/locale$/,
278+
contextRegExp: /moment$/,
279+
}),
270280
// Perform type checking and linting in a separate process to speed up compilation
271281
new ForkTsCheckerWebpackPlugin({
272282
async: false,
@@ -275,15 +285,6 @@ module.exports = {
275285
tslint: paths.appTsLint,
276286
}),
277287
],
278-
// Some libraries import Node modules but don't use them in the browser.
279-
// Tell Webpack to provide empty mocks for them so importing them works.
280-
node: {
281-
dgram: 'empty',
282-
fs: 'empty',
283-
net: 'empty',
284-
tls: 'empty',
285-
child_process: 'empty',
286-
},
287288
// Turn off performance hints during development because we don't do any
288289
// splitting or minification in interest of speed. These warnings become
289290
// cumbersome.

ui/config/webpack.config.prod.js

Lines changed: 46 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,7 @@ const autoprefixer = require('autoprefixer');
44
const path = require('path');
55
const webpack = require('webpack');
66
const HtmlWebpackPlugin = require('html-webpack-plugin');
7-
const ExtractTextPlugin = require('extract-text-webpack-plugin');
8-
const ManifestPlugin = require('webpack-manifest-plugin');
97
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
10-
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
118
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
129
const ForkTsCheckerWebpackPlugin = require('fork-ts-checker-webpack-plugin');
1310
const paths = require('./paths');
@@ -36,18 +33,6 @@ if (env.stringified['process.env'].NODE_ENV !== '"production"') {
3633
throw new Error('Production builds must have NODE_ENV=production.');
3734
}
3835

39-
// Note: defined here because it will be used more than once.
40-
const cssFilename = 'static/css/[name].[contenthash:8].css';
41-
42-
// ExtractTextPlugin expects the build output to be flat.
43-
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
44-
// However, our output is structured with css, js and media folders.
45-
// To have this structure working with relative paths, we have to use custom options.
46-
const extractTextPluginOptions = shouldUseRelativeAssetPaths
47-
? // Making sure that the publicPath goes back to to build folder.
48-
{ publicPath: Array(cssFilename.split('/').length).join('../') }
49-
: {};
50-
5136
// This is the production configuration.
5237
// It compiles slowly and is focused on producing a fast and minimal bundle.
5338
// The development configuration is different and lives in a separate file.
@@ -94,6 +79,13 @@ module.exports = {
9479
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
9580
'react-native': 'react-native-web',
9681
},
82+
fallback: {
83+
dgram: false,
84+
fs: false,
85+
net: false,
86+
tls: false,
87+
child_process: false,
88+
},
9789
plugins: [
9890
// Prevents users from importing files from outside of src/ (or node_modules/).
9991
// This often causes confusion because we only process files within src/ with babel.
@@ -156,7 +148,7 @@ module.exports = {
156148
},
157149
{
158150
test: /\.module\.s(a|c)ss$/,
159-
loader: [
151+
use: [
160152
require.resolve('style-loader'),
161153
// isDevelopment ? 'style-loader' : MiniCssExtractPlugin.loader,
162154
{
@@ -182,64 +174,46 @@ module.exports = {
182174
'sass-loader', // compiles Sass to CSS, using Node Sass by default
183175
],
184176
},
185-
// The notation here is somewhat confusing.
186177
// "postcss" loader applies autoprefixer to our CSS.
187178
// "css" loader resolves paths in CSS and adds assets as dependencies.
188-
// "style" loader normally turns CSS into JS modules injecting <style>,
189-
// but unlike in development configuration, we do something different.
190-
// `ExtractTextPlugin` first applies the "postcss" and "css" loaders
191-
// (second argument), then grabs the result CSS and puts it into a
192-
// separate file in our build process. This way we actually ship
193-
// a single CSS file in production instead of JS code injecting <style>
194-
// tags. If you use code splitting, however, any async bundles will still
195-
// use the "style" loader inside the async code so CSS from them won't be
196-
// in the main CSS file.
179+
// "style" loader turns CSS into JS modules that inject <style> tags.
197180
{
198181
test: /\.css$/,
199-
loader: ExtractTextPlugin.extract(
200-
Object.assign(
201-
{
202-
fallback: {
203-
loader: require.resolve('style-loader'),
204-
options: {
205-
hmr: false,
206-
},
207-
},
208-
use: [
209-
{
210-
loader: require.resolve('css-loader'),
211-
options: {
212-
importLoaders: 1,
213-
minimize: true,
214-
sourceMap: shouldUseSourceMap,
215-
},
216-
},
217-
{
218-
loader: require.resolve('postcss-loader'),
219-
options: {
220-
// Necessary for external CSS imports to work
221-
// https://github.com/facebookincubator/create-react-app/issues/2677
222-
ident: 'postcss',
223-
plugins: () => [
224-
require('postcss-flexbugs-fixes'),
225-
autoprefixer({
226-
browsers: [
227-
'>1%',
228-
'last 4 versions',
229-
'Firefox ESR',
230-
'not ie < 9', // React doesn't support IE8 anyway
231-
],
232-
flexbox: 'no-2009',
233-
}),
234-
],
235-
},
236-
},
182+
use: [
183+
{
184+
loader: require.resolve('style-loader'),
185+
options: {
186+
hmr: false,
187+
},
188+
},
189+
{
190+
loader: require.resolve('css-loader'),
191+
options: {
192+
importLoaders: 1,
193+
sourceMap: shouldUseSourceMap,
194+
},
195+
},
196+
{
197+
loader: require.resolve('postcss-loader'),
198+
options: {
199+
// Necessary for external CSS imports to work
200+
// https://github.com/facebookincubator/create-react-app/issues/2677
201+
ident: 'postcss',
202+
plugins: () => [
203+
require('postcss-flexbugs-fixes'),
204+
autoprefixer({
205+
browsers: [
206+
'>1%',
207+
'last 4 versions',
208+
'Firefox ESR',
209+
'not ie < 9', // React doesn't support IE8 anyway
210+
],
211+
flexbox: 'no-2009',
212+
}),
237213
],
238214
},
239-
extractTextPluginOptions
240-
)
241-
),
242-
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
215+
},
216+
],
243217
},
244218

245219
// "file" loader makes sure assets end up in the `build` folder.
@@ -328,69 +302,21 @@ module.exports = {
328302
// Use multi-process parallel running to improve the build speed
329303
// Default number of concurrent runs: os.cpus().length - 1
330304
parallel: true,
331-
// Enable file caching
332-
cache: true,
333-
sourceMap: shouldUseSourceMap,
334-
}), // Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
335-
new ExtractTextPlugin({
336-
filename: cssFilename,
337-
}),
338-
// Generate a manifest file which contains a mapping of all asset filenames
339-
// to their corresponding output file so that tools can pick it up without
340-
// having to parse `index.html`.
341-
new ManifestPlugin({
342-
fileName: 'asset-manifest.json',
343-
}),
344-
// Generate a service worker script that will precache, and keep up to date,
345-
// the HTML & assets that are part of the Webpack build.
346-
new SWPrecacheWebpackPlugin({
347-
// By default, a cache-busting query parameter is appended to requests
348-
// used to populate the caches, to ensure the responses are fresh.
349-
// If a URL is already hashed by Webpack, then there is no concern
350-
// about it being stale, and the cache-busting can be skipped.
351-
dontCacheBustUrlsMatching: /\.\w{8}\./,
352-
filename: 'service-worker.js',
353-
logger(message) {
354-
if (message.indexOf('Total precache size is') === 0) {
355-
// This message occurs for every build and is a bit too noisy.
356-
return;
357-
}
358-
if (message.indexOf('Skipping static resource') === 0) {
359-
// This message obscures real errors so we ignore it.
360-
// https://github.com/facebookincubator/create-react-app/issues/2612
361-
return;
362-
}
363-
console.log(message);
364-
},
365-
minify: true,
366-
// For unknown URLs, fallback to the index page
367-
navigateFallback: publicUrl + '/index.html',
368-
// Ignores URLs starting from /__ (useful for Firebase):
369-
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
370-
navigateFallbackWhitelist: [/^(?!\/__).*/],
371-
// Don't precache sourcemaps (they're large) and build asset manifest:
372-
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
373305
}),
374306
// Moment.js is an extremely popular library that bundles large locale files
375307
// by default due to how Webpack interprets its code. This is a practical
376308
// solution that requires the user to opt into importing specific locales.
377309
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
378310
// You can remove this if you don't use Moment.js:
379-
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
311+
new webpack.IgnorePlugin({
312+
resourceRegExp: /^\.\/locale$/,
313+
contextRegExp: /moment$/,
314+
}),
380315
// Perform type checking and linting in a separate process to speed up compilation
381316
new ForkTsCheckerWebpackPlugin({
382317
async: false,
383318
tsconfig: paths.appTsProdConfig,
384319
tslint: paths.appTsLint,
385320
}),
386321
],
387-
// Some libraries import Node modules but don't use them in the browser.
388-
// Tell Webpack to provide empty mocks for them so importing them works.
389-
node: {
390-
dgram: 'empty',
391-
fs: 'empty',
392-
net: 'empty',
393-
tls: 'empty',
394-
child_process: 'empty',
395-
},
396322
};

0 commit comments

Comments
 (0)