rajt 0.0.102 → 0.0.103

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rajt",
3
3
  "description": "A serverless bundler layer, fully typed for AWS Lambda (Node.js and LLRT) and Cloudflare Workers.",
4
- "version": "0.0.102",
4
+ "version": "0.0.103",
5
5
  "type": "module",
6
6
  "main": "./src/index.ts",
7
7
  "files": ["bin", "src"],
package/src/register.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { isProd } from './utils/environment'
2
+ const isPrd = isProd()
3
+
1
4
  export const handlers: Record<string, Function> = {}
2
5
 
3
6
  export function registerHandler(id: string, handler: any) {
@@ -6,7 +9,7 @@ export function registerHandler(id: string, handler: any) {
6
9
 
7
10
  export function getHandler(id: string): Function {
8
11
  const handler = handlers[id] || null
9
- if (!handler) throw new Error(`Handler ${id} not registered`)
12
+ if (isPrd && !handler) throw new Error(`Handler ${id} not registered`)
10
13
  return handler
11
14
  }
12
15
 
@@ -11,7 +11,7 @@ export function detectEnvironment(): symbol {
11
11
  try {
12
12
  if (
13
13
  process.env?.npm_lifecycle_event === 'dev'
14
- || process.env?.npm_lifecycle_script === 'rajt'
14
+ || process.env?.npm_lifecycle_script?.startsWith('rajt')
15
15
  || process.env?.AWS_SAM_LOCAL
16
16
  // || process?.argv?.includes('--dev')
17
17
  || process?.argv?.some(arg => ['-port', '-platform', '--dev', '--development', '--watch'].includes(arg))
@@ -6,6 +6,8 @@ export function resolve(...objs: any[]) {
6
6
  if (typeof obj === 'string')
7
7
  obj = getHandler(obj)
8
8
 
9
+ if (obj == null) continue
10
+
9
11
  if (typeof obj === 'function' && obj?.length === 2) {
10
12
 
11
13
  } else if (obj?.run) {