@nlabs/lex 1.52.13 → 1.52.15
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/jest.config.mjs +7 -1
- package/package.json +2 -1
- package/webpack.config.js +73 -7
package/jest.config.mjs
CHANGED
|
@@ -17,7 +17,7 @@ if(process.env.LEX_CONFIG) {
|
|
|
17
17
|
try {
|
|
18
18
|
const lexConfig = JSON.parse(process.env.LEX_CONFIG);
|
|
19
19
|
projectJestConfig = lexConfig.jest;
|
|
20
|
-
} catch
|
|
20
|
+
} catch(error) {
|
|
21
21
|
// eslint-disable-next-line no-console
|
|
22
22
|
console.warn('Failed to parse LEX_CONFIG:', error.message);
|
|
23
23
|
}
|
|
@@ -44,12 +44,18 @@ const baseConfig = {
|
|
|
44
44
|
testRegex: '(/__tests__/.*|\\.(test|spec|integration))\\.(ts|tsx)?$',
|
|
45
45
|
transform: {
|
|
46
46
|
'^.+\\.js$|^.+\\.jsx$': ['babel-jest', {
|
|
47
|
+
plugins: [
|
|
48
|
+
'babel-plugin-transform-import-meta'
|
|
49
|
+
],
|
|
47
50
|
presets: [
|
|
48
51
|
['@babel/preset-env', {targets: {node: 'current'}}],
|
|
49
52
|
'@babel/preset-typescript'
|
|
50
53
|
]
|
|
51
54
|
}],
|
|
52
55
|
'^.+\\.ts$|^.+\\.tsx$': ['babel-jest', {
|
|
56
|
+
plugins: [
|
|
57
|
+
'babel-plugin-transform-import-meta'
|
|
58
|
+
],
|
|
53
59
|
presets: [
|
|
54
60
|
['@babel/preset-env', {targets: {node: 'current'}}],
|
|
55
61
|
'@babel/preset-typescript',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nlabs/lex",
|
|
3
|
-
"version": "1.52.
|
|
3
|
+
"version": "1.52.15",
|
|
4
4
|
"description": "Lex",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -111,6 +111,7 @@
|
|
|
111
111
|
"autoprefixer": "^10.4.23",
|
|
112
112
|
"babel-jest": "^30.2.0",
|
|
113
113
|
"babel-loader": "^10.0.0",
|
|
114
|
+
"babel-plugin-transform-import-meta": "^2.1.0",
|
|
114
115
|
"boxen": "8.0.1",
|
|
115
116
|
"buffer": "^6.0.3",
|
|
116
117
|
"caniuse-lite": "1.0.30001761",
|
package/webpack.config.js
CHANGED
|
@@ -15,7 +15,6 @@ import FaviconsWebpackPlugin from 'favicons-webpack-plugin';
|
|
|
15
15
|
import {existsSync} from 'fs';
|
|
16
16
|
import {sync as globSync} from 'glob';
|
|
17
17
|
import HtmlWebPackPlugin from 'html-webpack-plugin';
|
|
18
|
-
import MiniCssExtractPlugin from 'mini-css-extract-plugin';
|
|
19
18
|
import isEmpty from 'lodash/isEmpty.js';
|
|
20
19
|
import {resolve as pathResolve} from 'path';
|
|
21
20
|
import postcssBrowserReporter from 'postcss-browser-reporter';
|
|
@@ -199,6 +198,7 @@ const watchIgnorePaths = [
|
|
|
199
198
|
const imagePath = `${sourceFullPath}/images/`;
|
|
200
199
|
const fontPath = `${sourceFullPath}/fonts/`;
|
|
201
200
|
const docPath = `${sourceFullPath}/docs/`;
|
|
201
|
+
const iconPath = `${sourceFullPath}/icons/`;
|
|
202
202
|
|
|
203
203
|
const staticPathFull = pathResolve(process.cwd(), webpackStaticPath);
|
|
204
204
|
|
|
@@ -228,6 +228,18 @@ if(existsSync(docPath)) {
|
|
|
228
228
|
staticPaths.push({from: docPath, noErrorOnMissing: true, to: './docs/'});
|
|
229
229
|
}
|
|
230
230
|
|
|
231
|
+
if(existsSync(iconPath)) {
|
|
232
|
+
staticPaths.push({
|
|
233
|
+
from: iconPath,
|
|
234
|
+
globOptions: {
|
|
235
|
+
ignore: ['**/*.svg']
|
|
236
|
+
},
|
|
237
|
+
noErrorOnMissing: true,
|
|
238
|
+
to: './icons/'
|
|
239
|
+
});
|
|
240
|
+
watchIgnorePaths.push(iconPath);
|
|
241
|
+
}
|
|
242
|
+
|
|
231
243
|
if(staticPaths.length) {
|
|
232
244
|
plugins.push(new CopyWebpackPlugin({patterns: staticPaths}));
|
|
233
245
|
}
|
|
@@ -683,10 +695,6 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
683
695
|
const fileIndex = pathUrl.length > 1 ? pathUrl.length - 1 : 0;
|
|
684
696
|
return `/${pathUrl[fileIndex]}`;
|
|
685
697
|
}
|
|
686
|
-
},
|
|
687
|
-
{
|
|
688
|
-
from: /\\.(css|gif|ico|jpg|json|png|svg|txt)$/,
|
|
689
|
-
to: ({parsedUrl: {pathname}}) => pathname
|
|
690
698
|
}
|
|
691
699
|
],
|
|
692
700
|
verbose: !(process.env.LEX_QUIET === 'true')
|
|
@@ -694,13 +702,59 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
694
702
|
hmr: false,
|
|
695
703
|
log: {level: 'trace'},
|
|
696
704
|
middleware: (app, builtins) => {
|
|
705
|
+
const koaStatic = require('koa-static');
|
|
706
|
+
const {readFileSync} = require('fs');
|
|
707
|
+
|
|
708
|
+
app.use(async (ctx, next) => {
|
|
709
|
+
const path = ctx.path || ctx.url || '';
|
|
710
|
+
const isStaticFile = path && /\.(css|gif|ico|jpg|jpeg|json|png|svg|txt|woff|woff2|ttf|eot)$/i.test(path);
|
|
711
|
+
|
|
712
|
+
if(isStaticFile && outputFullPath) {
|
|
713
|
+
const filePath = pathResolve(outputFullPath, path.replace(/^\//, ''));
|
|
714
|
+
if(existsSync(filePath)) {
|
|
715
|
+
try {
|
|
716
|
+
ctx.type = path.match(/\.svg$/i) ? 'image/svg+xml' :
|
|
717
|
+
path.match(/\.(jpg|jpeg|png|gif)$/i) ? 'image/' + path.split('.').pop() :
|
|
718
|
+
path.match(/\.css$/i) ? 'text/css' :
|
|
719
|
+
'application/octet-stream';
|
|
720
|
+
ctx.body = readFileSync(filePath);
|
|
721
|
+
ctx.status = 200;
|
|
722
|
+
|
|
723
|
+
return;
|
|
724
|
+
} catch(err) {
|
|
725
|
+
if (process.env.LEX_CONFIG_DEBUG) {
|
|
726
|
+
console.log(`[LEX_DEBUG] Error reading file ${filePath}:`, err.message);
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
} else {
|
|
730
|
+
if (process.env.LEX_CONFIG_DEBUG) {
|
|
731
|
+
console.log(`[LEX_DEBUG] File not found at: ${filePath}, outputFullPath: ${outputFullPath}, path: ${path}`);
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
|
|
736
|
+
await next();
|
|
737
|
+
});
|
|
738
|
+
|
|
739
|
+
if(outputFullPath && existsSync(outputFullPath)) {
|
|
740
|
+
if (process.env.LEX_CONFIG_DEBUG) {
|
|
741
|
+
console.log(`[LEX_DEBUG] Setting up static file serving from output: ${outputFullPath}`);
|
|
742
|
+
}
|
|
743
|
+
|
|
744
|
+
app.use(koaStatic(outputFullPath, {
|
|
745
|
+
index: false,
|
|
746
|
+
defer: false,
|
|
747
|
+
hidden: false,
|
|
748
|
+
gzip: true,
|
|
749
|
+
br: false
|
|
750
|
+
}));
|
|
751
|
+
}
|
|
752
|
+
|
|
697
753
|
if(existsSync(staticPathFull)) {
|
|
698
754
|
if (process.env.LEX_CONFIG_DEBUG) {
|
|
699
755
|
console.log(`[LEX_DEBUG] Setting up static file serving from: ${staticPathFull}`);
|
|
700
756
|
}
|
|
701
757
|
|
|
702
|
-
const koaStatic = require('koa-static');
|
|
703
|
-
|
|
704
758
|
app.use(koaStatic(staticPathFull, {
|
|
705
759
|
index: false, // Don't auto-serve index files
|
|
706
760
|
defer: false, // CRITICAL: Don't defer - serve immediately if file exists
|
|
@@ -727,6 +781,18 @@ export default (webpackEnv, webpackOptions) => {
|
|
|
727
781
|
}
|
|
728
782
|
}
|
|
729
783
|
|
|
784
|
+
app.use(async (ctx, next) => {
|
|
785
|
+
const path = ctx.path || ctx.url || '';
|
|
786
|
+
const isStaticFile = path && /\.(css|gif|ico|jpg|jpeg|json|png|svg|txt|woff|woff2|ttf|eot)$/i.test(path);
|
|
787
|
+
|
|
788
|
+
await next();
|
|
789
|
+
|
|
790
|
+
if(isStaticFile && ctx.status === 404) {
|
|
791
|
+
ctx.body = 'File not found';
|
|
792
|
+
return;
|
|
793
|
+
}
|
|
794
|
+
});
|
|
795
|
+
|
|
730
796
|
app.use(async (ctx, next) => {
|
|
731
797
|
const path = ctx.path || ctx.url || (ctx.request && ctx.request.path) || '';
|
|
732
798
|
if(path && path.match(/^\/wps/)) {
|