catalyst-core-internal 0.0.1-beta.64 → 0.0.1-beta.66
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -2,4 +2,5 @@
|
|
|
2
2
|
* @description stores all config.json key value into process.env before server starts.
|
|
3
3
|
*/const loadEnvironmentVariables=()=>{if(validateConfigFile(appConfig)){for(let k in appConfig){// below code provides support for object handling present in config.
|
|
4
4
|
// However, for usage on client the client logic in define plugin needs to be checked and updated
|
|
5
|
-
process.env[k]=typeof appConfig[k]==="object"?JSON.stringify(appConfig[k]):appConfig[k];}}
|
|
5
|
+
process.env[k]=typeof appConfig[k]==="object"?JSON.stringify(appConfig[k]):appConfig[k];}}// Load Sentry configuration if it exists
|
|
6
|
+
try{const sentryConfig=require("@catalyst/template/config/sentry.config.json");process.env.SENTRY_CONFIG=JSON.stringify(sentryConfig);}catch(error){console.warn("Warning: Failed to load sentry.config.json");}};var _default=exports.default=loadEnvironmentVariables;
|
package/dist/sentry.js
ADDED
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.ErrorBoundary=void 0;exports.addBreadcrumb=addBreadcrumb;exports.captureException=captureException;exports.captureMessage=captureMessage;exports.default=void 0;exports.init=init;var _react=_interopRequireDefault(require("react"));var _jsxRuntime=require("react/jsx-runtime");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}let sentryInitialized=false;function getSentryInstance(){let instance=null;const isServer=typeof window==="undefined";if(isServer){try{const sentryNodeModule="@sentry/node";// eslint-disable-next-line security/detect-eval-with-expression, no-eval
|
|
2
|
+
instance=eval(`require("${sentryNodeModule}")`);}catch(error){console.warn("Failed to load @sentry/node:",error.message);return null;}}else{try{instance=require("@sentry/react");}catch(error){console.warn("Failed to load @sentry/react:",error.message);return null;}}return instance;}const Sentry=getSentryInstance();function init(){if(sentryInitialized){console.warn("Sentry has already been initialized");return;}let sentryConfig=process.env.SENTRY_CONFIG;if(!sentryConfig){console.warn("Sentry configuration not found, skipping initialization");return;}try{sentryConfig=JSON.parse(sentryConfig);}catch(error){console.warn("Invalid sentry configuration",error);}const isServer=typeof window==="undefined";if(!sentryConfig.dsn){console.warn("Sentry DSN not found in configuration, skipping initialization");return;}try{if(isServer){Sentry.init({dsn:sentryConfig.dsn,tracesSampleRate:sentryConfig.tracesSampleRate||1.0,...sentryConfig.serverOptions});}else{Sentry.init({dsn:sentryConfig.dsn,tracesSampleRate:sentryConfig.tracesSampleRate||1.0,...sentryConfig.clientOptions});}sentryInitialized=true;}catch(error){console.error("Failed to initialize Sentry:",error.message);return;}}function captureException(error,context={}){Sentry.captureException(error,context);}function captureMessage(message,level="info"){Sentry.captureMessage(message,level);}function addBreadcrumb(breadcrumb){Sentry.addBreadcrumb(breadcrumb);}class ErrorBoundary extends _react.default.Component{constructor(props){super(props);this.state={hasError:false};}static getDerivedStateFromError(){return{hasError:true};}componentDidCatch(error,errorInfo){captureException(error,{componentStack:errorInfo.componentStack});}render(){if(this.state.hasError){if(this.props.fallback){return this.props.fallback;}return/*#__PURE__*/(0,_jsxRuntime.jsx)("h1",{children:"Something went wrong."});}return this.props.children;}}exports.ErrorBoundary=ErrorBoundary;var _default=exports.default={init,captureException,captureMessage,addBreadcrumb};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports,"__esModule",{value:true});exports.default=exports.basePlugins=void 0;var _path=_interopRequireDefault(require("path"));var _webpack=_interopRequireDefault(require("webpack"));var _miniCssExtractPlugin=_interopRequireDefault(require("mini-css-extract-plugin"));var _webpackBundleAnalyzer=require("webpack-bundle-analyzer");var _config=_interopRequireDefault(require("@catalyst/root/config.json"));var _package=require("@catalyst/template/package.json");var _scssParams=require("@catalyst/webpack/scssParams");var _babelConfig=_interopRequireDefault(require("@catalyst/webpack/babel.config.ssr"));var _babelConfig2=_interopRequireDefault(require("@catalyst/webpack/babel.config.client"));var _loadEnvironmentVariables=_interopRequireDefault(require("@catalyst/scripts/loadEnvironmentVariables"));var _config2=require("@catalyst/template/config/config.json");function _interopRequireDefault(e){return e&&e.__esModule?e:{default:e};}(0,_loadEnvironmentVariables.default)();const isDev=process.env.NODE_ENV==="development";const isSSR=!!process.env.SSR||false;const basePlugins=exports.basePlugins=[// **This loads process.env variable during webpack build process
|
|
2
|
-
new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,"BUILD_OUTPUT_PATH","PUBLIC_STATIC_ASSET_PATH","PUBLIC_STATIC_ASSET_URL","src_path","PWD"]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
|
|
2
|
+
new _webpack.default.DefinePlugin({"process.env":([..._config2.CLIENT_ENV_VARIABLES,"BUILD_OUTPUT_PATH","PUBLIC_STATIC_ASSET_PATH","PUBLIC_STATIC_ASSET_URL","src_path","PWD","SENTRY_CONFIG"]||[]).reduce((clientEnvMap,env)=>{clientEnvMap[env]=JSON.stringify(process.env[env]);return clientEnvMap;},{})}),// ** This is used to analyze bundle size.
|
|
3
3
|
_config2.ANALYZE_BUNDLE&&new _webpackBundleAnalyzer.BundleAnalyzerPlugin({generateStatsFile:_config2.ANALYZE_BUNDLE}),new _webpack.default.IgnorePlugin({resourceRegExp:/^\.\/locale$/,contextRegExp:/moment$/})];const{IS_DEV_COMMAND,PUBLIC_STATIC_ASSET_URL,PUBLIC_STATIC_ASSET_PATH,WEBPACK_DEV_SERVER_HOSTNAME,WEBPACK_DEV_SERVER_PORT,NODE_SERVER_HOSTNAME,NODE_SERVER_PORT}=process.env;let publicPath=isDev?`http://${WEBPACK_DEV_SERVER_HOSTNAME}:${WEBPACK_DEV_SERVER_PORT}/`:`${PUBLIC_STATIC_ASSET_URL}${PUBLIC_STATIC_ASSET_PATH}`;// serves assets from local on running devBuild and devServe command
|
|
4
4
|
if(IS_DEV_COMMAND==="true"&&!isDev){publicPath=`http://${NODE_SERVER_HOSTNAME}:${NODE_SERVER_PORT}/assets/`;}var _default=exports.default={context:_path.default.resolve(process.env.src_path),mode:isDev?"development":"production",entry:{app:[_path.default.resolve(process.env.src_path,"./client/index.js")]},output:{path:_path.default.join(process.env.src_path,`${process.env.BUILD_OUTPUT_PATH}/public`),filename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",chunkFilename:process.env.NODE_ENV==="development"?"[name].bundle.js":"[name].[contenthash].js",publicPath:publicPath},resolve:{fallback:{url:require.resolve("url")},extensions:[".js",".jsx",".scss",".ts",".tsx"],alias:Object.keys(_package._moduleAliases||{}).reduce((moduleEnvMap,alias)=>{moduleEnvMap[alias]=_path.default.join(process.env.src_path,..._package._moduleAliases[alias].split("/"));return moduleEnvMap;},{})},plugins:basePlugins,module:{rules:[{test:/\.jsx$|\.js$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{test:/\.tsx$|\.ts$/,exclude:_path.default.resolve(process.env.src_path,"./node_modules"),use:{loader:"babel-loader",options:isSSR?_babelConfig.default:_babelConfig2.default}},{// This loader processes all the .scss files that should be modularized. This should exclude anything inside node_modules and everything inside src/css/base since they should be globally scoped.
|
|
5
5
|
test:/\.scss$/,exclude:[_path.default.resolve(process.env.src_path,"./node_modules"),_path.default.resolve(process.env.src_path,"./src/static/css/base")],use:[isDev&&"css-hot-loader",!isSSR&&_miniCssExtractPlugin.default.loader,{loader:"css-loader",options:{modules:{mode:"local",exportOnlyLocals:!isDev&&isSSR,localIdentName:isDev?_config.default.cssModulesIdentifierDev:_config.default.cssModulesIdentifierProd}}},{loader:"postcss-loader"},{loader:"sass-loader",options:{additionalData:"$font_url: "+(0,_scssParams.fontUrl)()+";"+"$url_for: "+(0,_scssParams.imageUrl)()+";"}},{loader:"sass-resources-loader",options:{resources:[_path.default.resolve(process.env.src_path,"./src/static/css/resources/*.scss")]}}]},{// In development mode, client request app.css ,which has all the css in node_modules and src/static/css/base, This is served by webpack-dev-server. However in prod this css is injected in the doc sent from the server and needs to be global, so we don't pass the files through css-loader to be modularized.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "catalyst-core-internal",
|
|
3
|
-
"version": "0.0.1-beta.
|
|
3
|
+
"version": "0.0.1-beta.66",
|
|
4
4
|
"main": "index.js",
|
|
5
5
|
"description": "Web framework that provides great performance out of the box",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,8 @@
|
|
|
28
28
|
".": "./dist/index.js",
|
|
29
29
|
"./logger": "./dist/logger.js",
|
|
30
30
|
"./caching": "./dist/caching.js",
|
|
31
|
-
"./router/ClientRouter": "./dist/router/ClientRouter.js"
|
|
31
|
+
"./router/ClientRouter": "./dist/router/ClientRouter.js",
|
|
32
|
+
"./sentry": "./dist/sentry.js"
|
|
32
33
|
},
|
|
33
34
|
"scripts": {
|
|
34
35
|
"lint": "eslint .",
|