@shijiu/jsview 1.9.825 → 1.9.837

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.
@@ -52,6 +52,9 @@ export default class JsViewLoader {
52
52
  // 加载jsv-dom的调试版本
53
53
  await import("../dom/jsv-browser-debug-dom.js");
54
54
 
55
+ // 将jsv-forge-define单独做chunk, 解决npm run build后出现的循环import问题。
56
+ await import("../dom/jsv-forge-define.js");
57
+
55
58
  this.#forgeAppClass = JsViewBrowserForgeApp;
56
59
  }
57
60
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shijiu/jsview",
3
- "version": "1.9.825",
3
+ "version": "1.9.837",
4
4
  "bin": {
5
5
  "jsview-post-build": "./tools/jsview-post-build.js",
6
6
  "jsview-post-install": "./tools/jsview-post-install.js"
@@ -25,7 +25,11 @@ const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
25
25
  // like /todos/42/static/js/bundle.7289d.js. We have to know the root.
26
26
  const publicUrlOrPath = getPublicUrlOrPath(
27
27
  process.env.NODE_ENV === 'development',
28
- require(resolveApp('package.json')).homepage,
28
+ // JsView Modified >>>
29
+ // index.html 使用相对路径
30
+ //require(resolveApp('package.json')).homepage,
31
+ require(resolveApp('package.json')).homepage ?? './',
32
+ // JsView Modified <<<
29
33
  process.env.PUBLIC_URL
30
34
  );
31
35
 
@@ -6,6 +6,7 @@ import fullReload from 'vite-plugin-full-reload';
6
6
  // https://vitejs.dev/config/
7
7
  const jsviewConfig = defineConfig({
8
8
  assetsInclude: ['**/*.bmp'],
9
+ base: './', // index.html 使用相对路径
9
10
  build: {
10
11
  assetsInlineLimit: 0,
11
12
  //cssTarget: 'css/', // 未生效
@@ -23,12 +24,15 @@ const jsviewConfig = defineConfig({
23
24
  },
24
25
  rollupOptions: {
25
26
  output: {
26
- format: 'esm',
27
- entryFileNames: 'js/main.jsv.[hash].js',
27
+ assetFileNames: (chunkInfo) => chunkInfo.name.endsWith('.css')
28
+ ? 'css/[name].[hash].css' : 'assets/[name].[hash].[ext]',
28
29
  //chunkFileNames: 'js/[name].[hash].js',
29
30
  chunkFileNames: 'js/chunk.jsv.[hash].js',
30
- assetFileNames: (chunkInfo) => chunkInfo.name.endsWith('.css')
31
- ? 'css/[name].[hash].css' : 'assets/[name].[hash].[ext]'
31
+ entryFileNames: 'js/main.jsv.[hash].js',
32
+ format: 'esm',
33
+ manualChunks: {
34
+ 'vue': ['vue', '\0plugin-vue:export-helper'], // 将vue和_export_sfc独立出来,防止被集成在main.js中导致import deadloop.
35
+ },
32
36
  },
33
37
  },
34
38
  sourcemap: true,
@@ -152,4 +156,4 @@ function jsvSaveUrlToCache(urls) {
152
156
  export {
153
157
  jsvCreateJsViewViteConfig,
154
158
  jsvSaveUrlToCache,
155
- }
159
+ }
@@ -179,7 +179,7 @@ function getOptions(framework)
179
179
  options.jsviewPatchesDir = path.resolve(options.jsviewDir, 'patches');
180
180
  options.jsviewPatchModulesDir = path.resolve(options.jsviewPatchesDir, 'node_modules');
181
181
  options.jsviewToolsDir = path.resolve(options.jsviewDir, 'tools');
182
- options.jsviewRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
182
+ options.jsviewDomRevisionFile = path.resolve(options.jsviewDir, 'dom', 'target_core_revision.mjs');
183
183
 
184
184
  options.jsviewVueDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-vue');
185
185
  options.jsviewReactDir = path.resolve(options.modulesDir, '@shijiu', 'jsview-react');
@@ -244,7 +244,7 @@ function cpSync(workDir, srcPath, destPath, ignore=[])
244
244
 
245
245
  function rmSync(workDir, filePath)
246
246
  {
247
- const desc = ' -x ' + path.relative(workDir, filePath);
247
+ const desc = ' -* ' + path.relative(workDir, filePath);
248
248
  console.info(desc);
249
249
  fs.rmSync(filePath, { recursive: true, force: true });
250
250
  }
@@ -255,7 +255,7 @@ function symlinkSync(workDir, targetPath, toPath)
255
255
 
256
256
  const relativePath = path.relative(path.dirname(toPath), targetPath);
257
257
 
258
- const desc = ' ' + path.relative(workDir, toPath) + ' -* ' + path.relative(workDir, relativePath);
258
+ const desc = ' ' + path.relative(workDir, toPath) + ' -< ' + path.relative(workDir, relativePath);
259
259
  console.info(desc);
260
260
  fs.symlinkSync(relativePath, toPath, 'dir');
261
261
  }
@@ -286,7 +286,20 @@ function execCommand(cmdline, withOutput)
286
286
  }
287
287
  }
288
288
 
289
+ function checkNodeVersion(minMajorVersion = 16)
290
+ {
291
+ const versions = process.version.replace('v', '').split('.');
292
+ const [majorVersion, minorVersion, patchVersion] = versions;
293
+
294
+ console.log(`Node version: v${majorVersion}.${minorVersion}.${patchVersion}`);
295
+ if (majorVersion < minMajorVersion) {
296
+ console.error('JsView Error: Node version is too low! Please upgrade your Node.js first.');
297
+ process.exit(1);
298
+ }
299
+ }
300
+
289
301
  module.exports = {
302
+ checkNodeVersion,
290
303
  cpSync,
291
304
  execCommand,
292
305
  getOptions,
@@ -4,7 +4,10 @@
4
4
  const crypto = require('crypto');
5
5
  const fs = require('fs');
6
6
  const path = require('path');
7
- const { getOptions } = require('./jsview-common');
7
+ const {
8
+ checkNodeVersion,
9
+ getOptions,
10
+ } = require('./jsview-common');
8
11
 
9
12
  // main.js处理AppData信息
10
13
  async function prepareMainAppData(options, fileMd5)
@@ -175,6 +178,8 @@ function makeDebugMap(options)
175
178
 
176
179
  async function main()
177
180
  {
181
+ checkNodeVersion();
182
+
178
183
  const options = getOptions();
179
184
 
180
185
  const vueConfigFile = path.resolve(options.projectDir, 'vue.config.js');
@@ -5,6 +5,7 @@ const fs = require('fs');
5
5
  const path = require('path');
6
6
  const url = require('url');
7
7
  const {
8
+ checkNodeVersion,
8
9
  cpSync,
9
10
  execCommand,
10
11
  getOptions,
@@ -33,9 +34,16 @@ function checkNpmCommand()
33
34
 
34
35
  function checkNpmLinkForDebug(options, linkablePkgNames)
35
36
  {
37
+ const pkgObj = getPackageObject(options.projectDir);
38
+
36
39
  // node 16 不会安装本地包的二次依赖, 需要手动安装。
37
40
  let missingDepPkgs = '';
38
41
  for (const linkableName of linkablePkgNames) {
42
+ let linkableTarget = pkgObj.dependencies?.[linkableName];
43
+ if (!linkableTarget || !linkableTarget.startsWith('file:')) {
44
+ continue;
45
+ }
46
+
39
47
  const linkablePath = path.resolve(options.modulesDir, linkableName);
40
48
  const linkablePkgObj = getPackageObject(linkablePath);
41
49
 
@@ -59,11 +67,12 @@ function checkNpmLinkForDebug(options, linkablePkgNames)
59
67
  missingDepPkgs += ' ' + devDepPkg;
60
68
  }
61
69
  }
62
- console.log('Install missing dependencies')
63
- execCommand('npm install --no-save ' + missingDepPkgs);
70
+ if (missingDepPkgs !== '') {
71
+ console.log('Install missing dependencies')
72
+ execCommand('npm install --no-save ' + missingDepPkgs);
73
+ }
64
74
 
65
75
  // node 18 不会将本地依赖安装成链接,需要手动改成链接。
66
- const pkgObj = getPackageObject(options.projectDir);
67
76
  for (const linkableName of linkablePkgNames) {
68
77
  let linkableTarget = pkgObj.dependencies?.[linkableName];
69
78
  if (!linkableTarget || !linkableTarget.startsWith('file:')) {
@@ -119,7 +128,7 @@ function installPatches(options, pkgNeedPatch)
119
128
 
120
129
  async function printRevision(options)
121
130
  {
122
- const jsviewVersionURL = url.pathToFileURL(options.jsviewRevisionFile);
131
+ const jsviewVersionURL = url.pathToFileURL(options.jsviewDomRevisionFile);
123
132
  const { default: jsviewTargetVersion } = await import(jsviewVersionURL);
124
133
 
125
134
  console.log('**************************************************');
@@ -161,24 +170,11 @@ function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
161
170
 
162
171
  const linkablePkgNames = [
163
172
  '@shijiu/jsview',
173
+ '@shijiu/jsview-vue',
174
+ '@shijiu/jsview-vue-samples',
175
+ '@shijiu/jsview-react',
176
+ '@shijiu/jsview-react-samples',
164
177
  ];
165
- switch (framework) {
166
- case 'vue':
167
- linkablePkgNames.push(
168
- '@shijiu/jsview-vue',
169
- '@shijiu/jsview-vue-samples',
170
- )
171
- break;
172
- case 'react':
173
- linkablePkgNames.push(
174
- '@shijiu/jsview-react',
175
- '@shijiu/jsview-react-samples',
176
- )
177
- break;
178
- default:
179
- console.error('JsView Error: Bad framework: ' + framework);
180
- break;
181
- }
182
178
 
183
179
  checkNpmCommand();
184
180
 
@@ -193,6 +189,8 @@ function doPostInstall(framework, pkgNeedPatch, skipCheckVersion)
193
189
 
194
190
  function main(argv)
195
191
  {
192
+ checkNodeVersion();
193
+
196
194
  let pkgNeedPatch;
197
195
 
198
196
  switch (argv.framework) {
@@ -5,6 +5,7 @@ const childProcess = require('child_process');
5
5
  const path = require('path');
6
6
  const url = require('url');
7
7
  const {
8
+ checkNodeVersion,
8
9
  getOptions,
9
10
  parseArguments
10
11
  } = require('./jsview-common');
@@ -21,8 +22,8 @@ async function getExtraOptions(argv)
21
22
  options.androidPackage = argv.unparsed[0];
22
23
  }
23
24
 
24
- const jsviewRevisionFile = url.pathToFileURL(options.jsviewRevisionFile);
25
- const { default: jsviewTargetRevision } = await import(jsviewRevisionFile);
25
+ const jsviewDomRevisionFile = url.pathToFileURL(options.jsviewDomRevisionFile);
26
+ const { default: jsviewTargetRevision } = await import(jsviewDomRevisionFile);
26
27
  options.jsviewCoreRevision = jsviewTargetRevision.CoreRevision;
27
28
  options.jsviewEngineUrl = jsviewTargetRevision.JseUrl;
28
29
 
@@ -65,6 +66,8 @@ function androidStartActivity(options)
65
66
 
66
67
  async function main(argv)
67
68
  {
69
+ checkNodeVersion();
70
+
68
71
  const options = await getExtraOptions(argv);
69
72
 
70
73
  printRevision(options);