{"id":21565113,"url":"https://github.com/cfware/babel-plugin-bundled-import-meta","last_synced_at":"2025-04-10T13:10:14.343Z","repository":{"id":53120486,"uuid":"155412009","full_name":"cfware/babel-plugin-bundled-import-meta","owner":"cfware","description":"Babel plugin to rewrite import.meta for bundled usage","archived":false,"fork":false,"pushed_at":"2022-08-05T08:57:14.000Z","size":40,"stargazers_count":4,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-23T03:01:58.036Z","etag":null,"topics":["babel-plugin","esm","esmodules","import-meta","rollup","webpack"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cfware.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"tidelift":"npm/babel-plugin-bundled-import-meta"}},"created_at":"2018-10-30T15:44:08.000Z","updated_at":"2023-10-13T20:23:04.000Z","dependencies_parsed_at":"2022-08-25T22:50:27.422Z","dependency_job_id":null,"html_url":"https://github.com/cfware/babel-plugin-bundled-import-meta","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fbabel-plugin-bundled-import-meta","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fbabel-plugin-bundled-import-meta/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fbabel-plugin-bundled-import-meta/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cfware%2Fbabel-plugin-bundled-import-meta/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cfware","download_url":"https://codeload.github.com/cfware/babel-plugin-bundled-import-meta/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247744334,"owners_count":20988783,"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":["babel-plugin","esm","esmodules","import-meta","rollup","webpack"],"created_at":"2024-11-24T10:18:28.226Z","updated_at":"2025-04-10T13:10:14.325Z","avatar_url":"https://github.com/cfware.png","language":"JavaScript","funding_links":["https://tidelift.com/funding/github/npm/babel-plugin-bundled-import-meta","https://tidelift.com/subscription/pkg/npm-babel-plugin-bundled-import-meta?utm_source=npm-babel-plugin-bundled-import-meta\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo"],"categories":[],"sub_categories":[],"readme":"# babel-plugin-bundled-import-meta\n\n[![Travis CI][travis-image]][travis-url]\n[![Greenkeeper badge][gk-image]](https://greenkeeper.io/)\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![BSD-3-Clause][license-image]](LICENSE)\n\nBabel plugin to rewrite import.meta.url for use in bundles.\n\n## Install babel-plugin-bundled-import-meta\n\nThis module requires node.js 10 or above and `@babel/core`.\n\n```sh\nnpm i babel-plugin-bundled-import-meta\n```\n\n## Usage\n\nAdd `babel-plugin-bundled-import-meta` to `plugins` in your babel settings.\n\n## Settings\n\n```json\n{\n\t\"plugins\": [\n\t\t[\"babel-plugin-bundled-import-meta\", {\n\t\t\t\"mappings\": {\n\t\t\t\t\"node_modules\": \"/assets\"\n\t\t\t},\n\t\t\t\"bundleDir\": \"html\"\n\t\t}]\n\t]\n}\n```\n\nThis example will assume that `html/` will directly contain the bundled JavaScript.\n`node_modules/` served from `/assets`.  Any use of `import.meta` outside these\ntwo folders will throw an exception.\n\n### bundleDir\n\nIf no mappings match it is assumed that `bundleDir` is served from the same directory\nas the output bundle.  In the example where bundleDir is set to `html` it is assumed\nthat assets in `html/components` will be published in `./components` relative to the\nbundled JavaScript.\n\nDefault `process.cwd()`.\n\n### mappings\n\nThis maps source paths to server URL's.  Key's represent local source paths, values\nrepresent base URL which would be used for the unbundled build.  Value URL's can be\nrelative or absolute.  Relative URL's will be resolved at runtime using the bundle\nURL as the base URL.\n\nDefault `{}`.\n\n### importStyle\n\nIt's necessary to know the full URL of the bundle as loaded by the browser.  The best\nway to determine this is different based on what type of bundle will be used.\n\nSupported styles are: `amd`, `cjs`, `esm`, `iife`, `umd`, `system`.  Default `esm`.\n\nThe `esm` import style generates `import.meta.url` to detect the bundled URL.  This\nis not compatible with webpack so use another method.  If anyone knows of a 'best'\noption for use with webpack please open an issue or PR.\n\nWhen bundling with rollup you should generally use `esm` here.  The only exception is\nif rollup is generating an `esm` bundle for targets that do not support\n`import.meta.url`.  If you are using `import.meta.url` in your code but must maintain\ncompatibility with browsers that do not support this it is probably best to have rollup\ngenerate a different bundle format.\n\n## Attribution\n\nThis module is based on code found in [polymer-build].\n\n## `babel-plugin-bundled-import-meta` for enterprise\n\nAvailable as part of the Tidelift Subscription.\n\nThe maintainers of `babel-plugin-bundled-import-meta` and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-babel-plugin-bundled-import-meta?utm_source=npm-babel-plugin-bundled-import-meta\u0026utm_medium=referral\u0026utm_campaign=enterprise\u0026utm_term=repo)\n\n[npm-image]: https://img.shields.io/npm/v/babel-plugin-bundled-import-meta.svg\n[npm-url]: https://npmjs.org/package/babel-plugin-bundled-import-meta\n[travis-image]: https://travis-ci.org/cfware/babel-plugin-bundled-import-meta.svg?branch=master\n[travis-url]: https://travis-ci.org/cfware/babel-plugin-bundled-import-meta\n[gk-image]: https://badges.greenkeeper.io/cfware/babel-plugin-bundled-import-meta.svg\n[downloads-image]: https://img.shields.io/npm/dm/babel-plugin-bundled-import-meta.svg\n[downloads-url]: https://npmjs.org/package/babel-plugin-bundled-import-meta\n[license-image]: https://img.shields.io/npm/l/babel-plugin-bundled-import-meta.svg\n[polymer-build]: https://github.com/Polymer/tools/blob/fdc9e5472674c63435e8188fdc00b342184ce8f3/packages/build/src/babel-plugin-import-meta.ts\n[rollup-demo]: https://github.com/cfware/babel-plugin-bundled-import-meta/tree/master/rollup-demo\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fbabel-plugin-bundled-import-meta","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcfware%2Fbabel-plugin-bundled-import-meta","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcfware%2Fbabel-plugin-bundled-import-meta/lists"}