@mikro-orm/decorators 7.0.5-dev.6 → 7.0.5-dev.7

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.
Files changed (2) hide show
  1. package/package.json +2 -2
  2. package/utils.js +13 -9
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mikro-orm/decorators",
3
- "version": "7.0.5-dev.6",
3
+ "version": "7.0.5-dev.7",
4
4
  "description": "TypeScript ORM for Node.js based on Data Mapper, Unit of Work and Identity Map patterns. Supports MongoDB, MySQL, PostgreSQL and SQLite databases as well as usage with vanilla JavaScript.",
5
5
  "keywords": [
6
6
  "data-mapper",
@@ -52,7 +52,7 @@
52
52
  "@mikro-orm/core": "^7.0.4"
53
53
  },
54
54
  "peerDependencies": {
55
- "@mikro-orm/core": "7.0.5-dev.6",
55
+ "@mikro-orm/core": "7.0.5-dev.7",
56
56
  "reflect-metadata": "^0.1.0 || ^0.2.0"
57
57
  },
58
58
  "peerDependenciesMeta": {
package/utils.js CHANGED
@@ -87,16 +87,20 @@ export function lookupPathFromDecorator(name, stack) {
87
87
  // Reflect.decorate() as well. Also when babel is used, we need to check
88
88
  // the `_applyDecoratedDescriptor` method instead.
89
89
  let line = stack.findIndex(line => /__decorate|Reflect\.decorate|_applyDecoratedDescriptor/.exec(line));
90
- // bun does not have those lines at all, only the DecorateProperty/DecorateConstructor,
91
- // but those are also present in node, so we need to check this only if they weren't found.
90
+ // Bun can skip decorator helper frames. Native ES decorators expose the entity
91
+ // path right after `bun:wrap`, while reflect-metadata stacks reach it via Reflect.js.
92
92
  if (line === -1) {
93
- // here we handle bun which stack is different from nodejs so we search for reflect-metadata
94
- // Different bun versions might have different stack traces. The "last index" works for both 1.2.6 and 1.2.7.
95
- const reflectLine = stack.findLastIndex(line => line.replace(/\\/g, '/').includes('node_modules/reflect-metadata/Reflect.js'));
96
- if (reflectLine === -1 || reflectLine + 2 >= stack.length || !stack[reflectLine + 1].includes('bun:wrap')) {
97
- return name;
93
+ const bunWrapLine = stack.findLastIndex(stackLine => stackLine.includes('bun:wrap'));
94
+ if (bunWrapLine !== -1 && bunWrapLine + 1 < stack.length) {
95
+ line = bunWrapLine + 1;
96
+ }
97
+ else {
98
+ const reflectLine = stack.findLastIndex(stackLine => stackLine.replace(/\\/g, '/').includes('node_modules/reflect-metadata/Reflect.js'));
99
+ if (reflectLine === -1 || reflectLine + 2 >= stack.length || !stack[reflectLine + 1].includes('bun:wrap')) {
100
+ return name;
101
+ }
102
+ line = reflectLine + 2;
98
103
  }
99
- line = reflectLine + 2;
100
104
  }
101
105
  if (stack[line].includes('Reflect.decorate')) {
102
106
  line++;
@@ -108,7 +112,7 @@ export function lookupPathFromDecorator(name, stack) {
108
112
  line++;
109
113
  }
110
114
  try {
111
- const re = /\(.+\)/i.exec(stack[line]) ? /\((.*):\d+:\d+\)/ : /at\s*(.*):\d+:\d+$/;
115
+ const re = /\(.+\)/i.exec(stack[line]) ? /\((.*?)(?::\d+){1,2}\)/ : /at\s*(.*?)(?::\d+){1,2}$/;
112
116
  return stack[line].match(re)[1];
113
117
  }
114
118
  catch {