Title: Standardize synchronous circular requires · Issue #6 · jsinterface/interface · GitHub
Open Graph Title: Standardize synchronous circular requires · Issue #6 · jsinterface/interface
X Title: Standardize synchronous circular requires · Issue #6 · jsinterface/interface
Description: Synchronous circular requires (commonjs equivalent of static default imports) are individually edited in some sources (CSSOM, JSDOM), but a generic pattern can be recognized. The edits are always a delayed reassignment from dynamic impor...
Open Graph Description: Synchronous circular requires (commonjs equivalent of static default imports) are individually edited in some sources (CSSOM, JSDOM), but a generic pattern can be recognized. The edits are always a...
X Description: Synchronous circular requires (commonjs equivalent of static default imports) are individually edited in some sources (CSSOM, JSDOM), but a generic pattern can be recognized. The edits are always a...
Opengraph URL: https://github.com/jsinterface/interface/issues/6
X: @github
Domain: patch-diff.githubusercontent.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Standardize synchronous circular requires","articleBody":"Synchronous circular requires (commonjs equivalent of static default imports) \r\nare individually edited in some sources (CSSOM, JSDOM), \r\nbut a generic pattern can be recognized. \r\n\r\nThe edits are always a delayed reassignment from dynamic import\r\n(`const a=require(\"a\")` -\u003e `let a;setTimeout(async function expect_hoisted_a()`\r\n`{import(\"a\").then(({default:module})=\u003ea=module)},3000)` \r\n\\- note that dynamic import is only supported for requires in already async scopes; see issue #9 ), \r\nsupported by an equal timeout before the default export of module.exports in the \r\nentry module since the dynamic imports become promise resolutions of hoisted variables \r\nof co-dependent modules stacked lower in the module scope when bundled: \r\n```\r\n// entry module: \r\nawait new Promise(resolve=\u003esetTimeout(resolve,3000));\r\nexport default module.exports;\r\n\r\n// dependent module: \r\nvar codependent;\r\nsetTimeout(async function expect_hoisted_dependency()\r\n{import(\"codependent\").then(({default:module})=\u003ecodependent=module)\r\n},3000);\r\nexport default module.exports;\r\n\r\n// codependent module: \r\nimport dependent from \"dependent\";\r\nmodule.exports={dependent}\r\nexport default module.exports;\r\n\r\n// bundle: \r\nvar codependent;\r\nsetTimeout(async function expect_hoisted_a()\r\n{Promise.resolve(dependency).then(({default:module})=\u003ecodependent=module)\r\n},3000);\r\nvar dependent={default};\r\nvar dependency={default:dependent};\r\nawait new Promise(resolve=\u003esetTimeout(resolve,3000));\r\nexport default module.exports;\r\n```\r\nCollecting and awaiting the dynamic import reassignments instead of the arbitrary delay at the end of bundle, \r\nas well as gaining access to rollup's hoisted variable name to recursively ascertain the local reassignments, \r\nor potential modifications to the module hierarchy could be further improvements to this generalization. \r\n\r\nAn illustrative subject circular dependency graph (CSSOM):\r\n\r\n","author":{"url":"https://github.com/jsinterface","@type":"Person","name":"jsinterface"},"datePublished":"2023-10-25T10:49:02.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/6/interface/issues/6"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cd8dc841-c3de-a64e-e863-caeac25752a2 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 92B2:2B6986:48D6A1:65FEE5:6978A64F |
| html-safe-nonce | 84c0b38ff25022a6e71c3d5e0dabea257f4a2880160e5caf84b4faaa5fcd9636 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5MkIyOjJCNjk4Njo0OEQ2QTE6NjVGRUU1OjY5NzhBNjRGIiwidmlzaXRvcl9pZCI6IjY2MjY1OTI0NjczODAxMTkxMTkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 24e8a293f1b7a84f0d020012e3d53564f477a86332ee400f7fdeb1134c1af175 |
| hovercard-subject-tag | issue:1961099202 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/jsinterface/interface/6/issue_layout |
| twitter:image | https://opengraph.githubassets.com/c6f40a8efb43e2f84b0397b192054190a8b9e6caf5fe71176b647a85c0a6b143/jsinterface/interface/issues/6 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/c6f40a8efb43e2f84b0397b192054190a8b9e6caf5fe71176b647a85c0a6b143/jsinterface/interface/issues/6 |
| og:image:alt | Synchronous circular requires (commonjs equivalent of static default imports) are individually edited in some sources (CSSOM, JSDOM), but a generic pattern can be recognized. The edits are always a... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | jsinterface |
| hostname | github.com |
| expected-hostname | github.com |
| None | 2981c597c945c1d90ac6fa355ce7929b2f413dfe7872ca5c435ee53a24a1de50 |
| turbo-cache-control | no-preview |
| go-import | github.com/jsinterface/interface git https://github.com/jsinterface/interface.git |
| octolytics-dimension-user_id | 26650418 |
| octolytics-dimension-user_login | jsinterface |
| octolytics-dimension-repository_id | 688944177 |
| octolytics-dimension-repository_nwo | jsinterface/interface |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 688944177 |
| octolytics-dimension-repository_network_root_nwo | jsinterface/interface |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | f8aa86d87c47054170094daaf9699b27a28a8448 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width