innetjs 2.0.0 → 2.0.3
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 +0 -3
- package/bin/innet +105 -61
- package/constants.d.ts +3 -0
- package/declaration.d.ts +39 -0
- package/helpers.d.ts +5 -0
- package/index.es6.js +102 -60
- package/index.js +104 -60
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -58,9 +58,6 @@ Use the command in the project folder to build it.
|
|
|
58
58
|
innetjs build
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
-
## Links
|
|
62
|
-
Check [README.md](https://github.com/d8corp/innetjs/tree/main/src/templates/fe) of `fe` template
|
|
63
|
-
|
|
64
61
|
## Issues
|
|
65
62
|
If you find a bug or have a suggestion, please file an issue on [GitHub](https://github.com/d8corp/innetjs/issues).
|
|
66
63
|
|
package/bin/innet
CHANGED
|
@@ -23,6 +23,9 @@ var proxy = require('express-http-proxy');
|
|
|
23
23
|
var selector = require('cli-select');
|
|
24
24
|
var jsx = require('rollup-plugin-innet-jsx');
|
|
25
25
|
var filesize = require('rollup-plugin-filesize');
|
|
26
|
+
var image = require('@rollup/plugin-image');
|
|
27
|
+
var eslint = require('@rollup/plugin-eslint');
|
|
28
|
+
var linesAndColumns = require('lines-and-columns');
|
|
26
29
|
var unzipper = require('unzipper');
|
|
27
30
|
var commander = require('commander');
|
|
28
31
|
|
|
@@ -47,6 +50,8 @@ var proxy__default = /*#__PURE__*/_interopDefaultLegacy(proxy);
|
|
|
47
50
|
var selector__default = /*#__PURE__*/_interopDefaultLegacy(selector);
|
|
48
51
|
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
|
|
49
52
|
var filesize__default = /*#__PURE__*/_interopDefaultLegacy(filesize);
|
|
53
|
+
var image__default = /*#__PURE__*/_interopDefaultLegacy(image);
|
|
54
|
+
var eslint__default = /*#__PURE__*/_interopDefaultLegacy(eslint);
|
|
50
55
|
|
|
51
56
|
/******************************************************************************
|
|
52
57
|
Copyright (c) Microsoft Corporation.
|
|
@@ -115,13 +120,35 @@ function Extract(opts, template) {
|
|
|
115
120
|
return extract;
|
|
116
121
|
}
|
|
117
122
|
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
123
|
+
const lintIncludeDom = [
|
|
124
|
+
'**/*.ts',
|
|
125
|
+
'**/*.tsx',
|
|
126
|
+
'**/*.js',
|
|
127
|
+
'**/*.jsx',
|
|
128
|
+
];
|
|
129
|
+
const stringExcludeDom = [
|
|
130
|
+
'**/*.ts',
|
|
131
|
+
'**/*.tsx',
|
|
132
|
+
'**/*.js',
|
|
133
|
+
'**/*.jsx',
|
|
134
|
+
'**/*.json',
|
|
135
|
+
'**/*.css',
|
|
136
|
+
'**/*.scss',
|
|
137
|
+
'**/*.webp',
|
|
138
|
+
'**/*.gif',
|
|
139
|
+
'**/*.png',
|
|
140
|
+
'**/*.jpeg',
|
|
141
|
+
'**/*.jpg',
|
|
142
|
+
'**/*.svg',
|
|
143
|
+
];
|
|
144
|
+
const stringExcludeNode = [
|
|
145
|
+
'**/*.ts',
|
|
146
|
+
'**/*.tsx',
|
|
147
|
+
'**/*.js',
|
|
148
|
+
'**/*.jsx',
|
|
149
|
+
'**/*.json',
|
|
150
|
+
];
|
|
151
|
+
|
|
125
152
|
function getFile(file) {
|
|
126
153
|
file = path__default["default"].resolve(file);
|
|
127
154
|
if (!fs__default["default"].existsSync(file)) {
|
|
@@ -154,7 +181,15 @@ function convertIndexFile(data, version) {
|
|
|
154
181
|
const reporter = (options, outputOptions, info) => {
|
|
155
182
|
logger__default["default"].log(`${chalk__default["default"].yellow(info.fileName)} ${chalk__default["default"].green(info.bundleSize)} [ gzip: ${chalk__default["default"].green(info.gzipSize)} ]`);
|
|
156
183
|
return '';
|
|
157
|
-
};
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const livereload = require('rollup-plugin-livereload');
|
|
187
|
+
const { string } = require('rollup-plugin-string');
|
|
188
|
+
const { exec, spawn } = require('child_process');
|
|
189
|
+
const readline = require('readline');
|
|
190
|
+
const execAsync = util.promisify(exec);
|
|
191
|
+
const copyFiles = util.promisify(fs__default["default"].copy);
|
|
192
|
+
require('dotenv').config();
|
|
158
193
|
class InnetJS {
|
|
159
194
|
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '*', } = {}) {
|
|
160
195
|
this.projectFolder = path__default["default"].resolve(projectFolder);
|
|
@@ -248,35 +283,30 @@ class InnetJS {
|
|
|
248
283
|
moduleDirectories: [path__default["default"].resolve(this.buildFolder, 'node_modules')]
|
|
249
284
|
}), string({
|
|
250
285
|
include: '**/*.*',
|
|
251
|
-
exclude:
|
|
252
|
-
'**/*.ts',
|
|
253
|
-
'**/*.tsx',
|
|
254
|
-
'**/*.js',
|
|
255
|
-
'**/*.jsx',
|
|
256
|
-
'**/*.json',
|
|
257
|
-
]
|
|
286
|
+
exclude: stringExcludeNode,
|
|
258
287
|
}));
|
|
259
288
|
}
|
|
260
289
|
else {
|
|
261
|
-
inputOptions.plugins
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
'
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
290
|
+
inputOptions.plugins = [
|
|
291
|
+
eslint__default["default"]({
|
|
292
|
+
include: lintIncludeDom,
|
|
293
|
+
}),
|
|
294
|
+
...inputOptions.plugins,
|
|
295
|
+
pluginNodeResolve.nodeResolve(),
|
|
296
|
+
image__default["default"](),
|
|
297
|
+
styles__default["default"]({
|
|
298
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
299
|
+
url: true,
|
|
300
|
+
plugins: [autoprefixer__default["default"]()],
|
|
301
|
+
modules: this.cssModules,
|
|
302
|
+
sourceMap: this.sourcemap,
|
|
303
|
+
minimize: true,
|
|
304
|
+
}),
|
|
305
|
+
string({
|
|
306
|
+
include: '**/*.*',
|
|
307
|
+
exclude: stringExcludeDom,
|
|
308
|
+
}),
|
|
309
|
+
];
|
|
280
310
|
outputOptions.format = 'es';
|
|
281
311
|
outputOptions.plugins = [
|
|
282
312
|
rollupPluginTerser.terser(),
|
|
@@ -344,13 +374,7 @@ class InnetJS {
|
|
|
344
374
|
moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')]
|
|
345
375
|
}), string({
|
|
346
376
|
include: '**/*.*',
|
|
347
|
-
exclude:
|
|
348
|
-
'**/*.ts',
|
|
349
|
-
'**/*.tsx',
|
|
350
|
-
'**/*.js',
|
|
351
|
-
'**/*.jsx',
|
|
352
|
-
'**/*.json',
|
|
353
|
-
]
|
|
377
|
+
exclude: stringExcludeNode,
|
|
354
378
|
}), this.createServer(options.external));
|
|
355
379
|
}
|
|
356
380
|
else {
|
|
@@ -365,29 +389,49 @@ class InnetJS {
|
|
|
365
389
|
? fs__default["default"].readFileSync(this.sslCrt)
|
|
366
390
|
: undefined;
|
|
367
391
|
options.output.format = 'es';
|
|
368
|
-
options.plugins
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
'
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
392
|
+
options.plugins = [
|
|
393
|
+
eslint__default["default"]({
|
|
394
|
+
include: lintIncludeDom,
|
|
395
|
+
}),
|
|
396
|
+
...options.plugins,
|
|
397
|
+
pluginNodeResolve.nodeResolve(),
|
|
398
|
+
image__default["default"](),
|
|
399
|
+
styles__default["default"]({
|
|
400
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
401
|
+
url: true,
|
|
402
|
+
plugins: [autoprefixer__default["default"]()],
|
|
403
|
+
modules: this.cssModules,
|
|
404
|
+
sourceMap: true,
|
|
405
|
+
}),
|
|
406
|
+
string({
|
|
407
|
+
include: '**/*.*',
|
|
408
|
+
exclude: stringExcludeDom,
|
|
409
|
+
}),
|
|
410
|
+
this.createClient(key, cert, pkg),
|
|
411
|
+
livereload(Object.assign({ watch: this.publicFolder, verbose: false }, (key && cert ? { https: { key, cert } } : {})))
|
|
412
|
+
];
|
|
386
413
|
}
|
|
387
414
|
const watcher = rollup__default["default"].watch(options);
|
|
388
415
|
watcher.on('event', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
389
416
|
if (e.code == 'ERROR') {
|
|
390
|
-
|
|
417
|
+
if (e.error.code === 'UNRESOLVED_IMPORT') {
|
|
418
|
+
const [, importer, file] = e.error.message.match(/^Could not resolve '(.+)' from (.+)$/) || [];
|
|
419
|
+
const text = (yield fs__default["default"].readFile(file)).toString();
|
|
420
|
+
const lines = new linesAndColumns.LinesAndColumns(text);
|
|
421
|
+
const { line, column } = lines.locationForIndex(text.indexOf(importer));
|
|
422
|
+
logger__default["default"].end('Bundling', e.error.message);
|
|
423
|
+
console.log(`ERROR in ${file}:${line + 1}:${column + 1}`);
|
|
424
|
+
}
|
|
425
|
+
else if (e.error.code === 'PLUGIN_ERROR' && ['rpt2', 'commonjs'].includes(e.error.plugin)) {
|
|
426
|
+
const [, file, line, column] = e.error.message.match(/^[^(]+(src[^(]+)\((\d+),(\d+)\)/) || [];
|
|
427
|
+
logger__default["default"].end('Bundling', e.error.message);
|
|
428
|
+
if (file) {
|
|
429
|
+
console.log(`ERROR in ${file}:${line}:${column}`);
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
else {
|
|
433
|
+
logger__default["default"].end('Bundling', error ? e.error.stack : e.error.message);
|
|
434
|
+
}
|
|
391
435
|
}
|
|
392
436
|
else if (e.code === 'BUNDLE_START') {
|
|
393
437
|
logger__default["default"].start('Bundling');
|
|
@@ -536,7 +580,7 @@ class InnetJS {
|
|
|
536
580
|
}
|
|
537
581
|
}
|
|
538
582
|
|
|
539
|
-
var version = "2.0.
|
|
583
|
+
var version = "2.0.3";
|
|
540
584
|
|
|
541
585
|
require('dotenv').config();
|
|
542
586
|
const innetJS = new InnetJS();
|
package/constants.d.ts
ADDED
package/declaration.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
declare module '*.scss' {
|
|
2
|
+
const content: Record<string, string>
|
|
3
|
+
export default content
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module '*.css' {
|
|
7
|
+
const content: Record<string, string>
|
|
8
|
+
export default content
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare module '*.svg' {
|
|
12
|
+
const content: string
|
|
13
|
+
export default content
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
declare module '*.jpg' {
|
|
17
|
+
const content: string
|
|
18
|
+
export default content
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare module '*.jpeg' {
|
|
22
|
+
const content: string
|
|
23
|
+
export default content
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare module '*.png' {
|
|
27
|
+
const content: string
|
|
28
|
+
export default content
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
declare module '*.gif' {
|
|
32
|
+
const content: string
|
|
33
|
+
export default content
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
declare module '*.webp' {
|
|
37
|
+
const content: string
|
|
38
|
+
export default content
|
|
39
|
+
}
|
package/helpers.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { FileSizeRender } from 'rollup-plugin-filesize';
|
|
3
|
+
export declare function getFile(file: any): any;
|
|
4
|
+
export declare function convertIndexFile(data: Buffer, version: string): Promise<string>;
|
|
5
|
+
export declare const reporter: FileSizeRender<string | Promise<string>>;
|
package/index.es6.js
CHANGED
|
@@ -20,6 +20,9 @@ import proxy from 'express-http-proxy';
|
|
|
20
20
|
import selector from 'cli-select';
|
|
21
21
|
import jsx from 'rollup-plugin-innet-jsx';
|
|
22
22
|
import filesize from 'rollup-plugin-filesize';
|
|
23
|
+
import image from '@rollup/plugin-image';
|
|
24
|
+
import eslint from '@rollup/plugin-eslint';
|
|
25
|
+
import { LinesAndColumns } from 'lines-and-columns';
|
|
23
26
|
import { Parse } from 'unzipper';
|
|
24
27
|
|
|
25
28
|
/******************************************************************************
|
|
@@ -89,13 +92,35 @@ function Extract(opts, template) {
|
|
|
89
92
|
return extract;
|
|
90
93
|
}
|
|
91
94
|
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
95
|
+
const lintIncludeDom = [
|
|
96
|
+
'**/*.ts',
|
|
97
|
+
'**/*.tsx',
|
|
98
|
+
'**/*.js',
|
|
99
|
+
'**/*.jsx',
|
|
100
|
+
];
|
|
101
|
+
const stringExcludeDom = [
|
|
102
|
+
'**/*.ts',
|
|
103
|
+
'**/*.tsx',
|
|
104
|
+
'**/*.js',
|
|
105
|
+
'**/*.jsx',
|
|
106
|
+
'**/*.json',
|
|
107
|
+
'**/*.css',
|
|
108
|
+
'**/*.scss',
|
|
109
|
+
'**/*.webp',
|
|
110
|
+
'**/*.gif',
|
|
111
|
+
'**/*.png',
|
|
112
|
+
'**/*.jpeg',
|
|
113
|
+
'**/*.jpg',
|
|
114
|
+
'**/*.svg',
|
|
115
|
+
];
|
|
116
|
+
const stringExcludeNode = [
|
|
117
|
+
'**/*.ts',
|
|
118
|
+
'**/*.tsx',
|
|
119
|
+
'**/*.js',
|
|
120
|
+
'**/*.jsx',
|
|
121
|
+
'**/*.json',
|
|
122
|
+
];
|
|
123
|
+
|
|
99
124
|
function getFile(file) {
|
|
100
125
|
file = path$1.resolve(file);
|
|
101
126
|
if (!fs.existsSync(file)) {
|
|
@@ -128,7 +153,15 @@ function convertIndexFile(data, version) {
|
|
|
128
153
|
const reporter = (options, outputOptions, info) => {
|
|
129
154
|
logger.log(`${chalk.yellow(info.fileName)} ${chalk.green(info.bundleSize)} [ gzip: ${chalk.green(info.gzipSize)} ]`);
|
|
130
155
|
return '';
|
|
131
|
-
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
const livereload = require('rollup-plugin-livereload');
|
|
159
|
+
const { string } = require('rollup-plugin-string');
|
|
160
|
+
const { exec, spawn } = require('child_process');
|
|
161
|
+
const readline = require('readline');
|
|
162
|
+
const execAsync = promisify(exec);
|
|
163
|
+
const copyFiles = promisify(fs.copy);
|
|
164
|
+
require('dotenv').config();
|
|
132
165
|
class InnetJS {
|
|
133
166
|
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '*', } = {}) {
|
|
134
167
|
this.projectFolder = path$1.resolve(projectFolder);
|
|
@@ -222,35 +255,30 @@ class InnetJS {
|
|
|
222
255
|
moduleDirectories: [path$1.resolve(this.buildFolder, 'node_modules')]
|
|
223
256
|
}), string({
|
|
224
257
|
include: '**/*.*',
|
|
225
|
-
exclude:
|
|
226
|
-
'**/*.ts',
|
|
227
|
-
'**/*.tsx',
|
|
228
|
-
'**/*.js',
|
|
229
|
-
'**/*.jsx',
|
|
230
|
-
'**/*.json',
|
|
231
|
-
]
|
|
258
|
+
exclude: stringExcludeNode,
|
|
232
259
|
}));
|
|
233
260
|
}
|
|
234
261
|
else {
|
|
235
|
-
inputOptions.plugins
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
'
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
262
|
+
inputOptions.plugins = [
|
|
263
|
+
eslint({
|
|
264
|
+
include: lintIncludeDom,
|
|
265
|
+
}),
|
|
266
|
+
...inputOptions.plugins,
|
|
267
|
+
nodeResolve(),
|
|
268
|
+
image(),
|
|
269
|
+
styles({
|
|
270
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
271
|
+
url: true,
|
|
272
|
+
plugins: [autoprefixer()],
|
|
273
|
+
modules: this.cssModules,
|
|
274
|
+
sourceMap: this.sourcemap,
|
|
275
|
+
minimize: true,
|
|
276
|
+
}),
|
|
277
|
+
string({
|
|
278
|
+
include: '**/*.*',
|
|
279
|
+
exclude: stringExcludeDom,
|
|
280
|
+
}),
|
|
281
|
+
];
|
|
254
282
|
outputOptions.format = 'es';
|
|
255
283
|
outputOptions.plugins = [
|
|
256
284
|
terser(),
|
|
@@ -318,13 +346,7 @@ class InnetJS {
|
|
|
318
346
|
moduleDirectories: [path$1.resolve(this.srcFolder, 'node_modules')]
|
|
319
347
|
}), string({
|
|
320
348
|
include: '**/*.*',
|
|
321
|
-
exclude:
|
|
322
|
-
'**/*.ts',
|
|
323
|
-
'**/*.tsx',
|
|
324
|
-
'**/*.js',
|
|
325
|
-
'**/*.jsx',
|
|
326
|
-
'**/*.json',
|
|
327
|
-
]
|
|
349
|
+
exclude: stringExcludeNode,
|
|
328
350
|
}), this.createServer(options.external));
|
|
329
351
|
}
|
|
330
352
|
else {
|
|
@@ -339,29 +361,49 @@ class InnetJS {
|
|
|
339
361
|
? fs.readFileSync(this.sslCrt)
|
|
340
362
|
: undefined;
|
|
341
363
|
options.output.format = 'es';
|
|
342
|
-
options.plugins
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
'
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
364
|
+
options.plugins = [
|
|
365
|
+
eslint({
|
|
366
|
+
include: lintIncludeDom,
|
|
367
|
+
}),
|
|
368
|
+
...options.plugins,
|
|
369
|
+
nodeResolve(),
|
|
370
|
+
image(),
|
|
371
|
+
styles({
|
|
372
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
373
|
+
url: true,
|
|
374
|
+
plugins: [autoprefixer()],
|
|
375
|
+
modules: this.cssModules,
|
|
376
|
+
sourceMap: true,
|
|
377
|
+
}),
|
|
378
|
+
string({
|
|
379
|
+
include: '**/*.*',
|
|
380
|
+
exclude: stringExcludeDom,
|
|
381
|
+
}),
|
|
382
|
+
this.createClient(key, cert, pkg),
|
|
383
|
+
livereload(Object.assign({ watch: this.publicFolder, verbose: false }, (key && cert ? { https: { key, cert } } : {})))
|
|
384
|
+
];
|
|
360
385
|
}
|
|
361
386
|
const watcher = rollup.watch(options);
|
|
362
387
|
watcher.on('event', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
363
388
|
if (e.code == 'ERROR') {
|
|
364
|
-
|
|
389
|
+
if (e.error.code === 'UNRESOLVED_IMPORT') {
|
|
390
|
+
const [, importer, file] = e.error.message.match(/^Could not resolve '(.+)' from (.+)$/) || [];
|
|
391
|
+
const text = (yield fs.readFile(file)).toString();
|
|
392
|
+
const lines = new LinesAndColumns(text);
|
|
393
|
+
const { line, column } = lines.locationForIndex(text.indexOf(importer));
|
|
394
|
+
logger.end('Bundling', e.error.message);
|
|
395
|
+
console.log(`ERROR in ${file}:${line + 1}:${column + 1}`);
|
|
396
|
+
}
|
|
397
|
+
else if (e.error.code === 'PLUGIN_ERROR' && ['rpt2', 'commonjs'].includes(e.error.plugin)) {
|
|
398
|
+
const [, file, line, column] = e.error.message.match(/^[^(]+(src[^(]+)\((\d+),(\d+)\)/) || [];
|
|
399
|
+
logger.end('Bundling', e.error.message);
|
|
400
|
+
if (file) {
|
|
401
|
+
console.log(`ERROR in ${file}:${line}:${column}`);
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
logger.end('Bundling', error ? e.error.stack : e.error.message);
|
|
406
|
+
}
|
|
365
407
|
}
|
|
366
408
|
else if (e.code === 'BUNDLE_START') {
|
|
367
409
|
logger.start('Bundling');
|
package/index.js
CHANGED
|
@@ -22,6 +22,9 @@ var proxy = require('express-http-proxy');
|
|
|
22
22
|
var selector = require('cli-select');
|
|
23
23
|
var jsx = require('rollup-plugin-innet-jsx');
|
|
24
24
|
var filesize = require('rollup-plugin-filesize');
|
|
25
|
+
var image = require('@rollup/plugin-image');
|
|
26
|
+
var eslint = require('@rollup/plugin-eslint');
|
|
27
|
+
var linesAndColumns = require('lines-and-columns');
|
|
25
28
|
var unzipper = require('unzipper');
|
|
26
29
|
|
|
27
30
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
@@ -45,6 +48,8 @@ var proxy__default = /*#__PURE__*/_interopDefaultLegacy(proxy);
|
|
|
45
48
|
var selector__default = /*#__PURE__*/_interopDefaultLegacy(selector);
|
|
46
49
|
var jsx__default = /*#__PURE__*/_interopDefaultLegacy(jsx);
|
|
47
50
|
var filesize__default = /*#__PURE__*/_interopDefaultLegacy(filesize);
|
|
51
|
+
var image__default = /*#__PURE__*/_interopDefaultLegacy(image);
|
|
52
|
+
var eslint__default = /*#__PURE__*/_interopDefaultLegacy(eslint);
|
|
48
53
|
|
|
49
54
|
/******************************************************************************
|
|
50
55
|
Copyright (c) Microsoft Corporation.
|
|
@@ -113,13 +118,35 @@ function Extract(opts, template) {
|
|
|
113
118
|
return extract;
|
|
114
119
|
}
|
|
115
120
|
|
|
116
|
-
const
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
const lintIncludeDom = [
|
|
122
|
+
'**/*.ts',
|
|
123
|
+
'**/*.tsx',
|
|
124
|
+
'**/*.js',
|
|
125
|
+
'**/*.jsx',
|
|
126
|
+
];
|
|
127
|
+
const stringExcludeDom = [
|
|
128
|
+
'**/*.ts',
|
|
129
|
+
'**/*.tsx',
|
|
130
|
+
'**/*.js',
|
|
131
|
+
'**/*.jsx',
|
|
132
|
+
'**/*.json',
|
|
133
|
+
'**/*.css',
|
|
134
|
+
'**/*.scss',
|
|
135
|
+
'**/*.webp',
|
|
136
|
+
'**/*.gif',
|
|
137
|
+
'**/*.png',
|
|
138
|
+
'**/*.jpeg',
|
|
139
|
+
'**/*.jpg',
|
|
140
|
+
'**/*.svg',
|
|
141
|
+
];
|
|
142
|
+
const stringExcludeNode = [
|
|
143
|
+
'**/*.ts',
|
|
144
|
+
'**/*.tsx',
|
|
145
|
+
'**/*.js',
|
|
146
|
+
'**/*.jsx',
|
|
147
|
+
'**/*.json',
|
|
148
|
+
];
|
|
149
|
+
|
|
123
150
|
function getFile(file) {
|
|
124
151
|
file = path__default["default"].resolve(file);
|
|
125
152
|
if (!fs__default["default"].existsSync(file)) {
|
|
@@ -152,7 +179,15 @@ function convertIndexFile(data, version) {
|
|
|
152
179
|
const reporter = (options, outputOptions, info) => {
|
|
153
180
|
logger__default["default"].log(`${chalk__default["default"].yellow(info.fileName)} ${chalk__default["default"].green(info.bundleSize)} [ gzip: ${chalk__default["default"].green(info.gzipSize)} ]`);
|
|
154
181
|
return '';
|
|
155
|
-
};
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
const livereload = require('rollup-plugin-livereload');
|
|
185
|
+
const { string } = require('rollup-plugin-string');
|
|
186
|
+
const { exec, spawn } = require('child_process');
|
|
187
|
+
const readline = require('readline');
|
|
188
|
+
const execAsync = util.promisify(exec);
|
|
189
|
+
const copyFiles = util.promisify(fs__default["default"].copy);
|
|
190
|
+
require('dotenv').config();
|
|
156
191
|
class InnetJS {
|
|
157
192
|
constructor({ projectFolder = process.env.PROJECT_FOLDER || '', publicFolder = process.env.PUBLIC_FOLDER || 'public', buildFolder = process.env.BUILD_FOLDER || 'build', srcFolder = process.env.SRC_FOLDER || 'src', sourcemap = process.env.SOURCEMAP ? process.env.SOURCEMAP === 'true' : false, cssModules = process.env.CSS_MODULES ? process.env.CSS_MODULES === 'true' : true, cssInJs = process.env.CSS_IN_JS ? process.env.CSS_IN_JS === 'true' : true, sslKey = process.env.SSL_KEY || 'localhost.key', sslCrt = process.env.SSL_CRT || 'localhost.crt', proxy = process.env.PROXY || '', port = process.env.PORT ? +process.env.PORT : 3000, api = process.env.API || '*', } = {}) {
|
|
158
193
|
this.projectFolder = path__default["default"].resolve(projectFolder);
|
|
@@ -246,35 +281,30 @@ class InnetJS {
|
|
|
246
281
|
moduleDirectories: [path__default["default"].resolve(this.buildFolder, 'node_modules')]
|
|
247
282
|
}), string({
|
|
248
283
|
include: '**/*.*',
|
|
249
|
-
exclude:
|
|
250
|
-
'**/*.ts',
|
|
251
|
-
'**/*.tsx',
|
|
252
|
-
'**/*.js',
|
|
253
|
-
'**/*.jsx',
|
|
254
|
-
'**/*.json',
|
|
255
|
-
]
|
|
284
|
+
exclude: stringExcludeNode,
|
|
256
285
|
}));
|
|
257
286
|
}
|
|
258
287
|
else {
|
|
259
|
-
inputOptions.plugins
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
'
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
288
|
+
inputOptions.plugins = [
|
|
289
|
+
eslint__default["default"]({
|
|
290
|
+
include: lintIncludeDom,
|
|
291
|
+
}),
|
|
292
|
+
...inputOptions.plugins,
|
|
293
|
+
pluginNodeResolve.nodeResolve(),
|
|
294
|
+
image__default["default"](),
|
|
295
|
+
styles__default["default"]({
|
|
296
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
297
|
+
url: true,
|
|
298
|
+
plugins: [autoprefixer__default["default"]()],
|
|
299
|
+
modules: this.cssModules,
|
|
300
|
+
sourceMap: this.sourcemap,
|
|
301
|
+
minimize: true,
|
|
302
|
+
}),
|
|
303
|
+
string({
|
|
304
|
+
include: '**/*.*',
|
|
305
|
+
exclude: stringExcludeDom,
|
|
306
|
+
}),
|
|
307
|
+
];
|
|
278
308
|
outputOptions.format = 'es';
|
|
279
309
|
outputOptions.plugins = [
|
|
280
310
|
rollupPluginTerser.terser(),
|
|
@@ -342,13 +372,7 @@ class InnetJS {
|
|
|
342
372
|
moduleDirectories: [path__default["default"].resolve(this.srcFolder, 'node_modules')]
|
|
343
373
|
}), string({
|
|
344
374
|
include: '**/*.*',
|
|
345
|
-
exclude:
|
|
346
|
-
'**/*.ts',
|
|
347
|
-
'**/*.tsx',
|
|
348
|
-
'**/*.js',
|
|
349
|
-
'**/*.jsx',
|
|
350
|
-
'**/*.json',
|
|
351
|
-
]
|
|
375
|
+
exclude: stringExcludeNode,
|
|
352
376
|
}), this.createServer(options.external));
|
|
353
377
|
}
|
|
354
378
|
else {
|
|
@@ -363,29 +387,49 @@ class InnetJS {
|
|
|
363
387
|
? fs__default["default"].readFileSync(this.sslCrt)
|
|
364
388
|
: undefined;
|
|
365
389
|
options.output.format = 'es';
|
|
366
|
-
options.plugins
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
'
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
390
|
+
options.plugins = [
|
|
391
|
+
eslint__default["default"]({
|
|
392
|
+
include: lintIncludeDom,
|
|
393
|
+
}),
|
|
394
|
+
...options.plugins,
|
|
395
|
+
pluginNodeResolve.nodeResolve(),
|
|
396
|
+
image__default["default"](),
|
|
397
|
+
styles__default["default"]({
|
|
398
|
+
mode: this.cssInJs ? 'inject' : 'extract',
|
|
399
|
+
url: true,
|
|
400
|
+
plugins: [autoprefixer__default["default"]()],
|
|
401
|
+
modules: this.cssModules,
|
|
402
|
+
sourceMap: true,
|
|
403
|
+
}),
|
|
404
|
+
string({
|
|
405
|
+
include: '**/*.*',
|
|
406
|
+
exclude: stringExcludeDom,
|
|
407
|
+
}),
|
|
408
|
+
this.createClient(key, cert, pkg),
|
|
409
|
+
livereload(Object.assign({ watch: this.publicFolder, verbose: false }, (key && cert ? { https: { key, cert } } : {})))
|
|
410
|
+
];
|
|
384
411
|
}
|
|
385
412
|
const watcher = rollup__default["default"].watch(options);
|
|
386
413
|
watcher.on('event', (e) => __awaiter(this, void 0, void 0, function* () {
|
|
387
414
|
if (e.code == 'ERROR') {
|
|
388
|
-
|
|
415
|
+
if (e.error.code === 'UNRESOLVED_IMPORT') {
|
|
416
|
+
const [, importer, file] = e.error.message.match(/^Could not resolve '(.+)' from (.+)$/) || [];
|
|
417
|
+
const text = (yield fs__default["default"].readFile(file)).toString();
|
|
418
|
+
const lines = new linesAndColumns.LinesAndColumns(text);
|
|
419
|
+
const { line, column } = lines.locationForIndex(text.indexOf(importer));
|
|
420
|
+
logger__default["default"].end('Bundling', e.error.message);
|
|
421
|
+
console.log(`ERROR in ${file}:${line + 1}:${column + 1}`);
|
|
422
|
+
}
|
|
423
|
+
else if (e.error.code === 'PLUGIN_ERROR' && ['rpt2', 'commonjs'].includes(e.error.plugin)) {
|
|
424
|
+
const [, file, line, column] = e.error.message.match(/^[^(]+(src[^(]+)\((\d+),(\d+)\)/) || [];
|
|
425
|
+
logger__default["default"].end('Bundling', e.error.message);
|
|
426
|
+
if (file) {
|
|
427
|
+
console.log(`ERROR in ${file}:${line}:${column}`);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
logger__default["default"].end('Bundling', error ? e.error.stack : e.error.message);
|
|
432
|
+
}
|
|
389
433
|
}
|
|
390
434
|
else if (e.code === 'BUNDLE_START') {
|
|
391
435
|
logger__default["default"].start('Bundling');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "innetjs",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3",
|
|
4
4
|
"description": "CLI for innet boilerplate",
|
|
5
5
|
"homepage": "https://github.com/d8corp/innetjs",
|
|
6
6
|
"author": "Mikhail Lysikov <d8corp@mail.ru>",
|
|
@@ -33,6 +33,8 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@cantinc/logger": "^1.1.0",
|
|
35
35
|
"@rollup/plugin-commonjs": "^22.0.2",
|
|
36
|
+
"@rollup/plugin-eslint": "^8.0.2",
|
|
37
|
+
"@rollup/plugin-image": "^2.1.1",
|
|
36
38
|
"@rollup/plugin-json": "^4.1.0",
|
|
37
39
|
"@rollup/plugin-node-resolve": "^13.3.0",
|
|
38
40
|
"autoprefixer": "^10.4.8",
|
|
@@ -44,12 +46,12 @@
|
|
|
44
46
|
"express": "^4.18.1",
|
|
45
47
|
"express-http-proxy": "^1.6.3",
|
|
46
48
|
"fs-extra": "^10.1.0",
|
|
49
|
+
"lines-and-columns": "^2.0.3",
|
|
47
50
|
"node-sass": "^7.0.1",
|
|
48
51
|
"postcss": "^8.4.16",
|
|
49
52
|
"rollup": "^2.77.2",
|
|
50
53
|
"rollup-plugin-filesize": "^9.1.2",
|
|
51
54
|
"rollup-plugin-innet-jsx": "^1.3.0",
|
|
52
|
-
"rollup-plugin-lit-css": "^4.0.0",
|
|
53
55
|
"rollup-plugin-livereload": "^2.0.5",
|
|
54
56
|
"rollup-plugin-string": "^3.0.0",
|
|
55
57
|
"rollup-plugin-styles": "^4.0.0",
|