Skip to content

[App Extensibility ⚙️] Fix Babel configuration ignore node_modules folder adjusted for Windows (@W-17373534@)#2230

Merged
adamraya merged 11 commits intofeature/extensibility-v2from
W-17373534-ignore-node_modules-windows
Jan 31, 2025
Merged

[App Extensibility ⚙️] Fix Babel configuration ignore node_modules folder adjusted for Windows (@W-17373534@)#2230
adamraya merged 11 commits intofeature/extensibility-v2from
W-17373534-ignore-node_modules-windows

Conversation

@adamraya
Copy link
Contributor

@adamraya adamraya commented Jan 30, 2025

Description

Follow up on PR #2228 by adjusting the Babel changes to ensure compatibility with Windows.

Adjusted Babel config to support Windows using backslashes \ and Unix-like systems using forward slashes / as path separators.

Screenshot 2025-01-30 at 1 21 20 PM

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Adjusted Babel config to support Windows and Unix-like systems.

How to Test-Drive This PR

  1. Checkout this branch W-17373534-ignore-node_modules-windows on a Windows machine and run npm ci.

  2. Run the generator with this configuration:

node .\packages\pwa-kit-create-app\scripts\create-mobify-app-dev.js
? What type of PWA Kit project would you like to create? PWA Kit Application
? Do you want to use Application Extensibility? Yes
? Which Application Extensions do you want to install? @salesforce/extension-chakra-store-locator, @salesforce/extension-chakra-storefront
? ⚠️ WARNING: If you choose to extract the Application Extension code,
you will NO LONGER be able to consume upgrades from NPM. All changes
made to the extracted code will be YOUR RESPONSIBILITY.

Do you want to proceed with extracting the Application Extensions code? No
? What is the name of your Project? test
Installing dependencies for test... This may take a few minutes.
  1. Copy the content of packages\extension-chakra-storefront\config\sample.json into the extension-chakra-storefront inside the generated project package.json file.
  2. Strat the project removing Babel cache.
rmdir /s /q node_modules\.cache
set BABEL_DISABLE_CACHE=1 
npm start

Verify

  1. Observe no Babel warnings are present in the dev server logs.
  2. Smoke test the extensions by navigating through the storefront

Check previous PR to test on a Mac machine: #2228

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

@adamraya adamraya requested a review from a team as a code owner January 30, 2025 21:44
@adamraya adamraya added the skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated label Jan 30, 2025
([packageName]) =>
fse.realpathSync(
p.resolve(p.join(NODE_MODULES_PATH, packageName, 'src'))
) + '/**'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be \** in window?

Copy link
Contributor Author

@adamraya adamraya Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

// NOTE: Because our extensions are just folders containing source code, we need to ensure that the babel-loader processes them.
// This regex exclude everything in node_modules, but node_modules/extensions-*/ folders
exclude: /node_modules\/(?!(@?[^/]+\/)?extension-)[^/]+\/.*$/i,
exclude: /node_modules[\\/](?!(@?[^\\/]+[\\/])?extension-)[^\\/]+[\\/].*$/i,
Copy link
Contributor

@kevinxh kevinxh Jan 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could use path.sep to simplify this regex a bit...

new Regex(`${path.sep}`)

extensionSrcPaths.length > 0 ? `,${extensionSrcPaths.join(',')}` : ''

const babelArgs = `--only "app/**,${serverPath},${placeHolderPath}${extensionsPathsStr}"`
const babelArgs = `--only "app/**,${serverPath},${placeHolderPath}${extensionsPathsStr}"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above?

if (/node_modules\/@[^/]+\/(pwa-kit-extension-sdk|extension-)/.test(filepath)) {
if (
new RegExp(
`node_modules\\${path.sep}[^\\${path.sep}]+\\${path.sep}(pwa-kit-extension-sdk|@[^\\${path.sep}]+\\${path.sep}extension-|extension-)`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit, maybe it's worth saving this to a variable for re-use

@adamraya adamraya merged commit 64bb4ae into feature/extensibility-v2 Jan 31, 2025
27 checks passed
@adamraya adamraya deleted the W-17373534-ignore-node_modules-windows branch January 31, 2025 23:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

skip changelog Skip the "Changelog Check" GitHub Actions step even if the Changelog.md files are not updated

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants