Skip to content

Commit

Permalink
Enable a babel plugin in the sharing and mountable projects for a new…
Browse files Browse the repository at this point in the history
… syntax that has been introduced to the upstream codebase
  • Loading branch information
whitphx committed Feb 7, 2023
1 parent 12242a9 commit 9fe1fa6
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
3 changes: 2 additions & 1 deletion packages/mountable/config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,8 @@ module.exports = function (webpackEnv) {
],

plugins: [
"@emotion", // This line has been added after ejection. The emotion babel plugin is necessary for the Streamlit frontend: https://github.com/streamlit/streamlit/blob/786da40420cd5b6d7682da42837c6ecf861e8464/frontend/craco.config.js#L44
"@emotion", // Stlite: This line has been added after ejection. The emotion babel plugin is necessary for the Streamlit frontend: https://github.com/streamlit/streamlit/blob/786da40420cd5b6d7682da42837c6ecf861e8464/frontend/craco.config.js#L44
"@babel/plugin-proposal-logical-assignment-operators", // Stlite: This specific plugin is needed to parse the upstream source code with the CRA default browserslist setting. See https://github.com/whitphx/stlite/issues/471
[
require.resolve('babel-plugin-named-asset-import'),
{
Expand Down
19 changes: 11 additions & 8 deletions packages/sharing/craco.config.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
const path = require('path');
const path = require("path");

module.exports = {
babel: {
plugins: ["@emotion"],
plugins: [
"@emotion",
"@babel/plugin-proposal-logical-assignment-operators", // Stlite: This specific plugin is needed to parse the upstream source code with the CRA default browserslist setting. See https://github.com/whitphx/stlite/issues/471
],
loaderOptions: {
cacheDirectory: true,
},
Expand All @@ -21,16 +24,16 @@ module.exports = {
/* To resolve the alias streamlit/frontend uses */
webpackConfig.resolve.alias = {
...webpackConfig.resolve.alias,
"src": path.resolve(__dirname, "../../streamlit/frontend/src")
}
src: path.resolve(__dirname, "../../streamlit/frontend/src"),
};

/* To build Streamlit. These configs are copied from streamlit/frontend/craco.config.js */
// Apache Arrow uses .mjs
webpackConfig.module.rules.push({
include: /node_modules/,
test: /\.mjs$/,
type: "javascript/auto",
})
});

/* For file-loader that resolves the wheels */
// Since Webpack5, Asset Modules has been introduced to cover what file-loader had done.
Expand All @@ -52,6 +55,6 @@ module.exports = {
// })

return webpackConfig;
}
}
}
},
},
};

0 comments on commit 9fe1fa6

Please sign in to comment.