@ecrindigital/facetpack 0.1.8 → 0.1.10

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/dist/index.cjs CHANGED
@@ -274,13 +274,14 @@ function withFacetpack(config, options = {}) {
274
274
  const useMinifier = options.minifier !== false;
275
275
  const minifierPath = useMinifier ? import_path.join(packageDir, "dist", "minifier.js") : config.transformer?.minifierPath;
276
276
  const minifierConfig = typeof options.minifier === "object" ? options.minifier : {};
277
- const useTreeShake = options.treeShake !== false;
277
+ const useTreeShake = options.treeShake === true;
278
278
  const existingSerializer = config.serializer?.customSerializer;
279
279
  const customSerializer = useTreeShake ? createFacetpackSerializer(existingSerializer, { treeShake: true }) : existingSerializer;
280
280
  const projectRoot = config.projectRoot || process.cwd();
281
281
  const originalTransformerPath = config.transformer?.babelTransformerPath;
282
282
  const fallbackTransformerPath = originalTransformerPath || findFallbackTransformer(projectRoot);
283
283
  storeTransformerOptions(options, fallbackTransformerPath);
284
+ const existingResolver = config.resolver?.resolveRequest;
284
285
  return {
285
286
  ...config,
286
287
  transformer: {
@@ -309,15 +310,16 @@ function withFacetpack(config, options = {}) {
309
310
  ])
310
311
  ],
311
312
  resolveRequest: (context, moduleName, platform) => {
313
+ const fallbackResolver = existingResolver ?? context.resolveRequest;
312
314
  if (context.originModulePath.includes("node_modules")) {
313
- return context.resolveRequest(context, moduleName, platform);
315
+ return fallbackResolver(context, moduleName, platform);
314
316
  }
315
317
  const cached = getCachedResolution(context.originModulePath, moduleName);
316
318
  if (cached !== undefined) {
317
319
  if (cached) {
318
320
  return { type: "sourceFile", filePath: cached };
319
321
  }
320
- return context.resolveRequest(context, moduleName, platform);
322
+ return fallbackResolver(context, moduleName, platform);
321
323
  }
322
324
  const directory = context.originModulePath.substring(0, context.originModulePath.lastIndexOf("/"));
323
325
  const result = import_facetpack_native2.resolveSync(directory, moduleName, {
@@ -328,7 +330,7 @@ function withFacetpack(config, options = {}) {
328
330
  if (result.path) {
329
331
  return { type: "sourceFile", filePath: result.path };
330
332
  }
331
- return context.resolveRequest(context, moduleName, platform);
333
+ return fallbackResolver(context, moduleName, platform);
332
334
  }
333
335
  },
334
336
  serializer: {
@@ -452,9 +454,19 @@ var BABEL_REQUIRED_PATTERNS = [
452
454
  /runOnUI/,
453
455
  /runOnJS/
454
456
  ];
457
+ var HERMES_COMPAT_PATTERNS = [
458
+ /\basync\s+function\b/,
459
+ /\basync\s*\(/,
460
+ /\basync\s+\w+\s*\(/,
461
+ /=\s*async\s*\(/,
462
+ /=\s*async\s+function\b/
463
+ ];
455
464
  function requiresBabelTransform(src) {
456
465
  return BABEL_REQUIRED_PATTERNS.some((pattern) => pattern.test(src));
457
466
  }
467
+ function requiresHermesCompat(src) {
468
+ return HERMES_COMPAT_PATTERNS.some((pattern) => pattern.test(src));
469
+ }
458
470
  function shouldTransform(filename, src, options) {
459
471
  if (isNodeModules(filename)) {
460
472
  return false;
@@ -465,6 +477,12 @@ function shouldTransform(filename, src, options) {
465
477
  }
466
478
  return false;
467
479
  }
480
+ if (requiresHermesCompat(src)) {
481
+ if (process.env.FACETPACK_DEBUG) {
482
+ console.log(`[Facetpack] Babel required for async/await (Hermes compat): ${filename}`);
483
+ }
484
+ return false;
485
+ }
468
486
  const ext = filename.split(".").pop()?.toLowerCase();
469
487
  if (!ext)
470
488
  return false;
@@ -486,6 +504,33 @@ function transform(params) {
486
504
  console.log(`[Facetpack] OXC Transform: ${filename}`);
487
505
  }
488
506
  try {
507
+ const parseResult = import_facetpack_native3.parseSync(filename, src);
508
+ if (parseResult.errors.length > 0 && parseResult.diagnostics.length > 0) {
509
+ const formattedErrors = parseResult.diagnostics.map((d) => {
510
+ let output2 = d.formatted || "";
511
+ if (!output2 && d.message) {
512
+ output2 = `
513
+ × ${d.message}
514
+ `;
515
+ if (d.snippet) {
516
+ output2 += ` ╭─[${d.filename}:${d.line}:${d.column}]
517
+ `;
518
+ output2 += ` ${d.line} │ ${d.snippet}
519
+ `;
520
+ output2 += ` ╰────
521
+ `;
522
+ }
523
+ if (d.help) {
524
+ output2 += ` help: ${d.help}
525
+ `;
526
+ }
527
+ }
528
+ return output2;
529
+ }).join(`
530
+ `);
531
+ throw new Error(`
532
+ ${formattedErrors}`);
533
+ }
489
534
  const isClassic = opts.jsxRuntime === "classic";
490
535
  const result = import_facetpack_native3.transformSync(filename, src, {
491
536
  jsx: opts.jsx,
package/dist/index.js CHANGED
@@ -168,7 +168,7 @@ function wrapModule(id, code) {
168
168
  var serializer_default = createFacetpackSerializer;
169
169
 
170
170
  // src/transformer.ts
171
- import { transformSync, JsxRuntime, resolveBatchSync } from "@ecrindigital/facetpack-native";
171
+ import { transformSync, JsxRuntime, resolveBatchSync, parseSync } from "@ecrindigital/facetpack-native";
172
172
  import { parse } from "@babel/parser";
173
173
 
174
174
  // src/cache.ts
@@ -304,9 +304,19 @@ var BABEL_REQUIRED_PATTERNS = [
304
304
  /runOnUI/,
305
305
  /runOnJS/
306
306
  ];
307
+ var HERMES_COMPAT_PATTERNS = [
308
+ /\basync\s+function\b/,
309
+ /\basync\s*\(/,
310
+ /\basync\s+\w+\s*\(/,
311
+ /=\s*async\s*\(/,
312
+ /=\s*async\s+function\b/
313
+ ];
307
314
  function requiresBabelTransform(src) {
308
315
  return BABEL_REQUIRED_PATTERNS.some((pattern) => pattern.test(src));
309
316
  }
317
+ function requiresHermesCompat(src) {
318
+ return HERMES_COMPAT_PATTERNS.some((pattern) => pattern.test(src));
319
+ }
310
320
  function shouldTransform(filename, src, options) {
311
321
  if (isNodeModules(filename)) {
312
322
  return false;
@@ -317,6 +327,12 @@ function shouldTransform(filename, src, options) {
317
327
  }
318
328
  return false;
319
329
  }
330
+ if (requiresHermesCompat(src)) {
331
+ if (process.env.FACETPACK_DEBUG) {
332
+ console.log(`[Facetpack] Babel required for async/await (Hermes compat): ${filename}`);
333
+ }
334
+ return false;
335
+ }
320
336
  const ext = filename.split(".").pop()?.toLowerCase();
321
337
  if (!ext)
322
338
  return false;
@@ -338,6 +354,33 @@ function transform(params) {
338
354
  console.log(`[Facetpack] OXC Transform: ${filename}`);
339
355
  }
340
356
  try {
357
+ const parseResult = parseSync(filename, src);
358
+ if (parseResult.errors.length > 0 && parseResult.diagnostics.length > 0) {
359
+ const formattedErrors = parseResult.diagnostics.map((d) => {
360
+ let output2 = d.formatted || "";
361
+ if (!output2 && d.message) {
362
+ output2 = `
363
+ × ${d.message}
364
+ `;
365
+ if (d.snippet) {
366
+ output2 += ` ╭─[${d.filename}:${d.line}:${d.column}]
367
+ `;
368
+ output2 += ` ${d.line} │ ${d.snippet}
369
+ `;
370
+ output2 += ` ╰────
371
+ `;
372
+ }
373
+ if (d.help) {
374
+ output2 += ` help: ${d.help}
375
+ `;
376
+ }
377
+ }
378
+ return output2;
379
+ }).join(`
380
+ `);
381
+ throw new Error(`
382
+ ${formattedErrors}`);
383
+ }
341
384
  const isClassic = opts.jsxRuntime === "classic";
342
385
  const result = transformSync(filename, src, {
343
386
  jsx: opts.jsx,
@@ -468,13 +511,14 @@ function withFacetpack(config, options = {}) {
468
511
  const useMinifier = options.minifier !== false;
469
512
  const minifierPath = useMinifier ? join(packageDir, "dist", "minifier.js") : config.transformer?.minifierPath;
470
513
  const minifierConfig = typeof options.minifier === "object" ? options.minifier : {};
471
- const useTreeShake = options.treeShake !== false;
514
+ const useTreeShake = options.treeShake === true;
472
515
  const existingSerializer = config.serializer?.customSerializer;
473
516
  const customSerializer = useTreeShake ? createFacetpackSerializer(existingSerializer, { treeShake: true }) : existingSerializer;
474
517
  const projectRoot = config.projectRoot || process.cwd();
475
518
  const originalTransformerPath = config.transformer?.babelTransformerPath;
476
519
  const fallbackTransformerPath = originalTransformerPath || findFallbackTransformer(projectRoot);
477
520
  storeTransformerOptions(options, fallbackTransformerPath);
521
+ const existingResolver = config.resolver?.resolveRequest;
478
522
  return {
479
523
  ...config,
480
524
  transformer: {
@@ -503,15 +547,16 @@ function withFacetpack(config, options = {}) {
503
547
  ])
504
548
  ],
505
549
  resolveRequest: (context, moduleName, platform) => {
550
+ const fallbackResolver = existingResolver ?? context.resolveRequest;
506
551
  if (context.originModulePath.includes("node_modules")) {
507
- return context.resolveRequest(context, moduleName, platform);
552
+ return fallbackResolver(context, moduleName, platform);
508
553
  }
509
554
  const cached = getCachedResolution(context.originModulePath, moduleName);
510
555
  if (cached !== undefined) {
511
556
  if (cached) {
512
557
  return { type: "sourceFile", filePath: cached };
513
558
  }
514
- return context.resolveRequest(context, moduleName, platform);
559
+ return fallbackResolver(context, moduleName, platform);
515
560
  }
516
561
  const directory = context.originModulePath.substring(0, context.originModulePath.lastIndexOf("/"));
517
562
  const result = resolveSync(directory, moduleName, {
@@ -522,7 +567,7 @@ function withFacetpack(config, options = {}) {
522
567
  if (result.path) {
523
568
  return { type: "sourceFile", filePath: result.path };
524
569
  }
525
- return context.resolveRequest(context, moduleName, platform);
570
+ return fallbackResolver(context, moduleName, platform);
526
571
  }
527
572
  },
528
573
  serializer: {
@@ -146,9 +146,19 @@ var BABEL_REQUIRED_PATTERNS = [
146
146
  /runOnUI/,
147
147
  /runOnJS/
148
148
  ];
149
+ var HERMES_COMPAT_PATTERNS = [
150
+ /\basync\s+function\b/,
151
+ /\basync\s*\(/,
152
+ /\basync\s+\w+\s*\(/,
153
+ /=\s*async\s*\(/,
154
+ /=\s*async\s+function\b/
155
+ ];
149
156
  function requiresBabelTransform(src) {
150
157
  return BABEL_REQUIRED_PATTERNS.some((pattern) => pattern.test(src));
151
158
  }
159
+ function requiresHermesCompat(src) {
160
+ return HERMES_COMPAT_PATTERNS.some((pattern) => pattern.test(src));
161
+ }
152
162
  function shouldTransform(filename, src, options) {
153
163
  if (isNodeModules(filename)) {
154
164
  return false;
@@ -159,6 +169,12 @@ function shouldTransform(filename, src, options) {
159
169
  }
160
170
  return false;
161
171
  }
172
+ if (requiresHermesCompat(src)) {
173
+ if (process.env.FACETPACK_DEBUG) {
174
+ console.log(`[Facetpack] Babel required for async/await (Hermes compat): ${filename}`);
175
+ }
176
+ return false;
177
+ }
162
178
  const ext = filename.split(".").pop()?.toLowerCase();
163
179
  if (!ext)
164
180
  return false;
@@ -180,6 +196,33 @@ function transform(params) {
180
196
  console.log(`[Facetpack] OXC Transform: ${filename}`);
181
197
  }
182
198
  try {
199
+ const parseResult = import_facetpack_native.parseSync(filename, src);
200
+ if (parseResult.errors.length > 0 && parseResult.diagnostics.length > 0) {
201
+ const formattedErrors = parseResult.diagnostics.map((d) => {
202
+ let output2 = d.formatted || "";
203
+ if (!output2 && d.message) {
204
+ output2 = `
205
+ × ${d.message}
206
+ `;
207
+ if (d.snippet) {
208
+ output2 += ` ╭─[${d.filename}:${d.line}:${d.column}]
209
+ `;
210
+ output2 += ` ${d.line} │ ${d.snippet}
211
+ `;
212
+ output2 += ` ╰────
213
+ `;
214
+ }
215
+ if (d.help) {
216
+ output2 += ` help: ${d.help}
217
+ `;
218
+ }
219
+ }
220
+ return output2;
221
+ }).join(`
222
+ `);
223
+ throw new Error(`
224
+ ${formattedErrors}`);
225
+ }
183
226
  const isClassic = opts.jsxRuntime === "classic";
184
227
  const result = import_facetpack_native.transformSync(filename, src, {
185
228
  jsx: opts.jsx,
@@ -1 +1 @@
1
- {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAuFjF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAErE;AAwDD,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAgElE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,gBAAqB;sBAI1C,eAAe,GAAG,eAAe;EA4BtD"}
1
+ {"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../src/transformer.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAA;AAuFjF,wBAAgB,qBAAqB,CAAC,OAAO,EAAE,gBAAgB,GAAG,IAAI,CAErE;AA2ED,wBAAgB,SAAS,CAAC,MAAM,EAAE,eAAe,GAAG,eAAe,CAuFlE;AAED,wBAAgB,iBAAiB,CAAC,OAAO,GAAE,gBAAqB;sBAI1C,eAAe,GAAG,eAAe;EA4BtD"}
@@ -2,7 +2,7 @@ import { createRequire } from "node:module";
2
2
  var __require = /* @__PURE__ */ createRequire(import.meta.url);
3
3
 
4
4
  // src/transformer.ts
5
- import { transformSync, JsxRuntime, resolveBatchSync } from "@ecrindigital/facetpack-native";
5
+ import { transformSync, JsxRuntime, resolveBatchSync, parseSync } from "@ecrindigital/facetpack-native";
6
6
  import { parse } from "@babel/parser";
7
7
 
8
8
  // src/cache.ts
@@ -138,9 +138,19 @@ var BABEL_REQUIRED_PATTERNS = [
138
138
  /runOnUI/,
139
139
  /runOnJS/
140
140
  ];
141
+ var HERMES_COMPAT_PATTERNS = [
142
+ /\basync\s+function\b/,
143
+ /\basync\s*\(/,
144
+ /\basync\s+\w+\s*\(/,
145
+ /=\s*async\s*\(/,
146
+ /=\s*async\s+function\b/
147
+ ];
141
148
  function requiresBabelTransform(src) {
142
149
  return BABEL_REQUIRED_PATTERNS.some((pattern) => pattern.test(src));
143
150
  }
151
+ function requiresHermesCompat(src) {
152
+ return HERMES_COMPAT_PATTERNS.some((pattern) => pattern.test(src));
153
+ }
144
154
  function shouldTransform(filename, src, options) {
145
155
  if (isNodeModules(filename)) {
146
156
  return false;
@@ -151,6 +161,12 @@ function shouldTransform(filename, src, options) {
151
161
  }
152
162
  return false;
153
163
  }
164
+ if (requiresHermesCompat(src)) {
165
+ if (process.env.FACETPACK_DEBUG) {
166
+ console.log(`[Facetpack] Babel required for async/await (Hermes compat): ${filename}`);
167
+ }
168
+ return false;
169
+ }
154
170
  const ext = filename.split(".").pop()?.toLowerCase();
155
171
  if (!ext)
156
172
  return false;
@@ -172,6 +188,33 @@ function transform(params) {
172
188
  console.log(`[Facetpack] OXC Transform: ${filename}`);
173
189
  }
174
190
  try {
191
+ const parseResult = parseSync(filename, src);
192
+ if (parseResult.errors.length > 0 && parseResult.diagnostics.length > 0) {
193
+ const formattedErrors = parseResult.diagnostics.map((d) => {
194
+ let output2 = d.formatted || "";
195
+ if (!output2 && d.message) {
196
+ output2 = `
197
+ × ${d.message}
198
+ `;
199
+ if (d.snippet) {
200
+ output2 += ` ╭─[${d.filename}:${d.line}:${d.column}]
201
+ `;
202
+ output2 += ` ${d.line} │ ${d.snippet}
203
+ `;
204
+ output2 += ` ╰────
205
+ `;
206
+ }
207
+ if (d.help) {
208
+ output2 += ` help: ${d.help}
209
+ `;
210
+ }
211
+ }
212
+ return output2;
213
+ }).join(`
214
+ `);
215
+ throw new Error(`
216
+ ${formattedErrors}`);
217
+ }
175
218
  const isClassic = opts.jsxRuntime === "classic";
176
219
  const result = transformSync(filename, src, {
177
220
  jsx: opts.jsx,
@@ -1 +1 @@
1
- {"version":3,"file":"withFacetpack.d.ts","sourceRoot":"","sources":["../src/withFacetpack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAA;AAkC5E,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,gBAAqB,GAC7B,WAAW,CAiGb;AASD,wBAAgB,gBAAgB,IAAI,gBAAgB,CASnD"}
1
+ {"version":3,"file":"withFacetpack.d.ts","sourceRoot":"","sources":["../src/withFacetpack.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAkB,MAAM,SAAS,CAAA;AAkC5E,wBAAgB,aAAa,CAC3B,MAAM,EAAE,WAAW,EACnB,OAAO,GAAE,gBAAqB,GAC7B,WAAW,CAqGb;AASD,wBAAgB,gBAAgB,IAAI,gBAAgB,CASnD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ecrindigital/facetpack",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "description": "High-performance Metro transformer powered by OXC",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",