-
Notifications
You must be signed in to change notification settings - Fork 145
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[App Extensibility ⚙️] Fix Babel configuration ignore node_modules
folder (@W-17373534@)
#2228
Changes from 12 commits
b9f3a7e
2230d17
0401f10
c099e68
d5de6f6
049e826
9a491a9
9e3d3b8
2f1c77b
90d0357
bf4968d
394f9b3
e60e441
64e45c7
645f65d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,5 +57,22 @@ export default { | |
presets: [require('@babel/preset-env'), require('@babel/preset-react')], | ||
plugins: [require('babel-plugin-dynamic-import-node-babel-7')] | ||
} | ||
} | ||
}, | ||
ignore: [ | ||
function (filepath) { | ||
// Ignore node_modules, but include @salesforce/extension-* and pwa-kit-extension-sdk | ||
if (/node_modules/.test(filepath)) { | ||
// Only ignore non-extension @salesforce packages | ||
if ( | ||
/node_modules\/(?!@salesforce\/pwa-kit-extension-sdk|@salesforce\/extension-)/.test( | ||
filepath | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Unblocking comment, let's look a bit further in the future when partners start to create their own extensions. Do they have to follow the pattern of @salesforce/extension-* or just extension-* or their brand name like this @company/extension? |
||
) | ||
) { | ||
return true | ||
} | ||
return false | ||
} | ||
return false | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I asked AI to invert the logic to get rid of the nested conditions. Here is the output i got:
|
||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,6 +340,8 @@ const ruleForBabelLoader = (babelPlugins) => { | |
id: 'babel-loader', | ||
test: /(\.js(x?)|\.ts(x?))$/, | ||
// NOTE: Because our extensions are just folders containing source code, we need to ensure that the babel-loader processes them. | ||
// By default babel doesn't process files in "node_modules" folder, so here we will ensure they are included. | ||
exclude: /node_modules\/(?!(@?[^/]+\/)?extension-)[^/]+\/.*$/i, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. normally I wouldn't advocate to document the "what", only the "why"s. But I feel like when it comes to regexes, we should add a quick explanation of what this regex aims to do. Because it's hard to tell unless you copy and paste the regex to a tool like https://regexr.com/ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. i.e. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dumb question, we have There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are different configurations that don't work with each other. One is the Webpack configuration for babel-loader, and the other is the Babel configuration for babel-node, where we cannot use the exclude option. They are used in separate stages. |
||
use: [ | ||
{ | ||
loader: findDepInStack('babel-loader'), | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL you can pass a function into babel config ignore :-o. Any doc link about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's basically creating an inline Babel plugin. See https://babeljs.io/docs/plugins#plugin-development