{"id":13725674,"url":"https://github.com/airbnb/babel-plugin-dynamic-import-node","last_synced_at":"2025-05-14T15:04:32.682Z","repository":{"id":41192346,"uuid":"72034231","full_name":"airbnb/babel-plugin-dynamic-import-node","owner":"airbnb","description":"Babel plugin to transpile import() to a deferred require(), for node","archived":false,"fork":false,"pushed_at":"2023-03-04T01:43:36.000Z","size":113,"stargazers_count":573,"open_issues_count":7,"forks_count":66,"subscribers_count":37,"default_branch":"master","last_synced_at":"2025-03-14T06:06:03.089Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/airbnb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2016-10-26T18:50:00.000Z","updated_at":"2025-03-03T15:19:33.000Z","dependencies_parsed_at":"2023-09-27T20:38:55.256Z","dependency_job_id":null,"html_url":"https://github.com/airbnb/babel-plugin-dynamic-import-node","commit_stats":{"total_commits":77,"total_committers":14,"mean_commits":5.5,"dds":0.3246753246753247,"last_synced_commit":"a68388870de822183218515a1adbb3e8d7fa9486"},"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fbabel-plugin-dynamic-import-node","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fbabel-plugin-dynamic-import-node/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fbabel-plugin-dynamic-import-node/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/airbnb%2Fbabel-plugin-dynamic-import-node/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/airbnb","download_url":"https://codeload.github.com/airbnb/babel-plugin-dynamic-import-node/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244444346,"owners_count":20453706,"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-08-03T01:02:30.930Z","updated_at":"2025-04-11T14:42:19.623Z","avatar_url":"https://github.com/airbnb.png","language":"JavaScript","readme":"# babel-plugin-dynamic-import-node\n\nBabel plugin to transpile `import()` to a deferred `require()`, for node. Matches the [proposed spec](https://github.com/domenic/proposal-import-function).\n\n**NOTE:** Babylon \u003e= v6.12.0 is required to correctly parse dynamic imports.\n\n**NOTE:** This plugin generates code compatible with Node.js. Webpack \u003e= 2 supports `import()` natively, and for Webpack 1 you can use [`babel-plugin-dynamic-import-webpack`](https://github.com/airbnb/babel-plugin-dynamic-import-webpack) that generates Webpack-compatible output.\n\n## Installation\n\n```sh\nnpm install babel-plugin-dynamic-import-node --save-dev\n```\n\n## Usage\n\n### Via `.babelrc` (Recommended)\n\n**.babelrc**\n\n```json\n{\n  \"plugins\": [\"dynamic-import-node\"]\n}\n```\n\n#### Options\n\n- *`noInterop`* - A boolean value, that if true will not interop the require calls. Useful to avoid using `require('module').default` on commonjs modules.\n\n```json\n{\n  \"plugins\": [\n    [\"dynamic-import-node\", { \"noInterop\": true }]\n  ]\n}\n```\n\n### Via CLI\n\n```sh\n$ babel --plugins dynamic-import-node script.js\n```\n\n### Via Node API\n\n```javascript\nrequire('babel-core').transform('code', {\n  plugins: ['dynamic-import-node']\n});\n```\n\n### Code Example\n```javascript\nPromise.all([\n  import('./lib/import1'),\n  import('./lib/import2')\n ]).then(([\n   Import1,\n   Import2\n  ]) =\u003e {\n   console.log(Import1);\n   /* CODE HERE*/\n  });\n```\n","funding_links":[],"categories":["babel","JavaScript"],"sub_categories":["非 JavaScript 编译工具"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Fbabel-plugin-dynamic-import-node","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fairbnb%2Fbabel-plugin-dynamic-import-node","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fairbnb%2Fbabel-plugin-dynamic-import-node/lists"}