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

Import cycles through star exports #3884

Open
bojavou opened this issue Jul 26, 2023 · 0 comments
Open

Import cycles through star exports #3884

bojavou opened this issue Jul 26, 2023 · 0 comments

Comments

@bojavou
Copy link

bojavou commented Jul 26, 2023

Import cycles have some interaction with star exports. Where one star export finds a cycle and another finds a binding, the binding should override and resolve successfully.

It was pointed out to me that typically a cycle will cause a crash elsewhere, when InitializeEnvironment detects it. But that shouldn't happen in the case where a star export is in the middle of the cycle. There is inconsistency in implementations on this point. I wonder if it should be in the test suite.

There are eshost outputs below, plus browser demos. The browser demos log/error to the console.


Cycle on both sides, wrapped in named exports.

https://bojavou.github.io/star-export-cycle/biname/

https://github.com/bojavou/star-export-cycle/tree/main/biname

// entry.mjs
import { value } from './left.mjs'
print(value)

// left.mjs
export { value } from './middle.mjs'

// middle.mjs
export * from './left.mjs'
export * from './right.mjs'
export * from './bind.mjs'

// right.mjs
export { value } from './middle.mjs'

// bind.mjs
export const value = 'bind'
$ eshost entry.mjs
#### engine262
bind

#### JavaScriptCore
bind

#### SpiderMonkey
bind

#### V8

SyntaxError: Detected cycle while resolving name 'value' in './middle.mjs'

#### XS

SyntaxError: (host): import value ambiguous

Cycle on one side, wrapped in named exports.

https://bojavou.github.io/star-export-cycle/uniname/

https://github.com/bojavou/star-export-cycle/tree/main/uniname

// entry.mjs
import { value } from './left.mjs'
print(value)

// left.mjs
export { value } from './middle.mjs'

// middle.mjs
export * from './right.mjs'
export * from './bind.mjs'

// right.mjs
export { value } from './middle.mjs'

// bind.mjs
export const value = 'bind'
$ eshost entry.mjs
#### engine262
bind

#### JavaScriptCore
bind

#### SpiderMonkey
bind

#### V8
bind

#### XS

SyntaxError: (host): import value ambiguous

Cycle on both sides, wrapped in star exports.

https://bojavou.github.io/star-export-cycle/bistar/

https://github.com/bojavou/star-export-cycle/tree/main/bistar

// entry.mjs
import { value } from './left.mjs'
print(value)

// left.mjs
export * from './middle.mjs'

// middle.mjs
export * from './left.mjs'
export * from './right.mjs'
export * from './bind.mjs'

// right.mjs
export * from './middle.mjs'

// bind.mjs
export const value = 'bind'
$ eshost entry.mjs
#### engine262
bind

#### JavaScriptCore
bind

#### SpiderMonkey
bind

#### V8
bind

#### XS
bind

Cycle on one side, wrapped in star exports.

This behaves identically to bistar.

https://bojavou.github.io/star-export-cycle/unistar/

https://github.com/bojavou/star-export-cycle/tree/main/unistar

// entry.mjs
import { value } from './left.mjs'
print(value)

// left.mjs
export * from './middle.mjs'

// middle.mjs
export * from './right.mjs'
export * from './bind.mjs'

// right.mjs
export * from './middle.mjs'

// bind.mjs
export const value = 'bind'
$ eshost entry.mjs
#### engine262
bind

#### JavaScriptCore
bind

#### SpiderMonkey
bind

#### V8
bind

#### XS
bind
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant