From 87916b660e55b180570e5e111187b32365a2b9a8 Mon Sep 17 00:00:00 2001 From: JoseLion Date: Sun, 30 Jun 2024 13:37:51 -0500 Subject: [PATCH] feat(babel): Extension resolver plugin --- package.json | 2 +- src/lib/babelRegister.ts | 24 +++------- yarn.lock | 94 ++++++++++++---------------------------- 3 files changed, 35 insertions(+), 85 deletions(-) diff --git a/package.json b/package.json index df7258d..f5cedb4 100644 --- a/package.json +++ b/package.json @@ -54,7 +54,7 @@ "dependencies": { "@babel/core": "^7.24.7", "@babel/register": "^7.24.6", - "babel-plugin-module-resolver": "^5.0.2", + "babel-plugin-extension-resolver": "^1.0.12", "dot-prop-immutable": "^2.1.1", "pino": "^9.2.0", "pino-pretty": "^11.2.1", diff --git a/src/lib/babelRegister.ts b/src/lib/babelRegister.ts index 8c471fb..3ce4e7e 100644 --- a/src/lib/babelRegister.ts +++ b/src/lib/babelRegister.ts @@ -4,23 +4,13 @@ register({ cache: true, only: [/node_modules[/\\](react-native|@react-native)[/\\]/], plugins: [ - ["module-resolver", { - resolvePath(sourcePath: string) { - if (sourcePath.startsWith(".")) { - const hastePaths = [ - "/Image", - "/Platform", - "/PlatformColorValueTypes", - "/BaseViewConfig", - ]; - - return hastePaths.some(path => sourcePath.endsWith(path)) - ? `${sourcePath}.ios` - : undefined; - } - - return undefined; - }, + ["extension-resolver", { + extensions: [ + ".ios.js", + ".ios.jsx", + ".js", + ".jsx", + ], }], ], presets: ["module:@react-native/babel-preset"], diff --git a/yarn.lock b/yarn.lock index bf26e4d..ebdeced 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3838,16 +3838,12 @@ __metadata: languageName: node linkType: hard -"babel-plugin-module-resolver@npm:^5.0.2": - version: 5.0.2 - resolution: "babel-plugin-module-resolver@npm:5.0.2" +"babel-plugin-extension-resolver@npm:^1.0.12": + version: 1.0.12 + resolution: "babel-plugin-extension-resolver@npm:1.0.12" dependencies: - find-babel-config: "npm:^2.1.1" - glob: "npm:^9.3.3" - pkg-up: "npm:^3.1.0" - reselect: "npm:^4.1.7" - resolve: "npm:^1.22.8" - checksum: 10/8084fa8a4cd96aaa861e5fe765a6cd03accef64d21d4108e314029bcd5f3a7fd96faf0c877c575a6a24d4fe0d87458d49748ca56faa4c77b2b812e4ed6023768 + resolve: "npm:1.17.0" + checksum: 10/08c84f43b01dcedddf08d556aa69b6a6641cde41fbb21e711cfe080d066bc7ed506a463c1f4bd65f35284571dba55c398e846a299fd164f234d447661a4e7a6b languageName: node linkType: hard @@ -5999,16 +5995,6 @@ __metadata: languageName: node linkType: hard -"find-babel-config@npm:^2.1.1": - version: 2.1.1 - resolution: "find-babel-config@npm:2.1.1" - dependencies: - json5: "npm:^2.2.3" - path-exists: "npm:^4.0.0" - checksum: 10/a3e632a93ba2286b01f1273b90a1ef36e8d53351489817cbec500aa43169cc795122e788f4059c9876e5111dc587be65e46f3a2c9fed9161f21e754821b222d3 - languageName: node - linkType: hard - "find-cache-dir@npm:^2.0.0": version: 2.1.0 resolution: "find-cache-dir@npm:2.1.0" @@ -6399,18 +6385,6 @@ __metadata: languageName: node linkType: hard -"glob@npm:^9.3.3": - version: 9.3.5 - resolution: "glob@npm:9.3.5" - dependencies: - fs.realpath: "npm:^1.0.0" - minimatch: "npm:^8.0.2" - minipass: "npm:^4.2.4" - path-scurry: "npm:^1.6.1" - checksum: 10/e5fa8a58adf53525bca42d82a1fad9e6800032b7e4d372209b80cfdca524dd9a7dbe7d01a92d7ed20d89c572457f12c250092bc8817cb4f1c63efefdf9b658c0 - languageName: node - linkType: hard - "globals@npm:^11.1.0": version: 11.12.0 resolution: "globals@npm:11.12.0" @@ -8586,15 +8560,6 @@ __metadata: languageName: node linkType: hard -"minimatch@npm:^8.0.2": - version: 8.0.4 - resolution: "minimatch@npm:8.0.4" - dependencies: - brace-expansion: "npm:^2.0.1" - checksum: 10/aef05598ee565e1013bc8a10f53410ac681561f901c1a084b8ecfd016c9ed919f58f4bbd5b63e05643189dfb26e8106a84f0e1ff12e4a263aa37e1cae7ce9828 - languageName: node - linkType: hard - "minimatch@npm:^9.0.0, minimatch@npm:^9.0.3, minimatch@npm:^9.0.4": version: 9.0.5 resolution: "minimatch@npm:9.0.5" @@ -8680,13 +8645,6 @@ __metadata: languageName: node linkType: hard -"minipass@npm:^4.2.4": - version: 4.2.8 - resolution: "minipass@npm:4.2.8" - checksum: 10/e148eb6dcb85c980234cad889139ef8ddf9d5bdac534f4f0268446c8792dd4c74f4502479be48de3c1cce2f6450f6da4d0d4a86405a8a12be04c1c36b339569a - languageName: node - linkType: hard - "minipass@npm:^5.0.0": version: 5.0.0 resolution: "minipass@npm:5.0.0" @@ -9716,7 +9674,7 @@ __metadata: languageName: node linkType: hard -"path-scurry@npm:^1.11.1, path-scurry@npm:^1.6.1": +"path-scurry@npm:^1.11.1": version: 1.11.1 resolution: "path-scurry@npm:1.11.1" dependencies: @@ -9895,15 +9853,6 @@ __metadata: languageName: node linkType: hard -"pkg-up@npm:^3.1.0": - version: 3.1.0 - resolution: "pkg-up@npm:3.1.0" - dependencies: - find-up: "npm:^3.0.0" - checksum: 10/5bac346b7c7c903613c057ae3ab722f320716199d753f4a7d053d38f2b5955460f3e6ab73b4762c62fd3e947f58e04f1343e92089e7bb6091c90877406fcd8c8 - languageName: node - linkType: hard - "possible-typed-array-names@npm:^1.0.0": version: 1.0.0 resolution: "possible-typed-array-names@npm:1.0.0" @@ -10239,7 +10188,7 @@ __metadata: "@types/react": "npm:^18.3.3" "@types/react-test-renderer": "npm:^18.3.0" "@types/sinon": "npm:^17.0.3" - babel-plugin-module-resolver: "npm:^5.0.2" + babel-plugin-extension-resolver: "npm:^1.0.12" dot-prop-immutable: "npm:^2.1.1" eslint: "npm:^9.6.0" eslint-import-resolver-typescript: "npm:^3.6.1" @@ -10624,13 +10573,6 @@ __metadata: languageName: node linkType: hard -"reselect@npm:^4.1.7": - version: 4.1.8 - resolution: "reselect@npm:4.1.8" - checksum: 10/199984d9872f71cd207f4aa6e6fd2bd48d95154f7aa9b3aee3398335f39f5491059e732f28c12e9031d5d434adab2c458dc8af5afb6564d0ad37e1644445e09c - languageName: node - linkType: hard - "resolve-from@npm:^3.0.0": version: 3.0.0 resolution: "resolve-from@npm:3.0.0" @@ -10659,7 +10601,16 @@ __metadata: languageName: node linkType: hard -"resolve@npm:^1.14.2, resolve@npm:^1.22.4, resolve@npm:^1.22.8, resolve@npm:~1.22.1": +"resolve@npm:1.17.0": + version: 1.17.0 + resolution: "resolve@npm:1.17.0" + dependencies: + path-parse: "npm:^1.0.6" + checksum: 10/74141da8c56192fd46f6aa887864f8fd74c1755425174526610cb775177278bb414c6f6feb3051ccd73d774d2ae124c6c97e463e30d7ffd9a87f7da202b851dd + languageName: node + linkType: hard + +"resolve@npm:^1.14.2, resolve@npm:^1.22.4, resolve@npm:~1.22.1": version: 1.22.8 resolution: "resolve@npm:1.22.8" dependencies: @@ -10695,7 +10646,16 @@ __metadata: languageName: node linkType: hard -"resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin, resolve@patch:resolve@npm%3A^1.22.8#optional!builtin, resolve@patch:resolve@npm%3A~1.22.1#optional!builtin": +"resolve@patch:resolve@npm%3A1.17.0#optional!builtin": + version: 1.17.0 + resolution: "resolve@patch:resolve@npm%3A1.17.0#optional!builtin::version=1.17.0&hash=c3c19d" + dependencies: + path-parse: "npm:^1.0.6" + checksum: 10/02e87fe9233d169fdc5220572c7b8933c9e23323aaecfd5b8d0b106a7f09dc676dd4d380e66c72b1369489292bcb337b13aad28b480a1bde5a5c040ff16758ea + languageName: node + linkType: hard + +"resolve@patch:resolve@npm%3A^1.14.2#optional!builtin, resolve@patch:resolve@npm%3A^1.22.4#optional!builtin, resolve@patch:resolve@npm%3A~1.22.1#optional!builtin": version: 1.22.8 resolution: "resolve@patch:resolve@npm%3A1.22.8#optional!builtin::version=1.22.8&hash=c3c19d" dependencies: