├── index.js ├── .gitignore ├── README.md ├── boundle.js ├── plugin.js ├── babel.config.js ├── package.json └── yarn-error.log /index.js: -------------------------------------------------------------------------------- 1 | a = 1 -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /node_modules/ 2 | yarn.* -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # learn-babel 2 | learn-babel 3 | -------------------------------------------------------------------------------- /boundle.js: -------------------------------------------------------------------------------- 1 | "use strict"; 2 | 3 | c = 1; 4 | -------------------------------------------------------------------------------- /plugin.js: -------------------------------------------------------------------------------- 1 | module.exports = function ({ types: t }) { 2 | return { 3 | visitor: { 4 | Identifier(path) { 5 | if (path.node.name !== 'a') { 6 | return 7 | } 8 | path.node.name = 'c' 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /babel.config.js: -------------------------------------------------------------------------------- 1 | module.exports = function (api) { 2 | api.cache(true); 3 | 4 | const presets = [ 5 | [ 6 | "@babel/env", 7 | { 8 | targets: { 9 | edge: "17", 10 | firefox: "60", 11 | chrome: "67", 12 | safari: "11.1", 13 | }, 14 | useBuiltIns: "usage", 15 | corejs: "2", 16 | } 17 | ] 18 | ]; 19 | const plugins = [ 20 | './plugin.js' 21 | ]; 22 | 23 | return { 24 | presets, 25 | plugins 26 | }; 27 | } -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "learn-babel", 3 | "version": "1.0.0", 4 | "description": "learn-babel", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1", 8 | "dev": "./node_modules/.bin/babel index.js --out-file boundle.js -w" 9 | }, 10 | "repository": { 11 | "type": "git", 12 | "url": "git+https://github.com/IFmiss/learn-babel.git" 13 | }, 14 | "author": "", 15 | "license": "ISC", 16 | "bugs": { 17 | "url": "https://github.com/IFmiss/learn-babel/issues" 18 | }, 19 | "homepage": "https://github.com/IFmiss/learn-babel#readme", 20 | "dependencies": { 21 | "@babel/generator": "^7.7.7", 22 | "@babel/plugin-transform-arrow-functions": "^7.7.4", 23 | "@babel/preset-env": "^7.7.7", 24 | "@babel/traverse": "^7.7.4" 25 | }, 26 | "devDependencies": { 27 | "@babel/cli": "^7.7.7", 28 | "@babel/core": "^7.7.7", 29 | "@babel/parser": "^7.7.7" 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /yarn-error.log: -------------------------------------------------------------------------------- 1 | Arguments: 2 | /usr/local/bin/node /usr/local/bin/yarn add @babel/babel-preset-env 3 | 4 | PATH: 5 | /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin:/Applications/Visual Studio Code.app/Contents/Resources/app/bin 6 | 7 | Yarn version: 8 | 1.21.1 9 | 10 | Node version: 11 | 12.13.1 12 | 13 | Platform: 14 | darwin x64 15 | 16 | Trace: 17 | Error: https://registry.npm.taobao.org/@babel%2fbabel-preset-env: Not found 18 | at Request.params.callback [as _callback] (/usr/local/lib/node_modules/yarn/lib/cli.js:66947:18) 19 | at Request.self.callback (/usr/local/lib/node_modules/yarn/lib/cli.js:140665:22) 20 | at Request.emit (events.js:210:5) 21 | at Request. (/usr/local/lib/node_modules/yarn/lib/cli.js:141637:10) 22 | at Request.emit (events.js:210:5) 23 | at IncomingMessage. (/usr/local/lib/node_modules/yarn/lib/cli.js:141559:12) 24 | at Object.onceWrapper (events.js:299:28) 25 | at IncomingMessage.emit (events.js:215:7) 26 | at endReadableNT (_stream_readable.js:1184:12) 27 | at processTicksAndRejections (internal/process/task_queues.js:80:21) 28 | 29 | npm manifest: 30 | { 31 | "name": "learn-babel", 32 | "version": "1.0.0", 33 | "description": "learn-babel", 34 | "main": "index.js", 35 | "scripts": { 36 | "test": "echo \"Error: no test specified\" && exit 1", 37 | "dev": "./node_modules/.bin/babel index.js --out-file boundle.js -w" 38 | }, 39 | "repository": { 40 | "type": "git", 41 | "url": "git+https://github.com/IFmiss/learn-babel.git" 42 | }, 43 | "author": "", 44 | "license": "ISC", 45 | "bugs": { 46 | "url": "https://github.com/IFmiss/learn-babel/issues" 47 | }, 48 | "homepage": "https://github.com/IFmiss/learn-babel#readme", 49 | "dependencies": { 50 | "@babel/plugin-transform-arrow-functions": "^7.7.4" 51 | }, 52 | "devDependencies": { 53 | "@babel/cli": "^7.7.7", 54 | "@babel/core": "^7.7.7" 55 | } 56 | } 57 | 58 | yarn manifest: 59 | No manifest 60 | 61 | Lockfile: 62 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 63 | # yarn lockfile v1 64 | 65 | 66 | "@babel/code-frame@^7.0.0", "@babel/code-frame@^7.5.5": 67 | version "7.5.5" 68 | resolved "https://registry.npm.taobao.org/@babel/code-frame/download/@babel/code-frame-7.5.5.tgz#bc0782f6d69f7b7d49531219699b988f669a8f9d" 69 | integrity sha1-vAeC9tafe31JUxIZaZuYj2aaj50= 70 | dependencies: 71 | "@babel/highlight" "^7.0.0" 72 | 73 | "@babel/core@^7.7.7": 74 | version "7.7.7" 75 | resolved "https://registry.npm.taobao.org/@babel/core/download/@babel/core-7.7.7.tgz#ee155d2e12300bcc0cff6a8ad46f2af5063803e9" 76 | integrity sha1-7hVdLhIwC8wM/2qK1G8q9QY4A+k= 77 | dependencies: 78 | "@babel/code-frame" "^7.5.5" 79 | "@babel/generator" "^7.7.7" 80 | "@babel/helpers" "^7.7.4" 81 | "@babel/parser" "^7.7.7" 82 | "@babel/template" "^7.7.4" 83 | "@babel/traverse" "^7.7.4" 84 | "@babel/types" "^7.7.4" 85 | convert-source-map "^1.7.0" 86 | debug "^4.1.0" 87 | json5 "^2.1.0" 88 | lodash "^4.17.13" 89 | resolve "^1.3.2" 90 | semver "^5.4.1" 91 | source-map "^0.5.0" 92 | 93 | "@babel/generator@^7.7.4", "@babel/generator@^7.7.7": 94 | version "7.7.7" 95 | resolved "https://registry.npm.taobao.org/@babel/generator/download/@babel/generator-7.7.7.tgz#859ac733c44c74148e1a72980a64ec84b85f4f45" 96 | integrity sha1-hZrHM8RMdBSOGnKYCmTshLhfT0U= 97 | dependencies: 98 | "@babel/types" "^7.7.4" 99 | jsesc "^2.5.1" 100 | lodash "^4.17.13" 101 | source-map "^0.5.0" 102 | 103 | "@babel/helper-function-name@^7.7.4": 104 | version "7.7.4" 105 | resolved "https://registry.npm.taobao.org/@babel/helper-function-name/download/@babel/helper-function-name-7.7.4.tgz?cache=0&sync_timestamp=1574465949765&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-function-name%2Fdownload%2F%40babel%2Fhelper-function-name-7.7.4.tgz#ab6e041e7135d436d8f0a3eca15de5b67a341a2e" 106 | integrity sha1-q24EHnE11DbY8KPsoV3ltno0Gi4= 107 | dependencies: 108 | "@babel/helper-get-function-arity" "^7.7.4" 109 | "@babel/template" "^7.7.4" 110 | "@babel/types" "^7.7.4" 111 | 112 | "@babel/helper-get-function-arity@^7.7.4": 113 | version "7.7.4" 114 | resolved "https://registry.npm.taobao.org/@babel/helper-get-function-arity/download/@babel/helper-get-function-arity-7.7.4.tgz#cb46348d2f8808e632f0ab048172130e636005f0" 115 | integrity sha1-y0Y0jS+ICOYy8KsEgXITDmNgBfA= 116 | dependencies: 117 | "@babel/types" "^7.7.4" 118 | 119 | "@babel/helper-plugin-utils@^7.0.0": 120 | version "7.0.0" 121 | resolved "https://registry.npm.taobao.org/@babel/helper-plugin-utils/download/@babel/helper-plugin-utils-7.0.0.tgz#bbb3fbee98661c569034237cc03967ba99b4f250" 122 | integrity sha1-u7P77phmHFaQNCN8wDlnupm08lA= 123 | 124 | "@babel/helper-split-export-declaration@^7.7.4": 125 | version "7.7.4" 126 | resolved "https://registry.npm.taobao.org/@babel/helper-split-export-declaration/download/@babel/helper-split-export-declaration-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelper-split-export-declaration%2Fdownload%2F%40babel%2Fhelper-split-export-declaration-7.7.4.tgz#57292af60443c4a3622cf74040ddc28e68336fd8" 127 | integrity sha1-Vykq9gRDxKNiLPdAQN3Cjmgzb9g= 128 | dependencies: 129 | "@babel/types" "^7.7.4" 130 | 131 | "@babel/helpers@^7.7.4": 132 | version "7.7.4" 133 | resolved "https://registry.npm.taobao.org/@babel/helpers/download/@babel/helpers-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fhelpers%2Fdownload%2F%40babel%2Fhelpers-7.7.4.tgz#62c215b9e6c712dadc15a9a0dcab76c92a940302" 134 | integrity sha1-YsIVuebHEtrcFamg3Kt2ySqUAwI= 135 | dependencies: 136 | "@babel/template" "^7.7.4" 137 | "@babel/traverse" "^7.7.4" 138 | "@babel/types" "^7.7.4" 139 | 140 | "@babel/highlight@^7.0.0": 141 | version "7.5.0" 142 | resolved "https://registry.npm.taobao.org/@babel/highlight/download/@babel/highlight-7.5.0.tgz#56d11312bd9248fa619591d02472be6e8cb32540" 143 | integrity sha1-VtETEr2SSPphlZHQJHK+boyzJUA= 144 | dependencies: 145 | chalk "^2.0.0" 146 | esutils "^2.0.2" 147 | js-tokens "^4.0.0" 148 | 149 | "@babel/parser@^7.7.4", "@babel/parser@^7.7.7": 150 | version "7.7.7" 151 | resolved "https://registry.npm.taobao.org/@babel/parser/download/@babel/parser-7.7.7.tgz#1b886595419cf92d811316d5b715a53ff38b4937" 152 | integrity sha1-G4hllUGc+S2BExbVtxWlP/OLSTc= 153 | 154 | "@babel/plugin-transform-arrow-functions@^7.7.4": 155 | version "7.7.4" 156 | resolved "https://registry.npm.taobao.org/@babel/plugin-transform-arrow-functions/download/@babel/plugin-transform-arrow-functions-7.7.4.tgz?cache=0&sync_timestamp=1574466137008&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Fplugin-transform-arrow-functions%2Fdownload%2F%40babel%2Fplugin-transform-arrow-functions-7.7.4.tgz#76309bd578addd8aee3b379d809c802305a98a12" 157 | integrity sha1-djCb1Xit3YruOzedgJyAIwWpihI= 158 | dependencies: 159 | "@babel/helper-plugin-utils" "^7.0.0" 160 | 161 | "@babel/template@^7.7.4": 162 | version "7.7.4" 163 | resolved "https://registry.npm.taobao.org/@babel/template/download/@babel/template-7.7.4.tgz?cache=0&sync_timestamp=1574465948896&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftemplate%2Fdownload%2F%40babel%2Ftemplate-7.7.4.tgz#428a7d9eecffe27deac0a98e23bf8e3675d2a77b" 164 | integrity sha1-Qop9nuz/4n3qwKmOI7+ONnXSp3s= 165 | dependencies: 166 | "@babel/code-frame" "^7.0.0" 167 | "@babel/parser" "^7.7.4" 168 | "@babel/types" "^7.7.4" 169 | 170 | "@babel/traverse@^7.7.4": 171 | version "7.7.4" 172 | resolved "https://registry.npm.taobao.org/@babel/traverse/download/@babel/traverse-7.7.4.tgz#9c1e7c60fb679fe4fcfaa42500833333c2058558" 173 | integrity sha1-nB58YPtnn+T8+qQlAIMzM8IFhVg= 174 | dependencies: 175 | "@babel/code-frame" "^7.5.5" 176 | "@babel/generator" "^7.7.4" 177 | "@babel/helper-function-name" "^7.7.4" 178 | "@babel/helper-split-export-declaration" "^7.7.4" 179 | "@babel/parser" "^7.7.4" 180 | "@babel/types" "^7.7.4" 181 | debug "^4.1.0" 182 | globals "^11.1.0" 183 | lodash "^4.17.13" 184 | 185 | "@babel/types@^7.7.4": 186 | version "7.7.4" 187 | resolved "https://registry.npm.taobao.org/@babel/types/download/@babel/types-7.7.4.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2F%40babel%2Ftypes%2Fdownload%2F%40babel%2Ftypes-7.7.4.tgz#516570d539e44ddf308c07569c258ff94fde9193" 188 | integrity sha1-UWVw1TnkTd8wjAdWnCWP+U/ekZM= 189 | dependencies: 190 | esutils "^2.0.2" 191 | lodash "^4.17.13" 192 | to-fast-properties "^2.0.0" 193 | 194 | ansi-styles@^3.2.1: 195 | version "3.2.1" 196 | resolved "https://registry.npm.taobao.org/ansi-styles/download/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" 197 | integrity sha1-QfuyAkPlCxK+DwS43tvwdSDOhB0= 198 | dependencies: 199 | color-convert "^1.9.0" 200 | 201 | chalk@^2.0.0: 202 | version "2.4.2" 203 | resolved "https://registry.npm.taobao.org/chalk/download/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" 204 | integrity sha1-zUJUFnelQzPPVBpJEIwUMrRMlCQ= 205 | dependencies: 206 | ansi-styles "^3.2.1" 207 | escape-string-regexp "^1.0.5" 208 | supports-color "^5.3.0" 209 | 210 | color-convert@^1.9.0: 211 | version "1.9.3" 212 | resolved "https://registry.npm.taobao.org/color-convert/download/color-convert-1.9.3.tgz#bb71850690e1f136567de629d2d5471deda4c1e8" 213 | integrity sha1-u3GFBpDh8TZWfeYp0tVHHe2kweg= 214 | dependencies: 215 | color-name "1.1.3" 216 | 217 | color-name@1.1.3: 218 | version "1.1.3" 219 | resolved "https://registry.npm.taobao.org/color-name/download/color-name-1.1.3.tgz#a7d0558bd89c42f795dd42328f740831ca53bc25" 220 | integrity sha1-p9BVi9icQveV3UIyj3QIMcpTvCU= 221 | 222 | convert-source-map@^1.7.0: 223 | version "1.7.0" 224 | resolved "https://registry.npm.taobao.org/convert-source-map/download/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442" 225 | integrity sha1-F6LLiC1/d9NJBYXizmxSRCSjpEI= 226 | dependencies: 227 | safe-buffer "~5.1.1" 228 | 229 | debug@^4.1.0: 230 | version "4.1.1" 231 | resolved "https://registry.npm.taobao.org/debug/download/debug-4.1.1.tgz#3b72260255109c6b589cee050f1d516139664791" 232 | integrity sha1-O3ImAlUQnGtYnO4FDx1RYTlmR5E= 233 | dependencies: 234 | ms "^2.1.1" 235 | 236 | escape-string-regexp@^1.0.5: 237 | version "1.0.5" 238 | resolved "https://registry.npm.taobao.org/escape-string-regexp/download/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4" 239 | integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ= 240 | 241 | esutils@^2.0.2: 242 | version "2.0.3" 243 | resolved "https://registry.npm.taobao.org/esutils/download/esutils-2.0.3.tgz#74d2eb4de0b8da1293711910d50775b9b710ef64" 244 | integrity sha1-dNLrTeC42hKTcRkQ1Qd1ubcQ72Q= 245 | 246 | globals@^11.1.0: 247 | version "11.12.0" 248 | resolved "https://registry.npm.taobao.org/globals/download/globals-11.12.0.tgz#ab8795338868a0babd8525758018c2a7eb95c42e" 249 | integrity sha1-q4eVM4hooLq9hSV1gBjCp+uVxC4= 250 | 251 | has-flag@^3.0.0: 252 | version "3.0.0" 253 | resolved "https://registry.npm.taobao.org/has-flag/download/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" 254 | integrity sha1-tdRU3CGZriJWmfNGfloH87lVuv0= 255 | 256 | js-tokens@^4.0.0: 257 | version "4.0.0" 258 | resolved "https://registry.npm.taobao.org/js-tokens/download/js-tokens-4.0.0.tgz#19203fb59991df98e3a287050d4647cdeaf32499" 259 | integrity sha1-GSA/tZmR35jjoocFDUZHzerzJJk= 260 | 261 | jsesc@^2.5.1: 262 | version "2.5.2" 263 | resolved "https://registry.npm.taobao.org/jsesc/download/jsesc-2.5.2.tgz#80564d2e483dacf6e8ef209650a67df3f0c283a4" 264 | integrity sha1-gFZNLkg9rPbo7yCWUKZ98/DCg6Q= 265 | 266 | json5@^2.1.0: 267 | version "2.1.1" 268 | resolved "https://registry.npm.taobao.org/json5/download/json5-2.1.1.tgz#81b6cb04e9ba496f1c7005d07b4368a2638f90b6" 269 | integrity sha1-gbbLBOm6SW8ccAXQe0NoomOPkLY= 270 | dependencies: 271 | minimist "^1.2.0" 272 | 273 | lodash@^4.17.13: 274 | version "4.17.15" 275 | resolved "https://registry.npm.taobao.org/lodash/download/lodash-4.17.15.tgz?cache=0&sync_timestamp=1577793955950&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Flodash%2Fdownload%2Flodash-4.17.15.tgz#b447f6670a0455bbfeedd11392eff330ea097548" 276 | integrity sha1-tEf2ZwoEVbv+7dETku/zMOoJdUg= 277 | 278 | minimist@^1.2.0: 279 | version "1.2.0" 280 | resolved "https://registry.npm.taobao.org/minimist/download/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284" 281 | integrity sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ= 282 | 283 | ms@^2.1.1: 284 | version "2.1.2" 285 | resolved "https://registry.npm.taobao.org/ms/download/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" 286 | integrity sha1-0J0fNXtEP0kzgqjrPM0YOHKuYAk= 287 | 288 | path-parse@^1.0.6: 289 | version "1.0.6" 290 | resolved "https://registry.npm.taobao.org/path-parse/download/path-parse-1.0.6.tgz#d62dbb5679405d72c4737ec58600e9ddcf06d24c" 291 | integrity sha1-1i27VnlAXXLEc37FhgDp3c8G0kw= 292 | 293 | resolve@^1.3.2: 294 | version "1.14.2" 295 | resolved "https://registry.npm.taobao.org/resolve/download/resolve-1.14.2.tgz#dbf31d0fa98b1f29aa5169783b9c290cb865fea2" 296 | integrity sha1-2/MdD6mLHymqUWl4O5wpDLhl/qI= 297 | dependencies: 298 | path-parse "^1.0.6" 299 | 300 | safe-buffer@~5.1.1: 301 | version "5.1.2" 302 | resolved "https://registry.npm.taobao.org/safe-buffer/download/safe-buffer-5.1.2.tgz#991ec69d296e0313747d59bdfd2b745c35f8828d" 303 | integrity sha1-mR7GnSluAxN0fVm9/St0XDX4go0= 304 | 305 | semver@^5.4.1: 306 | version "5.7.1" 307 | resolved "https://registry.npm.taobao.org/semver/download/semver-5.7.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fsemver%2Fdownload%2Fsemver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" 308 | integrity sha1-qVT5Ma66UI0we78Gnv8MAclhFvc= 309 | 310 | source-map@^0.5.0: 311 | version "0.5.7" 312 | resolved "https://registry.npm.taobao.org/source-map/download/source-map-0.5.7.tgz#8a039d2d1021d22d1ea14c80d8ea468ba2ef3fcc" 313 | integrity sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w= 314 | 315 | supports-color@^5.3.0: 316 | version "5.5.0" 317 | resolved "https://registry.npm.taobao.org/supports-color/download/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" 318 | integrity sha1-4uaaRKyHcveKHsCzW2id9lMO/I8= 319 | dependencies: 320 | has-flag "^3.0.0" 321 | 322 | to-fast-properties@^2.0.0: 323 | version "2.0.0" 324 | resolved "https://registry.npm.taobao.org/to-fast-properties/download/to-fast-properties-2.0.0.tgz#dc5e698cbd079265bc73e0377681a4e4e83f616e" 325 | integrity sha1-3F5pjL0HkmW8c+A3doGk5Og/YW4= 326 | --------------------------------------------------------------------------------