@voxgig/model 2.2.0 → 2.3.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.
@@ -5,8 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.local_builder = void 0;
7
7
  const path_1 = __importDefault(require("path"));
8
- // import fresh from 'import-fresh'
9
- const clear_module_1 = __importDefault(require("clear-module"));
10
8
  // Runs any builders local to the repo.
11
9
  const local_builder = async (build) => {
12
10
  try {
@@ -27,10 +25,9 @@ const local_builder = async (build) => {
27
25
  let builder = builders[name];
28
26
  let action_path = path_1.default.join(root, builder.load);
29
27
  // TODO: need to watch these files too, and their deps!
30
- // console.log('ACTION PATH', name, action_path)
31
- (0, clear_module_1.default)(action_path);
28
+ console.log('ACTION PATH 1', name, action_path);
29
+ clear(action_path);
32
30
  let action = require(action_path);
33
- // let action: any = fresh(action_path)
34
31
  let br = await action(build.model, build);
35
32
  ok = ok && null != br && br.ok;
36
33
  brlog.push(br);
@@ -43,4 +40,27 @@ const local_builder = async (build) => {
43
40
  }
44
41
  };
45
42
  exports.local_builder = local_builder;
43
+ // Adapted from https://github.com/sindresorhus/import-fresh - Thanks!
44
+ function clear(path) {
45
+ let filePath = require.resolve(path);
46
+ // console.log('CM fp', filePath)
47
+ if (require.cache[filePath]) {
48
+ const children = require.cache[filePath].children.map(child => child.id);
49
+ // console.log('CM-B', filePath, children)
50
+ // Delete module from cache
51
+ delete require.cache[filePath];
52
+ for (const id of children) {
53
+ clear(id);
54
+ }
55
+ }
56
+ if (require.cache[filePath] && require.cache[filePath].parent) {
57
+ let i = require.cache[filePath].parent.children.length;
58
+ // console.log('CM-A', filePath, require.cache[filePath].parent.children)
59
+ while (i--) {
60
+ if (require.cache[filePath].parent.children[i].id === filePath) {
61
+ require.cache[filePath].parent.children.splice(i, 1);
62
+ }
63
+ }
64
+ }
65
+ }
46
66
  //# sourceMappingURL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,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAA;QAEtD,yEAAyE;QAEzE,OAAO,CAAC,EAAE,EAAE,CAAC;YACX,IAAI,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,QAAQ,EAAE,CAAC;gBAC/D,OAAO,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACtD,CAAC;QACH,CAAC;IACH,CAAC;AAEH,CAAC"}
@@ -1,9 +1,6 @@
1
1
 
2
2
  import Path from 'path'
3
3
 
4
- // import fresh from 'import-fresh'
5
- import clear from 'clear-module'
6
-
7
4
  import { Build, Builder } from '../build'
8
5
 
9
6
 
@@ -34,11 +31,10 @@ const local_builder: Builder = async (build: Build) => {
34
31
  let action_path = Path.join(root, builder.load)
35
32
 
36
33
  // TODO: need to watch these files too, and their deps!
37
- // console.log('ACTION PATH', name, action_path)
34
+ console.log('ACTION PATH 1', name, action_path)
38
35
 
39
36
  clear(action_path)
40
37
  let action = require(action_path)
41
- // let action: any = fresh(action_path)
42
38
  let br = await action(build.model, build)
43
39
  ok = ok && null != br && br.ok
44
40
  brlog.push(br)
@@ -52,6 +48,41 @@ const local_builder: Builder = async (build: Build) => {
52
48
 
53
49
  }
54
50
 
51
+
52
+ // Adapted from https://github.com/sindresorhus/import-fresh - Thanks!
53
+ function clear(path: string) {
54
+ let filePath = require.resolve(path)
55
+ // console.log('CM fp', filePath)
56
+
57
+ if (require.cache[filePath]) {
58
+ const children = require.cache[filePath].children.map(child => child.id)
59
+
60
+ // console.log('CM-B', filePath, children)
61
+
62
+ // Delete module from cache
63
+ delete require.cache[filePath]
64
+
65
+ for (const id of children) {
66
+ clear(id)
67
+ }
68
+ }
69
+
70
+
71
+ if (require.cache[filePath] && require.cache[filePath].parent) {
72
+ let i = require.cache[filePath].parent.children.length
73
+
74
+ // console.log('CM-A', filePath, require.cache[filePath].parent.children)
75
+
76
+ while (i--) {
77
+ if (require.cache[filePath].parent.children[i].id === filePath) {
78
+ require.cache[filePath].parent.children.splice(i, 1)
79
+ }
80
+ }
81
+ }
82
+
83
+ }
84
+
85
+
55
86
  export {
56
87
  local_builder
57
88
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@voxgig/model",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "main": "dist/model.js",
5
5
  "type": "commonjs",
6
6
  "types": "dist/model.d.ts",
@@ -46,13 +46,11 @@
46
46
  "dependencies": {
47
47
  "@voxgig/util": "^0.0.3",
48
48
  "aontu": "0.21.1",
49
- "chokidar": "3.6.0",
50
- "clear-module": "^4.1.2",
51
- "import-fresh": "^3.3.0"
49
+ "chokidar": "3.6.0"
52
50
  },
53
51
  "devDependencies": {
54
52
  "@types/jest": "^29.5.12",
55
- "@types/node": "22.1.0",
53
+ "@types/node": "22.3.0",
56
54
  "es-jest": "^2.1.0",
57
55
  "esbuild": "^0.23.0",
58
56
  "esbuild-jest": "^0.5.0",