{"id":19238517,"url":"https://github.com/tmpfs/swc-builtin-shim","last_synced_at":"2025-02-23T13:52:51.764Z","repository":{"id":66127951,"uuid":"388681888","full_name":"tmpfs/swc-builtin-shim","owner":"tmpfs","description":"MVP for an attempt to shim built in modules using spack","archived":false,"fork":false,"pushed_at":"2021-07-23T04:57:10.000Z","size":12,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-05T02:12:15.431Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tmpfs.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-07-23T04:55:52.000Z","updated_at":"2021-07-23T04:57:12.000Z","dependencies_parsed_at":"2023-03-10T15:15:32.015Z","dependency_job_id":null,"html_url":"https://github.com/tmpfs/swc-builtin-shim","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fswc-builtin-shim","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fswc-builtin-shim/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fswc-builtin-shim/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tmpfs%2Fswc-builtin-shim/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tmpfs","download_url":"https://codeload.github.com/tmpfs/swc-builtin-shim/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240324059,"owners_count":19783453,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T16:33:04.004Z","updated_at":"2025-02-23T13:52:51.741Z","avatar_url":"https://github.com/tmpfs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Spack Builtin Shim\n\nAn attempt to use shims for node builtin modules.\n\n```\nyarn install\nnpx spack\n```\n\nWhen compiling with `spack` for the browser and using builtin modules such as `assert` and `events` we encountered this error when executing the generated bundle:\n\n```\nUncaught SyntaxError: Cannot use import statement outside a module\n```\n\nIt appears that builtin modules are passed through as `import` statements untouched as there is no available code to compile.\n\nHowever, when we added the `assert` and `events` packages to be used as shims and updated `.swcrc` to configure the `paths`:\n\n```json\n{\n  \"jsc\": {\n    \"paths\": {\n      \"assert\": [\"node_modules/assert\"],\n      \"events\": [\"node_modules/events\"]\n    }\n  }\n}\n```\n\nThese shims for the builtin modules are not used and the compiled bundle still includes the original import statements.\n\n* [List of builtin shims](https://github.com/browserify/browserify#compatibility)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmpfs%2Fswc-builtin-shim","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftmpfs%2Fswc-builtin-shim","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftmpfs%2Fswc-builtin-shim/lists"}