neo.mjs 9.10.0 → 9.10.2
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/ServiceWorker.mjs
CHANGED
package/apps/portal/index.html
CHANGED
@@ -2,13 +2,12 @@ import fs from 'fs-extra';
|
|
2
2
|
import path from 'path';
|
3
3
|
import {minify as minifyJs} from 'terser';
|
4
4
|
import {minifyHtml} from './util/minifyHtml.mjs';
|
5
|
-
import {fileURLToPath} from 'url';
|
6
5
|
|
7
6
|
const
|
8
7
|
outputBasePath = 'dist/esm/',
|
9
8
|
// Regex to find import statements with 'node_modules' in the path
|
10
9
|
// It captures the entire import statement (excluding the leading 'import') and the path itself.
|
11
|
-
regexImport = /(import(
|
10
|
+
regexImport = /(import(?:\s*(?:[\w*{}\n\r\t, ]+from\s*)?|\s*\(\s*)?)(["'`])((?:(?!\2).)*node_modules(?:(?!\2).)*)\2/g,
|
12
11
|
root = path.resolve(),
|
13
12
|
requireJson = path => JSON.parse(fs.readFileSync(path, 'utf-8')),
|
14
13
|
packageJson = requireJson(path.join(root, 'package.json')),
|
@@ -23,6 +22,32 @@ if (insideNeo) {
|
|
23
22
|
inputDirectories = ['apps', 'docs', 'node_modules/neo.mjs/src', 'src']
|
24
23
|
}
|
25
24
|
|
25
|
+
/**
|
26
|
+
* @param {String} match
|
27
|
+
* @param {String} p1 will be "import {marked} from " (or similar, including the 'import' keyword and everything up to the first quote)
|
28
|
+
* @param {String} p2 will be the quote character (', ", or `)
|
29
|
+
* @param {String} p3 will be the original path string (e.g., '../../../../node_modules/marked/lib/marked.esm.js')
|
30
|
+
* @returns {String}
|
31
|
+
*/
|
32
|
+
function adjustImportPathHandler(match, p1, p2, p3) {
|
33
|
+
let newPath;
|
34
|
+
|
35
|
+
if (p3.includes('/node_modules/neo.mjs/')) {
|
36
|
+
newPath = p3.replace('/node_modules/neo.mjs/', '/')
|
37
|
+
} else {
|
38
|
+
newPath = '../../' + p3; // Prepend 2 levels up
|
39
|
+
}
|
40
|
+
|
41
|
+
// Reconstruct the import statement with the new path
|
42
|
+
return p1 + p2 + newPath + p2
|
43
|
+
}
|
44
|
+
|
45
|
+
/**
|
46
|
+
*
|
47
|
+
* @param {String} inputDir
|
48
|
+
* @param {String} outputDir
|
49
|
+
* @returns {Promise<void>}
|
50
|
+
*/
|
26
51
|
async function minifyDirectory(inputDir, outputDir) {
|
27
52
|
if (fs.existsSync(inputDir)) {
|
28
53
|
fs.mkdirSync(outputDir, {recursive: true});
|
@@ -74,6 +99,11 @@ async function minifyDirectory(inputDir, outputDir) {
|
|
74
99
|
}
|
75
100
|
}
|
76
101
|
|
102
|
+
/**
|
103
|
+
* @param {String} content
|
104
|
+
* @param {String} outputPath
|
105
|
+
* @returns {Promise<void>}
|
106
|
+
*/
|
77
107
|
async function minifyFile(content, outputPath) {
|
78
108
|
fs.mkdirSync(path.dirname(outputPath), {recursive: true});
|
79
109
|
|
@@ -88,7 +118,11 @@ async function minifyFile(content, outputPath) {
|
|
88
118
|
environment : 'dist/esm',
|
89
119
|
mainPath : './Main.mjs',
|
90
120
|
workerBasePath: jsonContent.basePath + 'src/worker/'
|
91
|
-
})
|
121
|
+
});
|
122
|
+
|
123
|
+
if (!insideNeo) {
|
124
|
+
jsonContent.appPath = jsonContent.appPath.substring(6)
|
125
|
+
}
|
92
126
|
}
|
93
127
|
|
94
128
|
fs.writeFileSync(outputPath, JSON.stringify(jsonContent));
|
@@ -103,16 +137,7 @@ async function minifyFile(content, outputPath) {
|
|
103
137
|
}
|
104
138
|
// Minify JS files
|
105
139
|
else if (outputPath.endsWith('.mjs')) {
|
106
|
-
let adjustedContent = content.replace(regexImport,
|
107
|
-
// p1 will be "import {marked} from " (or similar, including the 'import' keyword and everything up to the first quote)
|
108
|
-
// p2 will be the quote character (', ", or `)
|
109
|
-
// p3 will be the original path string (e.g., '../../../../node_modules/marked/lib/marked.esm.js')
|
110
|
-
|
111
|
-
const newPath = '../../' + p3; // Prepend 2 levels up
|
112
|
-
|
113
|
-
// Reconstruct the import statement with the new path
|
114
|
-
return p1 + p2 + newPath + p2
|
115
|
-
});
|
140
|
+
let adjustedContent = content.replace(regexImport, adjustImportPathHandler);
|
116
141
|
|
117
142
|
const result = await minifyJs(adjustedContent, {
|
118
143
|
module: true,
|
package/package.json
CHANGED
package/src/DefaultConfig.mjs
CHANGED
@@ -264,12 +264,12 @@ const DefaultConfig = {
|
|
264
264
|
useVdomWorker: true,
|
265
265
|
/**
|
266
266
|
* buildScripts/injectPackageVersion.mjs will update this value
|
267
|
-
* @default '9.10.
|
267
|
+
* @default '9.10.2'
|
268
268
|
* @memberOf! module:Neo
|
269
269
|
* @name config.version
|
270
270
|
* @type String
|
271
271
|
*/
|
272
|
-
version: '9.10.
|
272
|
+
version: '9.10.2'
|
273
273
|
};
|
274
274
|
|
275
275
|
Object.assign(DefaultConfig, {
|