@xarc/app-dev 13.0.0-beta.1 โ 13.1.0
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.
- package/README.md +467 -10
- package/config/jest/jest.config.js +1 -11
- package/config/jest/jest.config.js.map +1 -1
- package/package.json +17 -18
- package/src/config/jest/jest.config.ts +0 -15
package/README.md
CHANGED
|
@@ -1,18 +1,475 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @xarc/app-dev
|
|
2
2
|
|
|
3
|
-
[![NPM version][npm-image]][npm-url]
|
|
3
|
+
[![NPM version][npm-image]][npm-url][![npm downloads][npm-downloads-image]][npm-downloads-url]
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Overview
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
`@xarc/app-dev` is the comprehensive development toolkit for the Electrode platform, providing a powerful set of tools and configurations for building modern React applications at enterprise scale. As the development companion to `@xarc/app`, it offers everything developers need for a productive development experience with hot module replacement, advanced build systems, testing frameworks, and deployment-ready configurations.
|
|
8
8
|
|
|
9
|
-
|
|
9
|
+
## Key Features
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
- ๐ **Webpack Dev Server Integration** - Hot module replacement and live reloading
|
|
12
|
+
- โก **Build System** - Complete build pipeline with webpack, Babel, and TypeScript
|
|
13
|
+
- ๐งช **Testing Tools** - Jest, Mocha, Karma, and ESLint configurations
|
|
14
|
+
- ๐ฆ **Task Runner** - Powerful task system with `xrun` for development workflows
|
|
15
|
+
- ๐ **Hot Reload** - Advanced hot module replacement for React components and subapps
|
|
16
|
+
- ๐ **Configuration Presets** - Pre-configured Babel, ESLint, and webpack setups
|
|
17
|
+
- ๐ **Development Proxy** - Built-in reverse proxy for local development
|
|
18
|
+
|
|
19
|
+
## Installation and Dependencies
|
|
20
|
+
|
|
21
|
+
```bash
|
|
22
|
+
# Install as a development dependency
|
|
23
|
+
npm install --save-dev @xarc/app-dev
|
|
24
|
+
|
|
25
|
+
# Usually installed alongside @xarc/app
|
|
26
|
+
npm install @xarc/app
|
|
27
|
+
npm install --save-dev @xarc/app-dev
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## Basic Setup
|
|
31
|
+
|
|
32
|
+
1. **Create a task runner file** (`xrun-tasks.ts`):
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
const { loadDevTasks, xrun } = require("@xarc/app-dev");
|
|
36
|
+
|
|
37
|
+
// Configure development environment
|
|
38
|
+
xrun.updateEnv({
|
|
39
|
+
{
|
|
40
|
+
HOST: "localhost",
|
|
41
|
+
PORT: 443,
|
|
42
|
+
/*
|
|
43
|
+
* Set app's node server to listen at port 3100 so the proxy can listen at 3000
|
|
44
|
+
* and forward request to the app.
|
|
45
|
+
*/
|
|
46
|
+
APP_SERVER_PORT: 3100,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
// do not override any env flag already set in process.env
|
|
50
|
+
override: true,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
// Load all development tasks
|
|
55
|
+
loadDevTasks(xrun, {
|
|
56
|
+
// options to customize features
|
|
57
|
+
webpackOptions: {
|
|
58
|
+
// enable CSS module for files other than `.mod.css`
|
|
59
|
+
cssModuleSupport: "byModExt",
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
2. **Add package.json scripts**:
|
|
65
|
+
|
|
66
|
+
```json
|
|
67
|
+
{
|
|
68
|
+
"scripts": {
|
|
69
|
+
"dev": "xrun dev",
|
|
70
|
+
"build": "xrun build",
|
|
71
|
+
"test": "xrun test",
|
|
72
|
+
"lint": "xrun lint"
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
3. **Start development server**:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
npm run dev
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
## Why Choose @xarc/app-dev Over Create React App?
|
|
84
|
+
|
|
85
|
+
As an experienced developer, here are the key advantages of @xarc/app-dev:
|
|
86
|
+
|
|
87
|
+
### ๐๏ธ **Enterprise-Scale Architecture**
|
|
88
|
+
- **Micro-Frontend Support**: Built-in SubApp architecture for modular, scalable applications
|
|
89
|
+
- **Team-Friendly**: Designed for large development teams with independent component development
|
|
90
|
+
|
|
91
|
+
### โก **Superior Development Experience**
|
|
92
|
+
- **Advanced Task System**: Comprehensive `xrun` task runner with granular workflow control
|
|
93
|
+
- **No Ejection Required**: Highly configurable without breaking update paths
|
|
94
|
+
|
|
95
|
+
### ๐ **Production-Ready Features**
|
|
96
|
+
- **Built-in SSR**: Native server-side rendering with automatic isomorphic asset loading
|
|
97
|
+
- **Advanced HMR**: Hot module replacement for React components, Redux reducers, and SubApps
|
|
98
|
+
- **CDN Integration**: Seamless asset optimization and delivery
|
|
99
|
+
|
|
100
|
+
### ๐ง **Flexible Configuration**
|
|
101
|
+
- **Multiple Testing Frameworks**: Support for Jest, Mocha
|
|
102
|
+
- **TypeScript-First**: Comprehensive TypeScript support and type definitions
|
|
103
|
+
- **Preset System**: Ready-to-use configurations for Babel, ESLint, and webpack
|
|
104
|
+
|
|
105
|
+
## Complete Usage Examples
|
|
106
|
+
|
|
107
|
+
### Example 1: Basic React Application Setup
|
|
108
|
+
|
|
109
|
+
#### 1. Task Runner Configuration (`xrun-tasks.ts`)
|
|
110
|
+
```typescript
|
|
111
|
+
import { loadXarcDevTasks, xrun } from "@xarc/app-dev/lib/dev-tasks";
|
|
112
|
+
|
|
113
|
+
// Configure development environment
|
|
114
|
+
xrun.updateEnv({
|
|
115
|
+
HOST: "localhost",
|
|
116
|
+
PORT: 3000,
|
|
117
|
+
APP_SERVER_PORT: 3100,
|
|
118
|
+
WEBPACK_DEV_MIDDLEWARE: true,
|
|
119
|
+
NODE_ENV: process.env.NODE_ENV || "development"
|
|
120
|
+
}, { override: false });
|
|
121
|
+
|
|
122
|
+
// Load all development tasks
|
|
123
|
+
loadXarcDevTasks(xrun, {
|
|
124
|
+
// Custom webpack configuration
|
|
125
|
+
// options to customize features
|
|
126
|
+
webpackOptions: {
|
|
127
|
+
// enable CSS module for files other than `.mod.css`
|
|
128
|
+
cssModuleSupport: "byModExt",
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
#### 2. SubApp Implementation (`src/subapps/home/index.tsx`)
|
|
134
|
+
```tsx
|
|
135
|
+
import { React, ReactSubApp } from "@xarc/react";
|
|
136
|
+
import { reduxFeature } from "@xarc/react-redux";
|
|
137
|
+
|
|
138
|
+
interface HomeProps {
|
|
139
|
+
title?: string;
|
|
140
|
+
message?: string;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const HomeComponent: React.FC<HomeProps> = ({
|
|
144
|
+
title = "Welcome",
|
|
145
|
+
message = "Hello from @xarc/app-dev!"
|
|
146
|
+
}) => {
|
|
147
|
+
return (
|
|
148
|
+
<div className="home-container">
|
|
149
|
+
<h1>{title}</h1>
|
|
150
|
+
<p>{message}</p>
|
|
151
|
+
<button onClick={() => console.log("SubApp working!")}>
|
|
152
|
+
Click me!
|
|
153
|
+
</button>
|
|
154
|
+
</div>
|
|
155
|
+
);
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const subapp: ReactSubApp = {
|
|
159
|
+
Component: HomeComponent,
|
|
160
|
+
wantFeatures: [
|
|
161
|
+
reduxFeature({
|
|
162
|
+
React,
|
|
163
|
+
shareStore: true
|
|
164
|
+
})
|
|
165
|
+
]
|
|
166
|
+
};
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
#### 3. Application Entry (`src/client/entry.ts`)
|
|
170
|
+
```typescript
|
|
171
|
+
import { declareSubApp } from "@xarc/react";
|
|
172
|
+
|
|
173
|
+
// Declare your SubApps
|
|
174
|
+
export const Home = declareSubApp({
|
|
175
|
+
name: "Home",
|
|
176
|
+
getModule: () => import("../subapps/home")
|
|
177
|
+
});
|
|
178
|
+
```
|
|
179
|
+
### Example 2: Custom Webpack Configuration
|
|
180
|
+
|
|
181
|
+
The @xarc/app-dev system uses a powerful webpack partials system that allows you to override specific parts of the webpack configuration without replacing the entire config.
|
|
182
|
+
|
|
183
|
+
#### Understanding Webpack Partials
|
|
184
|
+
|
|
185
|
+
Webpack partials are modular configuration pieces that handle specific aspects of the webpack build:
|
|
186
|
+
|
|
187
|
+
- **baseOptions** - Base webpack configuration options
|
|
188
|
+
- **entry** - Entry point configuration
|
|
189
|
+
- **output** - Output configuration
|
|
190
|
+
- **resolve** - Module resolution settings
|
|
191
|
+
- **babel** - Babel loader configuration
|
|
192
|
+
- **extractStyle** - CSS extraction settings
|
|
193
|
+
- **fonts** - Font file handling
|
|
194
|
+
- **images** - Image processing
|
|
195
|
+
- **dev** - Development server settings
|
|
196
|
+
- **prodMode/devMode** - Environment-specific settings
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
```javascript
|
|
200
|
+
// webpack.config.js
|
|
201
|
+
const { xarcWebpack, partials, profiles } = require("@xarc/app-dev");
|
|
202
|
+
|
|
203
|
+
// Get the environment and options
|
|
204
|
+
const env = xarcWebpack.getEnvProfile();
|
|
205
|
+
const options = xarcWebpack.getComposeOptions();
|
|
206
|
+
|
|
207
|
+
// Use preset partials with custom overrides
|
|
208
|
+
const { composer } = xarcWebpack.initWebpackConfigComposer(options);
|
|
209
|
+
|
|
210
|
+
// Override specific partials from the preset
|
|
211
|
+
composer.getPartial("_resolve").setOverride((config) => ({
|
|
212
|
+
...config,
|
|
213
|
+
alias: {
|
|
214
|
+
...config.alias,
|
|
215
|
+
'@': path.resolve(process.cwd(), 'src'),
|
|
216
|
+
'@components': path.resolve(process.cwd(), 'src/components'),
|
|
217
|
+
'@utils': path.resolve(process.cwd(), 'src/utils'),
|
|
218
|
+
'@assets': path.resolve(process.cwd(), 'src/assets')
|
|
219
|
+
},
|
|
220
|
+
fallback: {
|
|
221
|
+
...config.fallback,
|
|
222
|
+
"crypto": require.resolve("crypto-browserify"),
|
|
223
|
+
"stream": require.resolve("stream-browserify"),
|
|
224
|
+
"buffer": require.resolve("buffer")
|
|
225
|
+
}
|
|
226
|
+
}));
|
|
227
|
+
|
|
228
|
+
// Add custom loader configurations
|
|
229
|
+
composer.getPartial("_babel").setOverride((config) => ({
|
|
230
|
+
...config,
|
|
231
|
+
module: {
|
|
232
|
+
...config.module,
|
|
233
|
+
rules: [
|
|
234
|
+
...config.module.rules,
|
|
235
|
+
{
|
|
236
|
+
test: /\.tsx?$/,
|
|
237
|
+
use: [
|
|
238
|
+
{
|
|
239
|
+
loader: 'ts-loader',
|
|
240
|
+
options: {
|
|
241
|
+
transpileOnly: true,
|
|
242
|
+
compilerOptions: {
|
|
243
|
+
jsx: 'react-jsx'
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
exclude: /node_modules/
|
|
249
|
+
}
|
|
250
|
+
]
|
|
251
|
+
}
|
|
252
|
+
}));
|
|
253
|
+
|
|
254
|
+
module.exports = xarcWebpack.compose(options);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
#### Available Webpack Partials
|
|
258
|
+
|
|
259
|
+
Here's a comprehensive list of all webpack partials available for customization, organized by category:
|
|
260
|
+
|
|
261
|
+
##### Core Configuration Partials
|
|
262
|
+
|
|
263
|
+
| Partial Name | Purpose | When to Override | Common Scenarios |
|
|
264
|
+
|--------------|---------|------------------|------------------|
|
|
265
|
+
| `_entry` | Entry point configuration and HMR setup | Dynamic entries, multi-page apps | Multiple entry points, custom entry logic |
|
|
266
|
+
| `_output` | Output settings (path, filename, publicPath) | Custom build output | CDN integration, custom file naming |
|
|
267
|
+
| `_resolve` | Module resolution (aliases, extensions) | Path aliases, custom modules | Monorepo setups, custom module paths |
|
|
268
|
+
|
|
269
|
+
|
|
270
|
+
##### Build & Processing Partials
|
|
271
|
+
|
|
272
|
+
| Partial Name | Purpose | When to Override | Common Scenarios |
|
|
273
|
+
|--------------|---------|------------------|------------------|
|
|
274
|
+
| `_babel` | Babel loader configuration | Custom Babel setup | Different presets, TypeScript config |
|
|
275
|
+
| `_extract-style` | CSS/SCSS/Less processing and extraction | Custom CSS setup | PostCSS plugins, CSS modules |
|
|
276
|
+
| `_fonts` | Font file handling (woff, woff2, ttf, eot) | Custom font processing | Web font optimization, custom loaders |
|
|
277
|
+
| `_images` | Image processing (png, jpg, gif, svg) | Image optimization | Custom image loaders, CDN integration |
|
|
278
|
+
| `_subapp-chunks` | SubApp code splitting and chunk optimization | Custom chunking strategy | Bundle size optimization, lazy loading |
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
#### Common Override Scenarios by Use Case
|
|
282
|
+
|
|
283
|
+
**๐ฏ Development Environment Customization**
|
|
284
|
+
```javascript
|
|
285
|
+
// Override _dev for custom development server
|
|
286
|
+
composer.getPartial("_dev").setOverride((config) => ({
|
|
287
|
+
...config,
|
|
288
|
+
devServer: {
|
|
289
|
+
...config.devServer,
|
|
290
|
+
port: 4000,
|
|
291
|
+
proxy: {
|
|
292
|
+
'/api': 'http://localhost:8080'
|
|
293
|
+
},
|
|
294
|
+
headers: {
|
|
295
|
+
'Access-Control-Allow-Origin': '*'
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}));
|
|
299
|
+
```
|
|
300
|
+
**๐งฉ Module Resolution and Aliases**
|
|
301
|
+
```javascript
|
|
302
|
+
// Override _resolve for monorepo or custom paths
|
|
303
|
+
composer.getPartial("_resolve").setOverride((config) => ({
|
|
304
|
+
...config,
|
|
305
|
+
alias: {
|
|
306
|
+
...config.alias,
|
|
307
|
+
'@shared': path.resolve(__dirname, '../shared'),
|
|
308
|
+
'@components': path.resolve(__dirname, 'src/components'),
|
|
309
|
+
'@utils': path.resolve(__dirname, 'src/utils')
|
|
310
|
+
}
|
|
311
|
+
}));
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
**๐จ Custom CSS Processing**
|
|
315
|
+
```javascript
|
|
316
|
+
// Override _extract-style for custom CSS setup
|
|
317
|
+
composer.getPartial("_extract-style").setOverride((config) => ({
|
|
318
|
+
...config,
|
|
319
|
+
module: {
|
|
320
|
+
...config.module,
|
|
321
|
+
rules: [
|
|
322
|
+
...config.module.rules,
|
|
323
|
+
{
|
|
324
|
+
test: /\.scss$/,
|
|
325
|
+
use: [
|
|
326
|
+
'style-loader',
|
|
327
|
+
'css-loader',
|
|
328
|
+
'sass-loader',
|
|
329
|
+
{
|
|
330
|
+
loader: 'postcss-loader',
|
|
331
|
+
options: {
|
|
332
|
+
plugins: [require('tailwindcss')]
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
]
|
|
336
|
+
}
|
|
337
|
+
]
|
|
338
|
+
}
|
|
339
|
+
}));
|
|
340
|
+
```
|
|
341
|
+
|
|
342
|
+
|
|
343
|
+
**๐ฆ SubApp Chunk Optimization**
|
|
344
|
+
```javascript
|
|
345
|
+
// Override _subapp-chunks for custom chunking
|
|
346
|
+
composer.getPartial("_subapp-chunks").setOverride((config) => ({
|
|
347
|
+
...config,
|
|
348
|
+
optimization: {
|
|
349
|
+
...config.optimization,
|
|
350
|
+
splitChunks: {
|
|
351
|
+
...config.optimization.splitChunks,
|
|
352
|
+
minSize: 20000,
|
|
353
|
+
maxSize: 250000
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
}));
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
## Usage in Electrode Ecosystem
|
|
361
|
+
|
|
362
|
+
### With @xarc/app
|
|
363
|
+
|
|
364
|
+
The typical setup with the main `@xarc/app` package:
|
|
365
|
+
|
|
366
|
+
```json
|
|
367
|
+
{
|
|
368
|
+
"dependencies": {
|
|
369
|
+
"@xarc/app": "^12.0.0"
|
|
370
|
+
},
|
|
371
|
+
"devDependencies": {
|
|
372
|
+
"@xarc/app-dev": "^12.0.0"
|
|
373
|
+
}
|
|
374
|
+
}
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
```typescript
|
|
378
|
+
// xrun-tasks.ts - Development tasks
|
|
379
|
+
import { loadXarcDevTasks, xrun } from "@xarc/app-dev/lib/dev-tasks";
|
|
380
|
+
|
|
381
|
+
xrun.updateEnv({
|
|
382
|
+
WEBPACK_DEV_MIDDLEWARE: true,
|
|
383
|
+
HOST: "localhost",
|
|
384
|
+
PORT: 3000,
|
|
385
|
+
APP_SERVER_PORT: 3100
|
|
386
|
+
});
|
|
387
|
+
|
|
388
|
+
loadXarcDevTasks(xrun, {});
|
|
389
|
+
```
|
|
390
|
+
|
|
391
|
+
### With Subapps
|
|
392
|
+
|
|
393
|
+
For subapp-based applications, you can configure webpack dev middleware in your server configuration:
|
|
394
|
+
|
|
395
|
+
```typescript
|
|
396
|
+
// server configuration
|
|
397
|
+
const config = {
|
|
398
|
+
plugins: {
|
|
399
|
+
"@xarc/app-dev": {
|
|
400
|
+
module: "@xarc/app-dev/lib/webpack-dev-express", // or fastify/koa
|
|
401
|
+
enable: process.env.NODE_ENV === "development"
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
};
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
|
|
409
|
+
## @xarc/app-dev vs Create React App: Feature Comparison
|
|
410
|
+
|
|
411
|
+
| Feature | @xarc/app-dev | Create React App (CRA) |
|
|
412
|
+
|---------|---------------|-------------------------|
|
|
413
|
+
| **Architecture** | Micro-frontend (SubApp) architecture | Monolithic SPA |
|
|
414
|
+
| **Server-Side Rendering** | โ
Built-in SSR support | โ Client-side only* |
|
|
415
|
+
| **Configuration** | โ
Extensible without ejecting | โ Must eject for customization |
|
|
416
|
+
| **Task Runner** | โ
Comprehensive `xrun` system | โ Basic npm scripts |
|
|
417
|
+
| **Server Integration** | โ
Express/Fastify/Koa/Hapi middleware | โ Dev server only |
|
|
418
|
+
| **Hot Module Replacement** | โ
Advanced HMR (Components + Redux + SubApps) | โ
Basic component HMR |
|
|
419
|
+
| **Testing Frameworks** | โ
Jest, Mocha, Karma support | โ
Jest only |
|
|
420
|
+
| **TypeScript** | โ
First-class TypeScript support | โ
Good TypeScript support |
|
|
421
|
+
| **Code Splitting** | โ
Automatic SubApp-level splitting | โ
Manual dynamic imports |
|
|
422
|
+
| **CDN Integration** | โ
Built-in CDN mapping | โ Manual configuration |
|
|
423
|
+
| **Asset Management** | โ
Isomorphic asset loading | โ Client-side only |
|
|
424
|
+
| **Production Readiness** | โ
Enterprise-scale proven | โ
Good for smaller apps |
|
|
425
|
+
| **Learning Curve** | ๐ Moderate to steep | ๐ Gentle |
|
|
426
|
+
|
|
427
|
+
## Configuration Options
|
|
428
|
+
|
|
429
|
+
### Environment Variables
|
|
430
|
+
|
|
431
|
+
Key environment variables for development:
|
|
432
|
+
|
|
433
|
+
```bash
|
|
434
|
+
# Server Configuration
|
|
435
|
+
HOST=localhost # Development server host
|
|
436
|
+
PORT=3000 # Main server port
|
|
437
|
+
APP_SERVER_PORT=3100 # App server port (when using proxy)
|
|
438
|
+
|
|
439
|
+
# Webpack Dev Server
|
|
440
|
+
WEBPACK_DEV_MIDDLEWARE=true # Enable webpack dev middleware
|
|
441
|
+
WEBPACK_DEV_HOST=localhost # Webpack dev server host
|
|
442
|
+
WEBPACK_DEV_PORT=2992 # Webpack dev server port
|
|
443
|
+
WEBPACK_DEV_HTTPS=false # Use HTTPS for dev server
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
### XarcOptions Interface
|
|
447
|
+
|
|
448
|
+
```typescript
|
|
449
|
+
interface XarcOptions {
|
|
450
|
+
webpack?: {
|
|
451
|
+
enableHotModuleReload?: boolean;
|
|
452
|
+
enableNodeModuleReload?: boolean;
|
|
453
|
+
minify?: boolean;
|
|
454
|
+
};
|
|
455
|
+
babel?: {
|
|
456
|
+
enableTypeScript?: boolean;
|
|
457
|
+
enableFlow?: boolean;
|
|
458
|
+
target?: string;
|
|
459
|
+
};
|
|
460
|
+
eslint?: {
|
|
461
|
+
enableTypeScript?: boolean;
|
|
462
|
+
extendRc?: string;
|
|
463
|
+
};
|
|
464
|
+
}
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
## License
|
|
469
|
+
|
|
470
|
+
Apache-2.0 ยฉ [Electrode](https://github.com/electrode-io/electrode)
|
|
471
|
+
|
|
472
|
+
[npm-image]: https://badge.fury.io/js/%40xarc%2Fapp-dev.svg
|
|
12
473
|
[npm-url]: https://npmjs.org/package/@xarc/app-dev
|
|
13
|
-
[daviddm-image]: https://david-dm.org/electrode-io/electrode/status.svg?path=packages/@xarc/app-dev
|
|
14
|
-
[daviddm-url]: https://david-dm.org/electrode-io/electrode?path=packages/@xarc/app-dev
|
|
15
|
-
[daviddm-dev-image]: https://david-dm.org/electrode-io/electrode/dev-status.svg?path=packages/@xarc/app-dev
|
|
16
|
-
[daviddm-dev-url]: https://david-dm.org/electrode-io/electrode?path=packages/@xarc/app-dev?type-dev
|
|
17
474
|
[npm-downloads-image]: https://img.shields.io/npm/dm/@xarc/app-dev.svg
|
|
18
475
|
[npm-downloads-url]: https://www.npmjs.com/package/@xarc/app-dev
|
|
@@ -3,13 +3,6 @@
|
|
|
3
3
|
const Path = require("path");
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const fileMock = Path.join(__dirname, "__mocks__", "file-mock.js");
|
|
6
|
-
const frameworkMock = Path.join(__dirname, "__mocks__", "framework-mock.js");
|
|
7
|
-
const { getOptArchetypeRequire } = require("../../lib/utils");
|
|
8
|
-
const optRequire = getOptArchetypeRequire(["@xarc/opt-jest", "electrode-archetype-opt-jest"]);
|
|
9
|
-
const jestPkg = optRequire("jest/package.json");
|
|
10
|
-
const jestMajVersion = parseInt(jestPkg.version.split(".")[0], 10);
|
|
11
|
-
// Jest changed its config setting for setup files on version 24
|
|
12
|
-
const SETUP_FILES_VERSION_SPLIT = 24;
|
|
13
6
|
const utils_1 = require("../../lib/utils");
|
|
14
7
|
const xarcOptions = (0, utils_1.loadXarcOptions)();
|
|
15
8
|
const xarcCwd = xarcOptions.cwd;
|
|
@@ -40,8 +33,5 @@ const jestDefaultConfig = {
|
|
|
40
33
|
url: "http://localhost/"
|
|
41
34
|
}
|
|
42
35
|
};
|
|
43
|
-
|
|
44
|
-
const jestSetupFilesNew = { setupFilesAfterEnv: [frameworkMock] };
|
|
45
|
-
const jestSetupFilesConfig = jestMajVersion >= SETUP_FILES_VERSION_SPLIT ? jestSetupFilesNew : jestSetupFilesDeprecated;
|
|
46
|
-
module.exports = _.merge({}, _.pickBy(jestDefaultConfig, x => x !== undefined), jestSetupFilesConfig, xarcOptions.jest);
|
|
36
|
+
module.exports = _.merge({}, _.pickBy(jestDefaultConfig, x => x !== undefined), xarcOptions.jest);
|
|
47
37
|
//# sourceMappingURL=jest.config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../src/config/jest/jest.config.ts"],"names":[],"mappings":";AAAA,uDAAuD;AAEvD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"jest.config.js","sourceRoot":"","sources":["../../src/config/jest/jest.config.ts"],"names":[],"mappings":";AAAA,uDAAuD;AAEvD,MAAM,IAAI,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7B,MAAM,CAAC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAC;AAC5B,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,WAAW,EAAE,cAAc,CAAC,CAAC;AAEnE,2CAAkD;AAElD,MAAM,WAAW,GAAG,IAAA,uBAAe,GAAE,CAAC;AACtC,MAAM,OAAO,GAAG,WAAW,CAAC,GAAG,CAAC;AAEhC,MAAM,EAAE,gBAAgB,EAAE,GAAG,WAAW,CAAC,KAAK,CAAC;AAE/C,gEAAgE;AAChE,MAAM,QAAQ,GAAG,gBAAgB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC;AAC/C,MAAM,SAAS,GAAG,6CAA6C,QAAQ,OAAO,CAAC;AAE/E,MAAM,OAAO,GAAG,OAAO,CAAC;AAExB,MAAM,iBAAiB,GAAG;IACxB,OAAO;IACP,QAAQ,EAAE,OAAO,CAAC,OAAO,CAAC,kCAAkC,CAAC;IAC7D,oBAAoB,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,MAAM,CAAC,gBAAgB,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5F,SAAS,EAAE,gBAAgB;QACzB,CAAC,CAAC;YACE,aAAa,EAAE,YAAY;YAC3B,aAAa,EAAE,YAAY;SAC5B;QACH,CAAC,CAAC,SAAS;IACb,SAAS;IACT,sBAAsB,EAAE,CAAC,gBAAgB,EAAE,cAAc,CAAC;IAC1D,iBAAiB,EAAE,CAAC,cAAc,EAAE,KAAK,CAAC;IAC1C,gBAAgB,EAAE;QAChB,qFAAqF,EAAE,QAAQ;QAC/F,+BAA+B,EAAE,oBAAoB;KACtD;IACD,wBAAwB,EAAE,CAAC,gBAAgB,CAAC;IAC5C,sBAAsB,EAAE;QACtB,GAAG,EAAE,mBAAmB;KAC3B;CACA,CAAC;AAEF,iBAAS,CAAC,CAAC,KAAK,CACd,EAAE,EACF,CAAC,CAAC,MAAM,CAAC,iBAAiB,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,KAAK,SAAS,CAAC,EACjD,WAAW,CAAC,IAAI,CACjB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xarc/app-dev",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.1.0",
|
|
4
4
|
"description": "Electrode X application development support",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"homepage": "http://www.electrode.io",
|
|
@@ -12,17 +12,6 @@
|
|
|
12
12
|
"url": "https://github.com/electrode-io/electrode/issues"
|
|
13
13
|
},
|
|
14
14
|
"license": "Apache-2.0",
|
|
15
|
-
"scripts": {
|
|
16
|
-
"compile": "tsc",
|
|
17
|
-
"build": "xrun -s compile user/moveDist",
|
|
18
|
-
"lint": "xrun xarc/lint",
|
|
19
|
-
"test": "xrun xarc/test-only",
|
|
20
|
-
"coverage": "xrun xarc/test-cov",
|
|
21
|
-
"check": "xrun xarc/check",
|
|
22
|
-
"format": "prettier --write --print-width 100 *.{js,jsx} `find . -type d -d 1 -exec echo '{}/**/*.{js,jsx}' \\; | egrep -v '(/node_modules/|/dist/|/coverage/)'`",
|
|
23
|
-
"prepublishOnly": "xrun [[build, docs], xarc/check]",
|
|
24
|
-
"docs": "xrun xarc/docs"
|
|
25
|
-
},
|
|
26
15
|
"bin": {
|
|
27
16
|
"xrun": "bin/xrun.js"
|
|
28
17
|
},
|
|
@@ -39,7 +28,7 @@
|
|
|
39
28
|
"Joel Chen <xchen@walmartlabs.com>"
|
|
40
29
|
],
|
|
41
30
|
"peerDependencies": {
|
|
42
|
-
"@xarc/app": "^
|
|
31
|
+
"@xarc/app": "^13.1.0"
|
|
43
32
|
},
|
|
44
33
|
"dependencies": {
|
|
45
34
|
"@babel/cli": "^7.17.10",
|
|
@@ -55,10 +44,10 @@
|
|
|
55
44
|
"@babel/preset-typescript": "^7.17.12",
|
|
56
45
|
"@babel/register": "^7.17.7",
|
|
57
46
|
"@jchip/redbird": "^1.3.0",
|
|
58
|
-
"@xarc/dev-base": "^1.0.0
|
|
47
|
+
"@xarc/dev-base": "^1.0.0",
|
|
59
48
|
"@xarc/run": "^1.0.5",
|
|
60
|
-
"@xarc/subapp": "^1.0.0
|
|
61
|
-
"@xarc/webpack": "^13.0.0
|
|
49
|
+
"@xarc/subapp": "^1.0.0",
|
|
50
|
+
"@xarc/webpack": "^13.0.0",
|
|
62
51
|
"ansi-to-html": "^0.7.2",
|
|
63
52
|
"babel-plugin-lodash": "^3.3.4",
|
|
64
53
|
"babel-plugin-minify-dead-code-elimination": "^0.5.2",
|
|
@@ -114,7 +103,7 @@
|
|
|
114
103
|
"@types/webpack": "5.28.0",
|
|
115
104
|
"@typescript-eslint/eslint-plugin": "^5.0.0",
|
|
116
105
|
"@typescript-eslint/parser": "^5.0.0",
|
|
117
|
-
"@xarc/app": "^
|
|
106
|
+
"@xarc/app": "^13.1.0",
|
|
118
107
|
"@xarc/module-dev": "^4.1.0",
|
|
119
108
|
"@xarc/run": "^1.1.1",
|
|
120
109
|
"chai": "^4.3.6",
|
|
@@ -193,5 +182,15 @@
|
|
|
193
182
|
"@xarc/module-dev/config/test/setup.js"
|
|
194
183
|
],
|
|
195
184
|
"recursive": true
|
|
185
|
+
},
|
|
186
|
+
"scripts": {
|
|
187
|
+
"compile": "tsc",
|
|
188
|
+
"build": "xrun -s compile user/moveDist",
|
|
189
|
+
"lint": "xrun xarc/lint",
|
|
190
|
+
"test": "xrun xarc/test-only",
|
|
191
|
+
"coverage": "xrun xarc/test-cov",
|
|
192
|
+
"check": "xrun xarc/check",
|
|
193
|
+
"format": "prettier --write --print-width 100 *.{js,jsx} `find . -type d -d 1 -exec echo '{}/**/*.{js,jsx}' \\; | egrep -v '(/node_modules/|/dist/|/coverage/)'`",
|
|
194
|
+
"docs": "xrun xarc/docs"
|
|
196
195
|
}
|
|
197
|
-
}
|
|
196
|
+
}
|
|
@@ -3,14 +3,6 @@
|
|
|
3
3
|
const Path = require("path");
|
|
4
4
|
const _ = require("lodash");
|
|
5
5
|
const fileMock = Path.join(__dirname, "__mocks__", "file-mock.js");
|
|
6
|
-
const frameworkMock = Path.join(__dirname, "__mocks__", "framework-mock.js");
|
|
7
|
-
const { getOptArchetypeRequire } = require("../../lib/utils");
|
|
8
|
-
const optRequire = getOptArchetypeRequire(["@xarc/opt-jest", "electrode-archetype-opt-jest"]);
|
|
9
|
-
|
|
10
|
-
const jestPkg = optRequire("jest/package.json");
|
|
11
|
-
const jestMajVersion = parseInt(jestPkg.version.split(".")[0], 10);
|
|
12
|
-
// Jest changed its config setting for setup files on version 24
|
|
13
|
-
const SETUP_FILES_VERSION_SPLIT = 24;
|
|
14
6
|
|
|
15
7
|
import { loadXarcOptions } from "../../lib/utils";
|
|
16
8
|
|
|
@@ -48,15 +40,8 @@ const jestDefaultConfig = {
|
|
|
48
40
|
}
|
|
49
41
|
};
|
|
50
42
|
|
|
51
|
-
const jestSetupFilesDeprecated = { setupTestFrameworkScriptFile: frameworkMock };
|
|
52
|
-
const jestSetupFilesNew = { setupFilesAfterEnv: [frameworkMock] };
|
|
53
|
-
|
|
54
|
-
const jestSetupFilesConfig =
|
|
55
|
-
jestMajVersion >= SETUP_FILES_VERSION_SPLIT ? jestSetupFilesNew : jestSetupFilesDeprecated;
|
|
56
|
-
|
|
57
43
|
export = _.merge(
|
|
58
44
|
{},
|
|
59
45
|
_.pickBy(jestDefaultConfig, x => x !== undefined),
|
|
60
|
-
jestSetupFilesConfig,
|
|
61
46
|
xarcOptions.jest
|
|
62
47
|
);
|