@gravity-ui/app-builder 0.14.0-beta.4 → 0.14.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -49,6 +49,10 @@ async function default_1(config) {
49
49
  const startNodemon = () => {
50
50
  if (needToStartNodemon && serverCompiled && clientCompiled) {
51
51
  logger_1.default.message('Starting application at', serverPath);
52
+ const nodeArgs = ['--enable-source-maps'];
53
+ if (inspect || inspectBrk) {
54
+ nodeArgs.push(`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`);
55
+ }
52
56
  const serverWatch = config.server.watch ?? [];
53
57
  const delay = config.server.watchThrottle;
54
58
  const nodemonInstance = (0, nodemon_1.default)({
@@ -58,9 +62,7 @@ async function default_1(config) {
58
62
  env: {
59
63
  ...(config.server.port ? { APP_PORT: `${config.server.port}` } : undefined),
60
64
  },
61
- nodeArgs: inspect || inspectBrk
62
- ? [`--${inspect ? 'inspect' : 'inspect-brk'}=:::${inspect || inspectBrk}`]
63
- : undefined,
65
+ nodeArgs,
64
66
  watch: [serverPath, ...serverWatch],
65
67
  delay,
66
68
  });
@@ -10,7 +10,7 @@ function babelPreset(config) {
10
10
  bugfixes: true,
11
11
  targets: config.isSsr ? { node: 'current' } : undefined,
12
12
  },
13
- runtime: { version: '^7.13.10' },
13
+ runtime: { version: '^7.26.0' },
14
14
  typescript: true,
15
15
  react: {
16
16
  runtime: config.newJsxTransform ? 'automatic' : 'classic',
@@ -16,20 +16,6 @@ module.exports = function (_context, options = {}) {
16
16
  const isTypeScriptEnabled = getOption(options.typescript, false);
17
17
  const reactOptions = getOption(options.react, {});
18
18
  const presets = [
19
- [
20
- () => ({
21
- /**
22
- * Safari 15 has a buggy implementation of class properties,
23
- * but @babel/compat-data marks it as stable.
24
- * Can be removed once the issue is fixed and released.
25
- * @see https://github.com/babel/babel/issues/14289
26
- */
27
- plugins: [
28
- require.resolve('@babel/plugin-transform-private-methods'),
29
- require.resolve('@babel/plugin-transform-class-properties'),
30
- ],
31
- }),
32
- ],
33
19
  // Latest stable ECMAScript features
34
20
  (isEnvDevelopment || isEnvProduction) && [require.resolve('@babel/preset-env'), envOptions],
35
21
  // ES features necessary for current Node version
@@ -44,7 +44,6 @@ const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-re
44
44
  const moment_timezone_data_webpack_plugin_1 = __importDefault(require("moment-timezone-data-webpack-plugin"));
45
45
  const webpack_plugin_1 = __importDefault(require("@statoscope/webpack-plugin"));
46
46
  const circular_dependency_plugin_1 = __importDefault(require("circular-dependency-plugin"));
47
- const webpack_node_externals_1 = __importDefault(require("webpack-node-externals"));
48
47
  const paths_1 = __importDefault(require("../paths"));
49
48
  const babel_1 = require("../babel");
50
49
  const progress_plugin_1 = require("./progress-plugin");
@@ -52,6 +51,7 @@ const utils_1 = require("./utils");
52
51
  const s3_upload_1 = require("../s3-upload");
53
52
  const log_config_1 = require("../logger/log-config");
54
53
  const utils_2 = require("../typescript/utils");
54
+ const node_externals_1 = require("./node-externals");
55
55
  const imagesSizeLimit = 2048;
56
56
  const fontSizeLimit = 8192;
57
57
  async function webpackConfigFactory(webpackMode, config, { logger, isSsr = false } = {}) {
@@ -72,9 +72,9 @@ async function webpackConfigFactory(webpackMode, config, { logger, isSsr = false
72
72
  externals =
73
73
  config.ssr?.noExternal === true
74
74
  ? undefined
75
- : (0, webpack_node_externals_1.default)({
76
- allowlist: config.ssr?.noExternal,
77
- importType: config.ssr?.moduleType === 'esm' ? 'module' : 'commonjs',
75
+ : (0, node_externals_1.nodeExternals)({
76
+ noExternal: config.ssr?.noExternal,
77
+ module: config.ssr?.moduleType === 'esm',
78
78
  });
79
79
  }
80
80
  let webpackConfig = {
@@ -0,0 +1,8 @@
1
+ import type * as webpack from 'webpack';
2
+ type Pattern = RegExp | ((v: string) => boolean) | string;
3
+ export interface NodeExternalsOptions {
4
+ noExternal?: Pattern | Pattern[];
5
+ module?: boolean;
6
+ }
7
+ export declare function nodeExternals({ noExternal, module }: NodeExternalsOptions): (data: webpack.ExternalItemFunctionData) => Promise<string | undefined>;
8
+ export {};
@@ -0,0 +1,114 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.nodeExternals = nodeExternals;
30
+ const fs = __importStar(require("node:fs"));
31
+ const path = __importStar(require("node:path"));
32
+ const paths_1 = __importDefault(require("../paths"));
33
+ const webpackInternal = /^webpack\/container\/reference\//;
34
+ function nodeExternals({ noExternal = [], module }) {
35
+ const noExternals = Array().concat(webpackInternal).concat(noExternal);
36
+ const nodeModules = readPackagesNames(paths_1.default.appNodeModules);
37
+ return async (data) => {
38
+ const { request } = data;
39
+ if (!request) {
40
+ return undefined;
41
+ }
42
+ const moduleName = getModuleName(request);
43
+ if (!request ||
44
+ !containsPattern(nodeModules, moduleName) ||
45
+ containsPattern(noExternals, request)) {
46
+ return undefined;
47
+ }
48
+ if (!module) {
49
+ return `commonjs ${data.request}`;
50
+ }
51
+ if (data.dependencyType === 'commonjs' ||
52
+ // lodash/something without extension can't be imported so always require it
53
+ (moduleName === 'lodash' && request.match(/^lodash\/[\w_]+($|\/[\w_]+$)/))) {
54
+ return `node-commonjs ${data.request}`;
55
+ }
56
+ return `module-import ${data.request}`;
57
+ };
58
+ }
59
+ function readPackagesNames(dirName) {
60
+ if (!fs.existsSync(dirName)) {
61
+ return [];
62
+ }
63
+ try {
64
+ return fs
65
+ .readdirSync(dirName)
66
+ .map((module) => {
67
+ if (module.startsWith('.') ||
68
+ !fs.statSync(path.join(dirName, module)).isDirectory()) {
69
+ return undefined;
70
+ }
71
+ if (module.startsWith('@')) {
72
+ try {
73
+ return fs.readdirSync(path.join(dirName, module)).map(function (scopedMod) {
74
+ return module + '/' + scopedMod;
75
+ });
76
+ }
77
+ catch (e) {
78
+ return [module];
79
+ }
80
+ }
81
+ return module;
82
+ })
83
+ .flat()
84
+ .filter((v) => v !== undefined);
85
+ }
86
+ catch (e) {
87
+ return [];
88
+ }
89
+ }
90
+ function containsPattern(patterns, value) {
91
+ return patterns.some((pattern) => {
92
+ if (pattern instanceof RegExp) {
93
+ return pattern.test(value);
94
+ }
95
+ else if (typeof pattern === 'function') {
96
+ return pattern(value);
97
+ }
98
+ else {
99
+ return pattern === value;
100
+ }
101
+ });
102
+ }
103
+ function getModuleName(request) {
104
+ const req = request;
105
+ const delimiter = '/';
106
+ // check if scoped module
107
+ if (req.startsWith('@')) {
108
+ const parts = req.split(delimiter, 2);
109
+ if (parts.length === 2) {
110
+ return parts.join(delimiter);
111
+ }
112
+ }
113
+ return req.split(delimiter, 1)[0] || '';
114
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/app-builder",
3
- "version": "0.14.0-beta.4",
3
+ "version": "0.14.1",
4
4
  "description": "Develop and build your React client-server projects, powered by typescript and webpack",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -51,6 +51,7 @@
51
51
  "prettier": "prettier '**/*.{md,yaml,yml,json}'",
52
52
  "typecheck": "tsc --noEmit",
53
53
  "test": "jest",
54
+ "watch": "tsc -p tsconfig.production.json --watch",
54
55
  "build": "npm run build:clean && npm run build:compile",
55
56
  "build:compile": "tsc -p tsconfig.production.json",
56
57
  "build:clean": "rimraf dist",
@@ -58,17 +59,15 @@
58
59
  },
59
60
  "dependencies": {
60
61
  "@aws-sdk/client-s3": "^3.353.0",
61
- "@babel/core": "^7.25.0",
62
- "@babel/helper-plugin-utils": "^7.25.0",
63
- "@babel/plugin-transform-class-properties": "^7.25.0",
62
+ "@babel/core": "^7.26.0",
63
+ "@babel/helper-plugin-utils": "^7.26.0",
64
64
  "@babel/plugin-transform-dynamic-import": "^7.25.0",
65
- "@babel/plugin-transform-modules-commonjs": "^7.25.0",
66
- "@babel/plugin-transform-private-methods": "^7.25.0",
65
+ "@babel/plugin-transform-modules-commonjs": "^7.26.0",
67
66
  "@babel/plugin-transform-runtime": "^7.25.0",
68
- "@babel/preset-env": "^7.25.0",
69
- "@babel/preset-react": "^7.25.0",
70
- "@babel/preset-typescript": "^7.25.0",
71
- "@babel/runtime": "^7.25.0",
67
+ "@babel/preset-env": "^7.26.0",
68
+ "@babel/preset-react": "^7.26.0",
69
+ "@babel/preset-typescript": "^7.26.0",
70
+ "@babel/runtime": "^7.26.0",
72
71
  "@okikio/sharedworker": "^1.0.7",
73
72
  "@pmmmwh/react-refresh-webpack-plugin": "^0.5.15",
74
73
  "@statoscope/webpack-plugin": "^5.28.2",
@@ -129,7 +128,6 @@
129
128
  "webpack-bundle-analyzer": "^4.10.2",
130
129
  "webpack-dev-server": "^5.1.0",
131
130
  "webpack-manifest-plugin": "^5.0.0",
132
- "webpack-node-externals": "^3.0.0",
133
131
  "worker-loader": "^3.0.8",
134
132
  "yargs": "^17.7.2"
135
133
  },