Skip to content

Commit

Permalink
fix(expo): remove deprecated webpack. (nrwl#26137)
Browse files Browse the repository at this point in the history
config.js

<!-- Please make sure you have read the submission guidelines before
posting an PR -->
<!--
https://github.com/nrwl/nx/blob/master/CONTRIBUTING.md#-submitting-a-pr
-->

<!-- Please make sure that your commit message follows our format -->
<!-- Example: `fix(nx): must begin with lowercase` -->

## Current Behavior
<!-- This is the behavior we have today -->

## Expected Behavior
<!-- This is the behavior we should expect with the changes in this PR
-->

## Related Issue(s)
<!-- Please link the issue being fixed so it gets closed when this is
merged. -->

Fixes nrwl#26118
nrwl#25291
nrwl#23233
  • Loading branch information
xiongemi authored May 31, 2024
1 parent a2ca3d3 commit 2cb7ecb
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 63 deletions.
6 changes: 6 additions & 0 deletions packages/expo/migrations.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@
"cli": "nx",
"description": "Change webpack to metro in expo projects",
"factory": "./src/migrations/update-19-0-0/change-webpack-to-metro"
},
"update-19-2-0-remove-webpack-config": {
"version": "19.2.0-beta.2",
"cli": "nx",
"description": "Remove deprecated webpack.config.js",
"factory": "./src/migrations/update-19-2-0/remove-deprecated-webpack-config"
}
},
"packageJsonUpdates": {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,14 @@ export default async function update(tree: Tree) {
config.targets['export-web'].options.bundler = 'metro';
}

updateJson(tree, `${config.root}/app.json`, (appJson) => {
if (appJson.expo?.web) {
appJson.expo.web.bundler = 'metro';
}
return appJson;
});
if (tree.exists(`${config.root}/app.json`)) {
updateJson(tree, `${config.root}/app.json`, (appJson) => {
if (appJson.expo?.web) {
appJson.expo.web.bundler = 'metro';
}
return appJson;
});
}
}

updateProjectConfiguration(tree, name, config);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { addProjectConfiguration, Tree } from '@nx/devkit';
import { createTreeWithEmptyWorkspace } from '@nx/devkit/testing';
import update from './remove-deprecated-webpack-config';

describe('remove-deprecated-webpack-config', () => {
let tree: Tree;

beforeEach(async () => {
tree = createTreeWithEmptyWorkspace({ layout: 'apps-libs' });
addProjectConfiguration(tree, 'product', {
root: 'apps/product',
sourceRoot: 'apps/product/src',
targets: {
start: {
executor: '@nx/expo:start',
},
},
});
tree.write(
`apps/product/webpack.config.js`,
'module.exports = { /* webpack config */ };'
);
});

it(`should remove webpack.config.js`, async () => {
await update(tree);

expect(tree.exists('apps/product/webpack.config.js')).toBe(false);
});
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Tree, getProjects } from '@nx/devkit';
import { removeSync } from 'fs-extra';
import { join } from 'path';

/**
* This function removes the deprecated webpack.config.js file from projects that use the expo:start executor
* @param tree
*/
export default async function update(tree: Tree) {
const projects = getProjects(tree);

for (const [_, config] of projects.entries()) {
if (config.targets?.['start']?.executor === '@nx/expo:start') {
if (tree.exists(join(config.root, 'webpack.config.js'))) {
tree.delete(join(config.root, 'webpack.config.js'));
}
}
}
}

0 comments on commit 2cb7ecb

Please sign in to comment.