{"id":21602004,"url":"https://github.com/ger86/webpackencore-babel","last_synced_at":"2026-04-13T05:38:52.710Z","repository":{"id":37512959,"uuid":"180938845","full_name":"ger86/webpackencore-babel","owner":"ger86","description":"Symfony project with Webpack Encore to show how we could configure Babel to transpile node_modules","archived":false,"fork":false,"pushed_at":"2023-01-06T01:47:44.000Z","size":2899,"stargazers_count":1,"open_issues_count":23,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T01:50:05.699Z","etag":null,"topics":["babel","bootstrap","symfony","webpack","webpack-encore"],"latest_commit_sha":null,"homepage":"","language":"CSS","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/ger86.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}},"created_at":"2019-04-12T05:48:12.000Z","updated_at":"2023-03-21T08:25:59.000Z","dependencies_parsed_at":"2023-02-05T02:01:35.289Z","dependency_job_id":null,"html_url":"https://github.com/ger86/webpackencore-babel","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/ger86%2Fwebpackencore-babel","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ger86%2Fwebpackencore-babel/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ger86%2Fwebpackencore-babel/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ger86%2Fwebpackencore-babel/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ger86","download_url":"https://codeload.github.com/ger86/webpackencore-babel/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244227773,"owners_count":20419306,"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","bootstrap","symfony","webpack","webpack-encore"],"created_at":"2024-11-24T19:11:43.987Z","updated_at":"2025-12-31T00:15:34.641Z","avatar_url":"https://github.com/ger86.png","language":"CSS","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Configuring Webpack Encore \u0026 Babel for passing by node_modules\n\nThis project show how you can configure WebpackEncore \u0026 Babel to pass by a library in `node_modules`.\n\nIn this case, I am using a versión of Bootstrap 4 that uses the spread operator but whose modules are not ES6 compliant so I have to use the raw javascript files and traspile them using **Babel**:\n\n```\nimport dropdown from 'bootstrap/js/src/dropdown.js';\n```\n\nIn order to avoid the presence of the spread operator in the final built two steps are needed:\n\n## Create babel.config.js\n\nSince the `.babelrc` file does not apply to files living in `node_modules` I have to use a `babel.config.js` file instead ([see this comment](https://github.com/symfony/webpack-encore/issues/670#issuecomment-628672354))\n\n```\n{\n    \"presets\": [\n      [\n        \"@babel/preset-env\",\n        {\n          \"targets\": {\n            \"chrome\": \"58\",\n            \"ie\": \"11\"\n          },\n          \"corejs\": 3,\n          \"modules\": false,\n          \"forceAllTransforms\": true,\n          \"useBuiltIns\": \"entry\"\n        }\n      ]\n    ],\n    \"plugins\": [\"@babel/plugin-syntax-dynamic-import\"]\n  }\n```\n\n## Use configureBabel method of Webpack Encore\n\nFinally, it is needed to tell Babel that transpiles the Bootstrap JS files, so we use its method `.configureBabel` in file `webpack.config.js`:\n\n```\n.configureBabel(null, {\n  includeNodeModules: ['bootstrap'],\n});\n```\n\nRunning `yarn encore production` we get a final build without the spread operator.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fger86%2Fwebpackencore-babel","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fger86%2Fwebpackencore-babel","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fger86%2Fwebpackencore-babel/lists"}