Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ModuleSource cannot transform source code using default destructing #2633

Closed
tri2820 opened this issue Nov 15, 2024 · 2 comments
Closed

ModuleSource cannot transform source code using default destructing #2633

tri2820 opened this issue Nov 15, 2024 · 2 comments
Labels
bug Something isn't working

Comments

@tri2820
Copy link

tri2820 commented Nov 15, 2024

Describe the bug

ModuleSource cannot transform source code using default destructing.

// works
new ModuleSource(`const { a } = {a : 1}`);

// doesn't work
new ModuleSource(`const { a = 2 } = {a : 1}`);

// doesn't work also
new ModuleSource(`const [a = 1] = [];`);

Steps to reproduce

  1. import { ModuleSource } from "@endo/module-source";
  2. create new ModuleSource with a source code using default destructing
  3. receive error:
SyntaxError: Error transforming source in <unknown>: Cannot read properties of undefined (reading 'buildError') (at transform-analyze.js:58:13)
    at createStaticRecord (transform-analyze.js:58:13)
    at new ModuleSource (module-source.js:86:7)
    at app.tsx:33:15
    at untrack (dev.js:518:12)
    at Object.fn (dev.js:543:22)
    at runComputation (dev.js:802:22)
    at updateComputation (dev.js:780:3)
    at runTop (dev.js:897:7)
    at runUserEffects (dev.js:1011:36)
    at dev.js:966:34Caused by: TypeError: Cannot read properties of undefined (reading 'buildError')
    at NodePath.buildCodeFrameError (index.ts:141:21)
    at collectPatternIdentifiers (babelPlugin.js:35:18)
    at collectPatternIdentifiers (babelPlugin.js:23:14)
    at babelPlugin.js:26:9
    at Array.flatMap (<anonymous>)
    at collectPatternIdentifiers (babelPlugin.js:25:33)
    at babelPlugin.js:471:13
    at Array.flatMap (<anonymous>)
    at VariableDeclaration (babelPlugin.js:470:47)
    at NodePath._call (context.ts:36:20)

Expected behavior

Can create a ModuleSource from source code using default destructing.

Question

  • Is this due to the behavior of the babel version we use?

Platform environment

1.71.114 Chromium: 130.0.6723.58 (Official Build) (64-bit)

@tri2820 tri2820 added the bug Something isn't working label Nov 15, 2024
@kriskowal
Copy link
Member

This is a duplicate of #2094. My assumption is that this is a defect in our Babel transform that might even be straight-forward to fix. There are two test cases for this problem checked in with test.failing.

@kriskowal kriskowal closed this as not planned Won't fix, can't repro, duplicate, stale Nov 16, 2024
@kriskowal
Copy link
Member

(And thank you for reporting!)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants