eddev 0.2.65 → 0.2.67-beta1

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.
Files changed (190) hide show
  1. package/admin/components/ImageWell.d.ts +2 -3
  2. package/admin/components/ImageWell.js +39 -51
  3. package/admin/defineField.d.ts +2 -2
  4. package/admin/defineWidget.d.ts +1 -1
  5. package/admin/defineWidget.js +2 -2
  6. package/admin/index.js +5 -1
  7. package/admin/installFieldTypes.js +26 -26
  8. package/admin/runWidgets.js +17 -28
  9. package/admin/selectMedia.d.ts +2 -2
  10. package/admin/selectMedia.js +1 -1
  11. package/blocks/ContentBlocks.d.ts +6 -6
  12. package/blocks/ContentBlocks.js +58 -66
  13. package/blocks/ErrorBoundaryEditor.d.ts +1 -1
  14. package/blocks/ErrorBoundaryEditor.js +16 -45
  15. package/blocks/ErrorBoundaryFrontend.d.ts +1 -1
  16. package/blocks/ErrorBoundaryFrontend.js +16 -45
  17. package/blocks/InspectorControls.d.ts +1 -1
  18. package/blocks/InspectorControls.js +3 -3
  19. package/blocks/blockAttributes.d.ts +2 -2
  20. package/blocks/blockAttributes.js +24 -44
  21. package/blocks/index.js +5 -1
  22. package/blocks/inlineEditing.d.ts +7 -7
  23. package/blocks/inlineEditing.js +36 -55
  24. package/blocks/installGutenbergHooks.js +48 -68
  25. package/build/babel/plugin-name-defined-components.js +15 -16
  26. package/build/build-favicon.js +11 -62
  27. package/build/clean.js +5 -52
  28. package/build/create-codegen-worker.js +78 -33
  29. package/build/create-serverless-dev-worker.js +61 -39
  30. package/build/create-webpack-worker.js +65 -33
  31. package/build/file-tree.d.ts +2 -2
  32. package/build/file-tree.js +12 -12
  33. package/build/get-webpack-config.js +341 -395
  34. package/build/graphql-codegen/graphql-codegen-files.js +31 -25
  35. package/build/graphql-codegen/graphql-codegen-no-duplicates.js +4 -4
  36. package/build/graphql-codegen/graphql-codegen-queries.js +102 -99
  37. package/build/manifests/manifest-blocks.d.ts +1 -1
  38. package/build/manifests/manifest-blocks.js +37 -29
  39. package/build/manifests/manifest-fields.d.ts +1 -1
  40. package/build/manifests/manifest-fields.js +23 -21
  41. package/build/manifests/manifest-views.d.ts +1 -1
  42. package/build/manifests/manifest-views.js +32 -25
  43. package/build/manifests/manifest-widgets.d.ts +1 -1
  44. package/build/manifests/manifest-widgets.js +22 -20
  45. package/build/manifests/manifest.d.ts +2 -2
  46. package/build/manifests/manifest.js +30 -90
  47. package/build/reporter.d.ts +1 -1
  48. package/build/reporter.js +29 -32
  49. package/build/serverless/create-next-app.d.ts +1 -1
  50. package/build/serverless/create-next-app.js +245 -467
  51. package/build/state/codegen-state.d.ts +4 -4
  52. package/build/state/compiler-state.d.ts +5 -5
  53. package/build/state/serverless-state.d.ts +3 -3
  54. package/build/workers/codegen-worker-script.js +392 -507
  55. package/build/workers/serverless-worker-dev-script.js +4 -4
  56. package/build/workers/webpack-worker-script.js +89 -150
  57. package/cli/build.dev.d.ts +1 -1
  58. package/cli/build.dev.js +79 -126
  59. package/cli/build.prod.d.ts +1 -1
  60. package/cli/build.prod.js +42 -98
  61. package/cli/cli.js +16 -55
  62. package/cli/display/components/BundleDisplay.d.ts +1 -2
  63. package/cli/display/components/BundleDisplay.js +13 -24
  64. package/cli/display/components/CodegenDisplay.d.ts +1 -2
  65. package/cli/display/components/CodegenDisplay.js +14 -25
  66. package/cli/display/components/DevCLIDisplay.d.ts +2 -3
  67. package/cli/display/components/DevCLIDisplay.js +14 -25
  68. package/cli/display/components/Fullscreen.js +9 -20
  69. package/cli/display/components/ServerlessDisplay.d.ts +2 -3
  70. package/cli/display/components/ServerlessDisplay.js +15 -26
  71. package/cli/display/components/StatusIcon.d.ts +2 -3
  72. package/cli/display/components/StatusIcon.js +3 -3
  73. package/cli/preinstall.js +4 -5
  74. package/cli/setup.js +25 -73
  75. package/components/AdminBar.d.ts +1 -2
  76. package/components/AdminBar.js +37 -3
  77. package/components/BrowserRouter.d.ts +2 -2
  78. package/components/BrowserRouter.js +41 -54
  79. package/components/InlinePage.d.ts +2 -2
  80. package/components/InlinePage.js +17 -29
  81. package/components/NextRouter.d.ts +2 -2
  82. package/components/NextRouter.js +20 -29
  83. package/components/index.js +5 -1
  84. package/config/config-schema.d.ts +1 -1
  85. package/config/config-schema.js +1 -1
  86. package/config/create-schema-file.js +6 -6
  87. package/config/get-config.js +10 -13
  88. package/config/index.js +5 -1
  89. package/config/parse-config.js +1 -1
  90. package/config/print-zod-errors.js +3 -3
  91. package/dev-ui/components/BreakpointColumnHeader.d.ts +2 -3
  92. package/dev-ui/components/BreakpointColumnHeader.js +7 -18
  93. package/dev-ui/components/BreakpointIndicator.d.ts +1 -2
  94. package/dev-ui/components/BreakpointIndicator.js +25 -32
  95. package/dev-ui/components/DevUI.d.ts +1 -2
  96. package/dev-ui/components/DevUI.js +13 -13
  97. package/dev-ui/components/Launcher.d.ts +2 -2
  98. package/dev-ui/components/Launcher.js +13 -25
  99. package/dev-ui/components/PanelWrapper.d.ts +2 -2
  100. package/dev-ui/components/PanelWrapper.js +8 -8
  101. package/dev-ui/components/ResponsiveLerpControl.d.ts +2 -3
  102. package/dev-ui/components/ResponsiveLerpControl.js +27 -38
  103. package/dev-ui/components/ResponsiveScaleEditor.d.ts +4 -5
  104. package/dev-ui/components/ResponsiveScaleEditor.js +64 -78
  105. package/dev-ui/components/atoms/Button.js +1 -1
  106. package/dev-ui/components/atoms/Dropdown.d.ts +3 -3
  107. package/dev-ui/components/atoms/Dropdown.js +8 -9
  108. package/dev-ui/components/atoms/NumberField.d.ts +2 -3
  109. package/dev-ui/components/atoms/NumberField.js +29 -42
  110. package/dev-ui/components/atoms/Spacer.js +1 -1
  111. package/dev-ui/components/atoms/Text.js +1 -1
  112. package/dev-ui/components/atoms/ToggleButton.d.ts +2 -2
  113. package/dev-ui/components/atoms/ToggleButton.js +5 -16
  114. package/dev-ui/components/atoms/Tooltip.d.ts +2 -2
  115. package/dev-ui/components/atoms/Tooltip.js +8 -20
  116. package/dev-ui/components/panels/AppDataDebugger.d.ts +1 -2
  117. package/dev-ui/components/panels/AppDataDebugger.js +8 -19
  118. package/dev-ui/components/panels/ColorEditor.d.ts +1 -2
  119. package/dev-ui/components/panels/ColorEditor.js +35 -42
  120. package/dev-ui/components/panels/PageDataDebugger.d.ts +1 -2
  121. package/dev-ui/components/panels/PageDataDebugger.js +8 -20
  122. package/dev-ui/components/panels/QueryDebugger.d.ts +1 -2
  123. package/dev-ui/components/panels/QueryDebugger.js +12 -24
  124. package/dev-ui/components/panels/SpacingEditor.d.ts +1 -2
  125. package/dev-ui/components/panels/SpacingEditor.js +34 -48
  126. package/dev-ui/components/panels/TypographyEditor.d.ts +1 -2
  127. package/dev-ui/components/panels/TypographyEditor.js +38 -46
  128. package/dev-ui/hooks/useBreakpoint.d.ts +1 -1
  129. package/dev-ui/hooks/useBreakpoint.js +13 -13
  130. package/dev-ui/hooks/usePersistState.js +6 -7
  131. package/dev-ui/hooks/useStylesheet.js +6 -6
  132. package/dev-ui/icons.d.ts +15 -16
  133. package/dev-ui/icons.js +16 -27
  134. package/dev-ui/index.js +5 -1
  135. package/dev-ui/loader.d.ts +1 -2
  136. package/dev-ui/loader.js +13 -9
  137. package/dev-ui/panels.d.ts +2 -2
  138. package/dev-ui/panels.js +7 -7
  139. package/dev-ui/theme.d.ts +96 -70
  140. package/dev-ui/theme.js +3 -3
  141. package/dynamic/dynamic-component.d.ts +1 -10
  142. package/dynamic/dynamic-component.js +1 -1
  143. package/dynamic/index.js +5 -1
  144. package/entry/Root.d.ts +2 -3
  145. package/entry/Root.js +16 -26
  146. package/entry/entry.admin.dev.js +4 -4
  147. package/entry/entry.admin.prod.js +4 -4
  148. package/entry/entry.monolith.dev.js +5 -5
  149. package/entry/entry.monolith.prod.js +5 -5
  150. package/gravityforms/gravity-forms.d.ts +2 -2
  151. package/gravityforms/index.js +5 -1
  152. package/gravityforms/useGravityForm.d.ts +2 -2
  153. package/gravityforms/useGravityForm.js +126 -130
  154. package/hooks/index.js +5 -1
  155. package/hooks/queryUtils.d.ts +14 -14
  156. package/hooks/queryUtils.js +101 -192
  157. package/hooks/useAppData.d.ts +2 -2
  158. package/hooks/useAppData.js +9 -9
  159. package/hooks/usePageLoad.js +4 -4
  160. package/hooks/useQueryDebug.d.ts +1 -1
  161. package/hooks/useQueryDebug.js +7 -7
  162. package/hooks/useRPC.d.ts +4 -4
  163. package/hooks/useRPC.js +3 -3
  164. package/package.json +7 -7
  165. package/routing/index.js +5 -1
  166. package/routing/remoteProps.d.ts +1 -1
  167. package/routing/remoteProps.js +31 -72
  168. package/routing/routing.d.ts +15 -15
  169. package/routing/routing.js +108 -170
  170. package/routing/updateEditLink.js +1 -1
  171. package/serverless/define-api.d.ts +1 -1
  172. package/serverless/define-rpc-router.js +8 -4
  173. package/serverless/index.js +6 -2
  174. package/serverless-template/_utils/fetch-wordpress-props.ts +0 -4
  175. package/serverless-template/_utils/fetch-wp.ts +0 -1
  176. package/style/createStitches.d.ts +375 -783
  177. package/style/createStitches.js +164 -142
  178. package/style/index.js +5 -1
  179. package/tsconfig.json +1 -1
  180. package/utils/Observable.d.ts +2 -2
  181. package/utils/Observable.js +12 -15
  182. package/utils/getRepoName.js +3 -3
  183. package/utils/promptIfRepoNameIncorrect.js +18 -64
  184. package/utils/refreshOverlayInterop.js +1 -1
  185. package/utils/reportErrorStack.d.ts +1 -1
  186. package/utils/reportErrorStack.js +1 -1
  187. package/utils/serverlessAppContext.js +1 -1
  188. package/utils/updateEnvFile.js +19 -69
  189. package/utils/useObservable.js +3 -3
  190. package/views/index.js +5 -1
@@ -1,414 +1,360 @@
1
1
  "use strict";
2
- var __assign = (this && this.__assign) || function () {
3
- __assign = Object.assign || function(t) {
4
- for (var s, i = 1, n = arguments.length; i < n; i++) {
5
- s = arguments[i];
6
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
- t[p] = s[p];
8
- }
9
- return t;
10
- };
11
- return __assign.apply(this, arguments);
12
- };
13
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
22
- var __generator = (this && this.__generator) || function (thisArg, body) {
23
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
- function verb(n) { return function (v) { return step([n, v]); }; }
26
- function step(op) {
27
- if (f) throw new TypeError("Generator is already executing.");
28
- while (_) try {
29
- if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
30
- if (y = 0, t) op = [op[0] & 2, t.value];
31
- switch (op[0]) {
32
- case 0: case 1: t = op; break;
33
- case 4: _.label++; return { value: op[1], done: false };
34
- case 5: _.label++; y = op[1]; op = [0]; continue;
35
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
- default:
37
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
- if (t[2]) _.ops.pop();
42
- _.trys.pop(); continue;
43
- }
44
- op = body.call(thisArg, _);
45
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
- }
48
- };
49
- var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
50
- if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
51
- if (ar || !(i in from)) {
52
- if (!ar) ar = Array.prototype.slice.call(from, 0, i);
53
- ar[i] = from[i];
54
- }
55
- }
56
- return to.concat(ar || Array.prototype.slice.call(from));
57
- };
58
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
59
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
60
4
  };
61
5
  Object.defineProperty(exports, "__esModule", { value: true });
62
- var webpack_1 = require("webpack");
63
- var path_1 = __importDefault(require("path"));
64
- var react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
65
- var webpack_virtual_modules_1 = __importDefault(require("webpack-virtual-modules"));
6
+ const webpack_1 = require("webpack");
7
+ const path_1 = __importDefault(require("path"));
8
+ const react_refresh_webpack_plugin_1 = __importDefault(require("@pmmmwh/react-refresh-webpack-plugin"));
9
+ const webpack_virtual_modules_1 = __importDefault(require("webpack-virtual-modules"));
66
10
  // @ts-ignore
67
- var friendly_errors_webpack_plugin_1 = __importDefault(require("@soda/friendly-errors-webpack-plugin"));
11
+ const friendly_errors_webpack_plugin_1 = __importDefault(require("@soda/friendly-errors-webpack-plugin"));
68
12
  // @ts-ignore
69
- var webpack_plugin_1 = __importDefault(require("@loadable/webpack-plugin"));
13
+ const webpack_plugin_1 = __importDefault(require("@loadable/webpack-plugin"));
70
14
  // @ts-ignore
71
- var webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
15
+ const webpack_bundle_analyzer_1 = require("webpack-bundle-analyzer");
72
16
  // @ts-ignore
73
- var mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
74
- var autoprefixer_1 = __importDefault(require("autoprefixer"));
17
+ const mini_css_extract_plugin_1 = __importDefault(require("mini-css-extract-plugin"));
18
+ const autoprefixer_1 = __importDefault(require("autoprefixer"));
75
19
  // Custom Babel plugins
76
- var plugin_name_defined_components_1 = __importDefault(require("./babel/plugin-name-defined-components"));
77
- var fs_1 = require("fs");
78
- var manifest_blocks_1 = require("./manifests/manifest-blocks");
79
- var manifest_fields_1 = require("./manifests/manifest-fields");
80
- var manifest_views_1 = require("./manifests/manifest-views");
81
- var get_config_1 = require("../config/get-config");
82
- var manifest_widgets_1 = require("./manifests/manifest-widgets");
83
- function getWebpackConfig(opts) {
84
- return __awaiter(this, void 0, void 0, function () {
85
- var compiling, config, ALIAS, ENTRY, PLUGINS, RULES, DEFINES, VIRTUAL_MODULES, EXTERNALS, virtualModules, isServerless, isBrowser, isSSR, isDev, entryDir, distSuffix, outputFolder, loadableManifestFile, writeVirtualModule, manifestLoaders, rpcExists, buildID;
86
- return __generator(this, function (_a) {
87
- switch (_a.label) {
88
- case 0:
89
- compiling = false;
90
- config = (0, get_config_1.getEDConfigUnwrapped)();
91
- ALIAS = {};
92
- ENTRY = {};
93
- PLUGINS = [];
94
- RULES = [];
95
- DEFINES = {};
96
- VIRTUAL_MODULES = {};
97
- EXTERNALS = {};
98
- isServerless = opts.serverless;
99
- isBrowser = opts.target === "client";
100
- isSSR = isServerless && !isBrowser;
101
- isDev = opts.mode === "development";
102
- entryDir = path_1.default.resolve(path_1.default.dirname(__dirname), "./entry");
103
- if (isDev) {
104
- if (opts.isAdmin) {
105
- ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.admin.dev.js")];
106
- }
107
- else if (isServerless) {
108
- ENTRY["main"] = ["".concat(entryDir, "/entry.serverless.dev.js")];
109
- }
110
- else {
111
- ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.monolith.dev.js")];
112
- }
113
- }
114
- else {
115
- if (opts.isAdmin) {
116
- ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.admin.prod.js")];
117
- }
118
- else if (isServerless) {
119
- ENTRY["main"] = ["".concat(entryDir, "/entry.serverless.prod.js")];
120
- }
121
- else {
122
- ENTRY["main"] = ["".concat(entryDir, "/entry.publicPath.js"), "".concat(entryDir, "/entry.monolith.prod.js")];
123
- }
124
- }
125
- distSuffix = opts.isAdmin ? "admin" : "frontend";
126
- outputFolder = path_1.default.resolve(opts.baseDirectory, isServerless ? (isDev ? "./.edwp/dev" : "./.edwp/prod") : "./dist/" + distSuffix);
127
- loadableManifestFile = "loadable-stats.json";
128
- // JS/TS
129
- ALIAS["@blocks"] = path_1.default.join(opts.baseDirectory, "blocks");
130
- ALIAS["@components"] = path_1.default.join(opts.baseDirectory, "components");
131
- ALIAS["@views"] = path_1.default.join(opts.baseDirectory, "views");
132
- ALIAS["@hooks"] = path_1.default.join(opts.baseDirectory, "hooks");
133
- ALIAS["@lib"] = path_1.default.join(opts.baseDirectory, "lib");
134
- ALIAS["@queries"] = path_1.default.join(opts.baseDirectory, "hooks/queries");
135
- ALIAS["@utils"] = path_1.default.join(opts.baseDirectory, "utils");
136
- RULES.push({
137
- test: /\.[jt]sx?$/,
138
- exclude: /node_modules/,
139
- use: [
20
+ const plugin_name_defined_components_1 = __importDefault(require("./babel/plugin-name-defined-components"));
21
+ const fs_1 = require("fs");
22
+ const manifest_blocks_1 = require("./manifests/manifest-blocks");
23
+ const manifest_fields_1 = require("./manifests/manifest-fields");
24
+ const manifest_views_1 = require("./manifests/manifest-views");
25
+ const get_config_1 = require("../config/get-config");
26
+ const manifest_widgets_1 = require("./manifests/manifest-widgets");
27
+ async function getWebpackConfig(opts) {
28
+ let compiling = false;
29
+ const config = (0, get_config_1.getEDConfigUnwrapped)();
30
+ // Webpack config
31
+ const ALIAS = {};
32
+ const ENTRY = {};
33
+ const PLUGINS = [];
34
+ const RULES = [];
35
+ const DEFINES = {};
36
+ const VIRTUAL_MODULES = {};
37
+ const EXTERNALS = {};
38
+ // Initialize the virtual modules plugin
39
+ let virtualModules;
40
+ // Helpful calculations
41
+ const isServerless = opts.serverless;
42
+ const isBrowser = opts.target === "client";
43
+ const isSSR = isServerless && !isBrowser;
44
+ const isDev = opts.mode === "development";
45
+ // Entry points
46
+ const entryDir = path_1.default.resolve(path_1.default.dirname(__dirname), "./entry");
47
+ if (isDev) {
48
+ if (opts.isAdmin) {
49
+ ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.admin.dev.js`];
50
+ }
51
+ else if (isServerless) {
52
+ ENTRY["main"] = [`${entryDir}/entry.serverless.dev.js`];
53
+ }
54
+ else {
55
+ ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.monolith.dev.js`];
56
+ }
57
+ }
58
+ else {
59
+ if (opts.isAdmin) {
60
+ ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.admin.prod.js`];
61
+ }
62
+ else if (isServerless) {
63
+ ENTRY["main"] = [`${entryDir}/entry.serverless.prod.js`];
64
+ }
65
+ else {
66
+ ENTRY["main"] = [`${entryDir}/entry.publicPath.js`, `${entryDir}/entry.monolith.prod.js`];
67
+ }
68
+ }
69
+ // Admin entry
70
+ // Determine output file placement
71
+ const distSuffix = opts.isAdmin ? "admin" : "frontend";
72
+ const outputFolder = path_1.default.resolve(opts.baseDirectory, isServerless ? (isDev ? "./.edwp/dev" : "./.edwp/prod") : "./dist/" + distSuffix);
73
+ const loadableManifestFile = `loadable-stats.json`;
74
+ // JS/TS
75
+ ALIAS["@blocks"] = path_1.default.join(opts.baseDirectory, "blocks");
76
+ ALIAS["@components"] = path_1.default.join(opts.baseDirectory, "components");
77
+ ALIAS["@views"] = path_1.default.join(opts.baseDirectory, "views");
78
+ ALIAS["@hooks"] = path_1.default.join(opts.baseDirectory, "hooks");
79
+ ALIAS["@lib"] = path_1.default.join(opts.baseDirectory, "lib");
80
+ ALIAS["@queries"] = path_1.default.join(opts.baseDirectory, "hooks/queries");
81
+ ALIAS["@utils"] = path_1.default.join(opts.baseDirectory, "utils");
82
+ RULES.push({
83
+ test: /\.[jt]sx?$/,
84
+ exclude: /node_modules/,
85
+ use: [
86
+ {
87
+ loader: require.resolve("babel-loader"),
88
+ options: {
89
+ presets: [
90
+ [
91
+ require.resolve("@babel/preset-env"),
140
92
  {
141
- loader: require.resolve("babel-loader"),
142
- options: {
143
- presets: [
144
- [
145
- require.resolve("@babel/preset-env"),
146
- {
147
- useBuiltIns: "entry",
148
- exclude: ["@babel/plugin-transform-regenerator"],
149
- targets: "> 0.25%, not dead",
150
- corejs: 3,
151
- },
152
- ],
153
- [
154
- require.resolve("@babel/preset-react"),
155
- {
156
- runtime: "automatic",
157
- },
158
- ],
159
- require.resolve("@babel/preset-typescript"),
160
- ],
161
- plugins: [
162
- [plugin_name_defined_components_1.default, { baseDirectory: opts.baseDirectory, cool: true }],
163
- isBrowser && isDev && !opts.isAdmin && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
164
- require.resolve("@loadable/babel-plugin"),
165
- ].filter(Boolean),
166
- },
93
+ useBuiltIns: "entry",
94
+ exclude: ["@babel/plugin-transform-regenerator"],
95
+ targets: "> 0.25%, not dead",
96
+ corejs: 3,
167
97
  },
168
98
  ],
169
- });
170
- // Styling
171
- ALIAS["@styles"] = path_1.default.join(opts.baseDirectory, "styles");
172
- ALIAS["@theme"] = path_1.default.join(opts.baseDirectory, "theme.css.tsx");
173
- PLUGINS.push(new mini_css_extract_plugin_1.default());
174
- RULES.push({
175
- test: /\.(sa|sc|c)ss$/,
176
- use: [
177
- {
178
- loader: mini_css_extract_plugin_1.default.loader,
179
- options: {
180
- publicPath: "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix),
181
- },
182
- },
183
- {
184
- loader: require.resolve("css-loader"),
185
- options: {
186
- import: true,
187
- // sourceMap: true,
188
- importLoaders: 2,
189
- // modules: true,
190
- },
191
- },
99
+ [
100
+ require.resolve("@babel/preset-react"),
192
101
  {
193
- loader: require.resolve("postcss-loader"),
194
- options: {
195
- postcssOptions: {
196
- ident: "postcss",
197
- sourceMap: true,
198
- plugins: [(0, autoprefixer_1.default)()],
199
- },
200
- },
102
+ runtime: "automatic",
201
103
  },
202
104
  ],
203
- });
204
- // Bundle analyser
205
- if (!opts.isAdmin && !isDev) {
206
- PLUGINS.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
207
- analyzerMode: "static",
208
- openAnalyzer: false,
209
- reportFilename: "./bundle-report.html",
210
- }));
211
- }
212
- // React Refresh
213
- if (isBrowser && isDev && !opts.isAdmin) {
214
- PLUGINS.push(new react_refresh_webpack_plugin_1.default({
215
- overlay: {
216
- // module: require.resolve("../utils/refreshOverlayInterop"),
217
- // @ts-ignore
218
- // sockProtocol: "http",
219
- sockHost: "127.0.0.1",
220
- sockPort: opts.hotPort,
221
- sockIntegration: "wds",
222
- },
223
- }));
224
- }
225
- // Loadable plugin for code-splitting
226
- if (isBrowser)
227
- PLUGINS.push(new webpack_plugin_1.default({
228
- filename: loadableManifestFile,
229
- writeToDisk: true,
230
- }));
231
- // Predefined values, good data injection
232
- PLUGINS.push(new webpack_1.DefinePlugin(DEFINES));
233
- // Errors
234
- if (!isDev) {
235
- PLUGINS.push(new friendly_errors_webpack_plugin_1.default({
236
- clearConsole: false,
237
- }));
238
- }
239
- if (isDev) {
240
- // PLUGINS.push(new ErrorOverlayPlugin())
241
- }
242
- // Virtual modules, for code injection
243
- virtualModules = new webpack_virtual_modules_1.default(VIRTUAL_MODULES);
244
- PLUGINS.push(virtualModules);
245
- writeVirtualModule = function (name, contents) {
246
- if (compiling) {
247
- virtualModules.writeModule(name, contents);
248
- }
249
- else {
250
- VIRTUAL_MODULES[name] = contents;
251
- }
252
- };
253
- manifestLoaders = [];
254
- // Views
255
- ALIAS["@manifest/views"] = path_1.default.resolve(opts.baseDirectory, "_view_manifest.js");
256
- if (opts.isAdmin) {
257
- writeVirtualModule(ALIAS["@manifest/views"], "export default {}");
258
- }
259
- else {
260
- manifestLoaders.push((0, manifest_views_1.createViewManifestGenerator)({
261
- baseDirectory: opts.baseDirectory,
262
- isAdmin: false,
263
- isDev: isDev,
264
- isServerless: isServerless,
265
- watch: isDev,
266
- onGenerate: function (manifest) {
267
- writeVirtualModule(ALIAS["@manifest/views"], manifest);
268
- },
269
- }));
270
- }
271
- // Field manifest
272
- ALIAS["@manifest/fields"] = path_1.default.resolve(opts.baseDirectory, "_fields_manifest.js");
273
- if (opts.isAdmin) {
274
- manifestLoaders.push((0, manifest_fields_1.createFieldManifestGenerator)({
275
- baseDirectory: opts.baseDirectory,
276
- isAdmin: true,
277
- isDev: isDev,
278
- isServerless: isServerless,
279
- watch: isDev,
280
- onGenerate: function (manifest) {
281
- writeVirtualModule(ALIAS["@manifest/fields"], manifest);
282
- },
283
- }));
284
- }
285
- else {
286
- writeVirtualModule(ALIAS["@manifest/fields"], "\n export default {}\n ");
287
- }
288
- // Field manifest
289
- ALIAS["@manifest/widgets"] = path_1.default.resolve(opts.baseDirectory, "_widgets_manifest.js");
290
- if (opts.isAdmin) {
291
- manifestLoaders.push((0, manifest_widgets_1.createWidgetManifestGenerator)({
292
- baseDirectory: opts.baseDirectory,
293
- isAdmin: true,
294
- isDev: isDev,
295
- isServerless: isServerless,
296
- watch: isDev,
297
- onGenerate: function (manifest) {
298
- writeVirtualModule(ALIAS["@manifest/widgets"], manifest);
299
- },
300
- }));
301
- }
302
- else {
303
- writeVirtualModule(ALIAS["@manifest/widgets"], "\n export default {}\n ");
304
- }
305
- // Block manifest
306
- ALIAS["@manifest/blocks"] = path_1.default.resolve(opts.baseDirectory, "_blocks_manifest.js");
307
- manifestLoaders.push((0, manifest_blocks_1.createBlockManifestGenerator)({
308
- baseDirectory: opts.baseDirectory,
309
- isAdmin: opts.isAdmin,
310
- isDev: isDev,
311
- isServerless: isServerless,
312
- watch: isDev,
313
- onGenerate: function (manifest) {
314
- writeVirtualModule(ALIAS["@manifest/blocks"], manifest);
315
- },
316
- }));
317
- // Wait for all manifests to resolve
318
- return [4 /*yield*/, Promise.all(manifestLoaders)
319
- // External Gutenberg
320
- ];
321
- case 1:
322
- // Wait for all manifests to resolve
323
- _a.sent();
324
- // External Gutenberg
325
- EXTERNALS["@wordpress/components"] = ["window", "wp"];
326
- EXTERNALS["@wordpress/element"] = ["window", "wp"];
327
- EXTERNALS["@wordpress/blocks"] = ["window", "wp"];
328
- EXTERNALS["@wordpress/utils"] = ["window", "wp"];
329
- EXTERNALS["@wordpress/data"] = ["window", "wp"];
330
- EXTERNALS["@wordpress/hooks"] = ["window", "wp"];
331
- EXTERNALS["@wordpress/block-editor"] = ["window", "wp"];
332
- if (opts.isAdmin) {
333
- EXTERNALS["@wordpress/components"] = ["wp", "components"];
334
- EXTERNALS["@wordpress/element"] = ["wp", "element"];
335
- EXTERNALS["@wordpress/blocks"] = ["wp", "blocks"];
336
- EXTERNALS["@wordpress/utils"] = ["wp", "utils"];
337
- EXTERNALS["@wordpress/data"] = ["wp", "data"];
338
- EXTERNALS["@wordpress/hooks"] = ["wp", "hooks"];
339
- EXTERNALS["@wordpress/block-editor"] = ["wp", "blockEditor"];
340
- EXTERNALS["react"] = "React";
341
- EXTERNALS["react-dom"] = "ReactDOM";
342
- }
343
- // Define some values
344
- DEFINES["process.browser"] = JSON.stringify(isBrowser);
345
- DEFINES["process.client"] = JSON.stringify(isBrowser);
346
- DEFINES["process.serverless"] = "false";
347
- DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
348
- DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
349
- DEFINES["process.dev"] = isDev ? "true" : "false";
350
- DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
351
- DEFINES["process.env.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
352
- DEFINES["process.themePath"] = JSON.stringify("/wp-content/themes/".concat(opts.themeName));
353
- if (isDev && opts.isAdmin) {
354
- DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
355
- }
356
- DEFINES["process.devUI"] = config.devUI === "enabled";
357
- DEFINES["process.serverlessEndpoint"] = "(window.SERVERLESS_ENDPOINT || '')";
358
- rpcExists = (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc.ts")) ||
359
- (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc/index.ts"));
360
- DEFINES["process.rpcEnabled"] = rpcExists ? "true" : "false";
361
- if (isBrowser) {
362
- DEFINES["process.env.themePath"] = "window.THEME_PATH || ".concat(DEFINES["process.env.themePath"]);
363
- }
364
- buildID = Date.now();
365
- return [2 /*return*/, {
366
- mode: opts.mode,
367
- context: opts.baseDirectory,
368
- target: opts.target === "ssr" ? "node" : "web",
369
- optimization: {
370
- splitChunks: {
371
- chunks: "async",
372
- },
373
- minimize: opts.mode === "production",
374
- // chunkIds: "named",
375
- },
376
- output: {
377
- filename: "[name].".concat(opts.isAdmin ? "admin" : "frontend", ".js?v=").concat(buildID),
378
- chunkFilename: "[name].".concat(opts.isAdmin ? "admin" : "frontend", ".js?v=").concat(buildID),
379
- publicPath: "/wp-content/themes/".concat(opts.themeName, "/dist/").concat(distSuffix, "/"),
380
- path: outputFolder,
381
- globalObject: isSSR ? "this" : "self",
382
- clean: true,
383
- },
384
- externals: __assign({ worker_threads: true }, EXTERNALS),
385
- resolve: {
386
- alias: ALIAS,
387
- extensions: [".js", ".jsx", ".ts", ".tsx"],
388
- },
389
- entry: ENTRY,
390
- plugins: __spreadArray(__spreadArray([], PLUGINS, true), [
391
- function () {
392
- compiling = true;
393
- },
394
- ], false),
395
- module: {
396
- rules: RULES,
397
- },
398
- devtool: opts.mode === "development" && opts.target === "client"
399
- ? opts.mode === "development"
400
- ? "cheap-module-source-map"
401
- : "source-map"
402
- : false,
403
- stats: {
404
- all: true,
405
- errorDetails: true,
406
- errors: true,
407
- colors: true,
408
- },
409
- }];
410
- }
411
- });
105
+ require.resolve("@babel/preset-typescript"),
106
+ ],
107
+ plugins: [
108
+ [plugin_name_defined_components_1.default, { baseDirectory: opts.baseDirectory, cool: true }],
109
+ isBrowser && isDev && !opts.isAdmin && [require.resolve("react-refresh/babel"), { skipEnvCheck: true }],
110
+ require.resolve("@loadable/babel-plugin"),
111
+ ].filter(Boolean),
112
+ },
113
+ },
114
+ ],
412
115
  });
116
+ // Styling
117
+ ALIAS["@styles"] = path_1.default.join(opts.baseDirectory, "styles");
118
+ ALIAS["@theme"] = path_1.default.join(opts.baseDirectory, "theme.css.tsx");
119
+ PLUGINS.push(new mini_css_extract_plugin_1.default());
120
+ RULES.push({
121
+ test: /\.(sa|sc|c)ss$/,
122
+ use: [
123
+ {
124
+ loader: mini_css_extract_plugin_1.default.loader,
125
+ options: {
126
+ publicPath: `/wp-content/themes/${opts.themeName}/dist/${distSuffix}`,
127
+ },
128
+ },
129
+ {
130
+ loader: require.resolve("css-loader"),
131
+ options: {
132
+ import: true,
133
+ // sourceMap: true,
134
+ importLoaders: 2,
135
+ // modules: true,
136
+ },
137
+ },
138
+ {
139
+ loader: require.resolve("postcss-loader"),
140
+ options: {
141
+ postcssOptions: {
142
+ ident: "postcss",
143
+ sourceMap: true,
144
+ plugins: [(0, autoprefixer_1.default)()],
145
+ },
146
+ },
147
+ },
148
+ ],
149
+ });
150
+ // Bundle analyser
151
+ if (!opts.isAdmin && !isDev) {
152
+ PLUGINS.push(new webpack_bundle_analyzer_1.BundleAnalyzerPlugin({
153
+ analyzerMode: "static",
154
+ openAnalyzer: false,
155
+ reportFilename: "./bundle-report.html",
156
+ }));
157
+ }
158
+ // React Refresh
159
+ if (isBrowser && isDev && !opts.isAdmin) {
160
+ PLUGINS.push(new react_refresh_webpack_plugin_1.default({
161
+ overlay: {
162
+ // module: require.resolve("../utils/refreshOverlayInterop"),
163
+ // @ts-ignore
164
+ // sockProtocol: "http",
165
+ sockHost: "127.0.0.1",
166
+ sockPort: opts.hotPort,
167
+ sockIntegration: "wds",
168
+ },
169
+ }));
170
+ }
171
+ // Loadable plugin for code-splitting
172
+ if (isBrowser)
173
+ PLUGINS.push(new webpack_plugin_1.default({
174
+ filename: loadableManifestFile,
175
+ writeToDisk: true,
176
+ }));
177
+ // Predefined values, good data injection
178
+ PLUGINS.push(new webpack_1.DefinePlugin(DEFINES));
179
+ // Errors
180
+ if (!isDev) {
181
+ PLUGINS.push(new friendly_errors_webpack_plugin_1.default({
182
+ clearConsole: false,
183
+ }));
184
+ }
185
+ if (isDev) {
186
+ // PLUGINS.push(new ErrorOverlayPlugin())
187
+ }
188
+ // Virtual modules, for code injection
189
+ virtualModules = new webpack_virtual_modules_1.default(VIRTUAL_MODULES);
190
+ PLUGINS.push(virtualModules);
191
+ const writeVirtualModule = (name, contents) => {
192
+ if (compiling) {
193
+ virtualModules.writeModule(name, contents);
194
+ }
195
+ else {
196
+ VIRTUAL_MODULES[name] = contents;
197
+ }
198
+ };
199
+ const manifestLoaders = [];
200
+ // Views
201
+ ALIAS["@manifest/views"] = path_1.default.resolve(opts.baseDirectory, "_view_manifest.js");
202
+ if (opts.isAdmin) {
203
+ writeVirtualModule(ALIAS["@manifest/views"], `export default {}`);
204
+ }
205
+ else {
206
+ manifestLoaders.push((0, manifest_views_1.createViewManifestGenerator)({
207
+ baseDirectory: opts.baseDirectory,
208
+ isAdmin: false,
209
+ isDev: isDev,
210
+ isServerless: isServerless,
211
+ watch: isDev,
212
+ onGenerate: (manifest) => {
213
+ writeVirtualModule(ALIAS["@manifest/views"], manifest);
214
+ },
215
+ }));
216
+ }
217
+ // Field manifest
218
+ ALIAS["@manifest/fields"] = path_1.default.resolve(opts.baseDirectory, "_fields_manifest.js");
219
+ if (opts.isAdmin) {
220
+ manifestLoaders.push((0, manifest_fields_1.createFieldManifestGenerator)({
221
+ baseDirectory: opts.baseDirectory,
222
+ isAdmin: true,
223
+ isDev: isDev,
224
+ isServerless: isServerless,
225
+ watch: isDev,
226
+ onGenerate: (manifest) => {
227
+ writeVirtualModule(ALIAS["@manifest/fields"], manifest);
228
+ },
229
+ }));
230
+ }
231
+ else {
232
+ writeVirtualModule(ALIAS["@manifest/fields"], `
233
+ export default {}
234
+ `);
235
+ }
236
+ // Field manifest
237
+ ALIAS["@manifest/widgets"] = path_1.default.resolve(opts.baseDirectory, "_widgets_manifest.js");
238
+ if (opts.isAdmin) {
239
+ manifestLoaders.push((0, manifest_widgets_1.createWidgetManifestGenerator)({
240
+ baseDirectory: opts.baseDirectory,
241
+ isAdmin: true,
242
+ isDev: isDev,
243
+ isServerless: isServerless,
244
+ watch: isDev,
245
+ onGenerate: (manifest) => {
246
+ writeVirtualModule(ALIAS["@manifest/widgets"], manifest);
247
+ },
248
+ }));
249
+ }
250
+ else {
251
+ writeVirtualModule(ALIAS["@manifest/widgets"], `
252
+ export default {}
253
+ `);
254
+ }
255
+ // Block manifest
256
+ ALIAS["@manifest/blocks"] = path_1.default.resolve(opts.baseDirectory, "_blocks_manifest.js");
257
+ manifestLoaders.push((0, manifest_blocks_1.createBlockManifestGenerator)({
258
+ baseDirectory: opts.baseDirectory,
259
+ isAdmin: opts.isAdmin,
260
+ isDev: isDev,
261
+ isServerless: isServerless,
262
+ watch: isDev,
263
+ onGenerate: (manifest) => {
264
+ writeVirtualModule(ALIAS["@manifest/blocks"], manifest);
265
+ },
266
+ }));
267
+ // Wait for all manifests to resolve
268
+ await Promise.all(manifestLoaders);
269
+ // External Gutenberg
270
+ EXTERNALS["@wordpress/components"] = ["window", "wp"];
271
+ EXTERNALS["@wordpress/element"] = ["window", "wp"];
272
+ EXTERNALS["@wordpress/blocks"] = ["window", "wp"];
273
+ EXTERNALS["@wordpress/utils"] = ["window", "wp"];
274
+ EXTERNALS["@wordpress/data"] = ["window", "wp"];
275
+ EXTERNALS["@wordpress/hooks"] = ["window", "wp"];
276
+ EXTERNALS["@wordpress/block-editor"] = ["window", "wp"];
277
+ if (opts.isAdmin) {
278
+ EXTERNALS["@wordpress/components"] = ["wp", "components"];
279
+ EXTERNALS["@wordpress/element"] = ["wp", "element"];
280
+ EXTERNALS["@wordpress/blocks"] = ["wp", "blocks"];
281
+ EXTERNALS["@wordpress/utils"] = ["wp", "utils"];
282
+ EXTERNALS["@wordpress/data"] = ["wp", "data"];
283
+ EXTERNALS["@wordpress/hooks"] = ["wp", "hooks"];
284
+ EXTERNALS["@wordpress/block-editor"] = ["wp", "blockEditor"];
285
+ EXTERNALS["react"] = "React";
286
+ EXTERNALS["react-dom"] = "ReactDOM";
287
+ }
288
+ // Define some values
289
+ DEFINES["process.browser"] = JSON.stringify(isBrowser);
290
+ DEFINES["process.client"] = JSON.stringify(isBrowser);
291
+ DEFINES["process.serverless"] = "false";
292
+ DEFINES["process.ssr"] = JSON.stringify(isServerless && !isBrowser);
293
+ DEFINES["process.LOADABLE_STATS_FILE"] = JSON.stringify(loadableManifestFile);
294
+ DEFINES["process.dev"] = isDev ? "true" : "false";
295
+ DEFINES["process.admin"] = opts.isAdmin ? "true" : "false";
296
+ DEFINES["process.env.themePath"] = JSON.stringify(`/wp-content/themes/${opts.themeName}`);
297
+ DEFINES["process.themePath"] = JSON.stringify(`/wp-content/themes/${opts.themeName}`);
298
+ if (isDev && opts.isAdmin) {
299
+ DEFINES["process.BLOCK_MANIFEST_FILE"] = JSON.stringify(ALIAS["@manifest/blocks"]);
300
+ }
301
+ DEFINES["process.devUI"] = config.devUI === "enabled";
302
+ DEFINES["process.serverlessEndpoint"] = "(window.SERVERLESS_ENDPOINT || '')";
303
+ const rpcExists = (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc.ts")) ||
304
+ (0, fs_1.existsSync)(path_1.default.join(opts.baseDirectory, "apis/_rpc/index.ts"));
305
+ DEFINES["process.rpcEnabled"] = rpcExists ? "true" : "false";
306
+ if (isBrowser) {
307
+ DEFINES["process.env.themePath"] = `window.THEME_PATH || ${DEFINES["process.env.themePath"]}`;
308
+ }
309
+ const buildID = Date.now();
310
+ return {
311
+ mode: opts.mode,
312
+ context: opts.baseDirectory,
313
+ target: opts.target === "ssr" ? "node" : "web",
314
+ optimization: {
315
+ splitChunks: {
316
+ chunks: "async",
317
+ },
318
+ minimize: opts.mode === "production",
319
+ // chunkIds: "named",
320
+ },
321
+ output: {
322
+ filename: `[name].${opts.isAdmin ? "admin" : "frontend"}.js?v=${buildID}`,
323
+ chunkFilename: `[name].${opts.isAdmin ? "admin" : "frontend"}.js?v=${buildID}`,
324
+ publicPath: `/wp-content/themes/${opts.themeName}/dist/${distSuffix}/`,
325
+ path: outputFolder,
326
+ globalObject: isSSR ? "this" : "self",
327
+ clean: true,
328
+ },
329
+ externals: {
330
+ worker_threads: true,
331
+ ...EXTERNALS,
332
+ },
333
+ resolve: {
334
+ alias: ALIAS,
335
+ extensions: [".js", ".jsx", ".ts", ".tsx"],
336
+ },
337
+ entry: ENTRY,
338
+ plugins: [
339
+ ...PLUGINS,
340
+ () => {
341
+ compiling = true;
342
+ },
343
+ ],
344
+ module: {
345
+ rules: RULES,
346
+ },
347
+ devtool: opts.mode === "development" && opts.target === "client"
348
+ ? opts.mode === "development"
349
+ ? "cheap-module-source-map"
350
+ : "source-map"
351
+ : false,
352
+ stats: {
353
+ all: true,
354
+ errorDetails: true,
355
+ errors: true,
356
+ colors: true,
357
+ },
358
+ };
413
359
  }
414
360
  exports.default = getWebpackConfig;