Skip to content
This repository has been archived by the owner on Jan 18, 2024. It is now read-only.

Commit

Permalink
[webpack] fix error for not specifying full extension (#4681)
Browse files Browse the repository at this point in the history
# Why

a regression from webpack 5 upgrade where it should explicitly specify full js extension like `import './foo.js';`. this breaks metro assumption and existing code in [expo-noifications](https://github.com/expo/expo/blob/1120c716f35cb28d88800e8f5d963d2b2ac94705/packages/expo-notifications/src/DevicePushTokenAutoRegistration.fx.ts#L1)

fixes expo/expo#22064
close ENG-8248

# How

add `resolve.fullySpecified=false` as webpack doc mentioned: https://webpack.js.org/configuration/module/#resolvefullyspecified

# Test Plan

based on https://github.com/viveksc1994/expo-48-web and apply the patch
  • Loading branch information
Kudo authored Apr 12, 2023
1 parent 0b97723 commit 21a6c63
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ Object {
Object {
"enforce": "pre",
"exclude": /@babel\\(\\?:\\\\/\\|\\\\\\\\\\{1,2\\}\\)runtime/,
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\|ts\\|tsx\\|css\\)\\$/,
"use": "node_modules/source-map-loader/dist/cjs.js",
},
Expand Down Expand Up @@ -104,6 +107,9 @@ Object {
},
Object {
"include": [Function],
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\|ts\\|tsx\\)\\$/,
"use": Object {
"loader": "node_modules/babel-loader/lib/index.js",
Expand Down Expand Up @@ -260,6 +266,9 @@ Object {
Object {
"enforce": "pre",
"exclude": /@babel\\(\\?:\\\\/\\|\\\\\\\\\\{1,2\\}\\)runtime/,
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\|ts\\|tsx\\|css\\)\\$/,
"use": "node_modules/source-map-loader/dist/cjs.js",
},
Expand Down Expand Up @@ -294,6 +303,9 @@ Object {
},
Object {
"include": [Function],
"resolve": Object {
"fullySpecified": false,
},
"test": /\\\\\\.\\(js\\|mjs\\|jsx\\|ts\\|tsx\\)\\$/,
"use": Object {
"loader": "node_modules/babel-loader/lib/index.js",
Expand Down
3 changes: 3 additions & 0 deletions packages/webpack-config/src/loaders/createBabelLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -239,5 +239,8 @@ export default function createBabelLoader({
loader: require.resolve('babel-loader'),
options: presetOptions,
},
resolve: {
fullySpecified: false,
},
};
}
3 changes: 3 additions & 0 deletions packages/webpack-config/src/webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,9 @@ export default async function (env: Environment, argv: Arguments = {}): Promise<
exclude: /@babel(?:\/|\\{1,2})runtime/,
test: /\.(js|mjs|jsx|ts|tsx|css)$/,
use: require.resolve('source-map-loader'),
resolve: {
fullySpecified: false,
},
},
{
oneOf: allLoaders,
Expand Down

0 comments on commit 21a6c63

Please sign in to comment.