@bigbinary/neeto-commons-frontend 4.12.3 → 4.13.0-beta.0
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.
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
const commonResolve = require("@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js");
|
|
4
|
+
|
|
5
|
+
const appResolve = require("../webpack/resolve.js");
|
|
6
|
+
|
|
7
|
+
module.exports = {
|
|
8
|
+
...commonResolve.alias,
|
|
9
|
+
...appResolve.alias,
|
|
10
|
+
images: path.resolve(process.cwd(), "app/assets/images"),
|
|
11
|
+
assert: require.resolve("assert/"),
|
|
12
|
+
buffer: require.resolve("buffer/"),
|
|
13
|
+
crypto: require.resolve("crypto-browserify"),
|
|
14
|
+
http: require.resolve("stream-http"),
|
|
15
|
+
https: require.resolve("https-browserify"),
|
|
16
|
+
os: require.resolve("os-browserify/browser"),
|
|
17
|
+
path: require.resolve("path-browserify"),
|
|
18
|
+
perf_hooks: require.resolve("perf_hooks"),
|
|
19
|
+
stream: require.resolve("stream-browserify"),
|
|
20
|
+
tty: require.resolve("tty-browserify"),
|
|
21
|
+
url: require.resolve("url/"),
|
|
22
|
+
util: require.resolve("util/"),
|
|
23
|
+
vm: require.resolve("vm-browserify"),
|
|
24
|
+
zlib: require.resolve("browserify-zlib"),
|
|
25
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
const {
|
|
2
|
+
TRANSFORM_RULES,
|
|
3
|
+
} = require("@bigbinary/neeto-commons-frontend/configs/constants.js");
|
|
4
|
+
|
|
5
|
+
module.exports = api => {
|
|
6
|
+
api.cache(true);
|
|
7
|
+
|
|
8
|
+
return {
|
|
9
|
+
presets: ["@bigbinary/neeto"],
|
|
10
|
+
plugins: [
|
|
11
|
+
[
|
|
12
|
+
"module-resolver",
|
|
13
|
+
{
|
|
14
|
+
root: ["./src"],
|
|
15
|
+
alias: {
|
|
16
|
+
"dayjs/plugin/timezone":
|
|
17
|
+
"@bigbinary/neeto-commons-frontend/utils/timezonePlugin",
|
|
18
|
+
},
|
|
19
|
+
loglevel: "silent",
|
|
20
|
+
},
|
|
21
|
+
],
|
|
22
|
+
...TRANSFORM_RULES,
|
|
23
|
+
],
|
|
24
|
+
};
|
|
25
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
|
|
3
|
+
const commonResolve = require("@bigbinary/neeto-commons-frontend/configs/webpack/resolve.js");
|
|
4
|
+
const dotenv = require("dotenv");
|
|
5
|
+
const rails = require("esbuild-rails");
|
|
6
|
+
const { sassPlugin } = require("esbuild-sass-plugin");
|
|
7
|
+
const postcss = require("postcss");
|
|
8
|
+
|
|
9
|
+
const alias = require("./alias.js");
|
|
10
|
+
const { babelPlugin } = require("./plugins/babel.js");
|
|
11
|
+
const { prevalPlugin } = require("./plugins/preval.js");
|
|
12
|
+
const {
|
|
13
|
+
createDefinitions,
|
|
14
|
+
entryPoint,
|
|
15
|
+
createModuleEntryPoints,
|
|
16
|
+
build,
|
|
17
|
+
watch,
|
|
18
|
+
createBigbinaryEntryPoints,
|
|
19
|
+
} = require("./utils.js");
|
|
20
|
+
|
|
21
|
+
// @ts-ignore
|
|
22
|
+
const postCssConfig = require("../../../../../postcss.config.js");
|
|
23
|
+
|
|
24
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
25
|
+
const isWatchMode = process.argv.includes("--watch");
|
|
26
|
+
|
|
27
|
+
dotenv.config({ path: isProduction ? ".env" : ".env.development" });
|
|
28
|
+
|
|
29
|
+
const config = {
|
|
30
|
+
entryPoints: {
|
|
31
|
+
application: entryPoint("app/javascript/packs/application.js"),
|
|
32
|
+
...createBigbinaryEntryPoints(),
|
|
33
|
+
...createModuleEntryPoints(["antd", "recharts", "emojiMart"]),
|
|
34
|
+
},
|
|
35
|
+
bundle: true,
|
|
36
|
+
splitting: true,
|
|
37
|
+
outdir: path.join(process.cwd(), "app/assets/builds"),
|
|
38
|
+
minify: isProduction,
|
|
39
|
+
sourcemap: true,
|
|
40
|
+
assetNames: "assets/[name]-[hash].digested",
|
|
41
|
+
chunkNames: "chunks/[name]-[hash].digested",
|
|
42
|
+
publicPath: `${process.env.ASSET_HOST ?? ""}/assets`,
|
|
43
|
+
plugins: [
|
|
44
|
+
rails(),
|
|
45
|
+
prevalPlugin(),
|
|
46
|
+
babelPlugin(),
|
|
47
|
+
sassPlugin({
|
|
48
|
+
async transform(source) {
|
|
49
|
+
const { css } = await postcss(postCssConfig.plugins).process(source);
|
|
50
|
+
|
|
51
|
+
return css;
|
|
52
|
+
},
|
|
53
|
+
importMapper: path =>
|
|
54
|
+
path.replace("@bigbinary/neetoui", "@bigbinary/neetoui/dist"),
|
|
55
|
+
}),
|
|
56
|
+
],
|
|
57
|
+
conditions: ["style"],
|
|
58
|
+
logLevel: "error",
|
|
59
|
+
format: "esm",
|
|
60
|
+
metafile: true,
|
|
61
|
+
platform: "browser",
|
|
62
|
+
mainFields: ["browser", "module", "main"],
|
|
63
|
+
loader: {
|
|
64
|
+
".png": "file",
|
|
65
|
+
".jpeg": "file",
|
|
66
|
+
".jpg": "file",
|
|
67
|
+
".svg": "file",
|
|
68
|
+
".ico": "file",
|
|
69
|
+
},
|
|
70
|
+
external: ["fs", "path", "os", "events"],
|
|
71
|
+
alias,
|
|
72
|
+
jsx: "automatic",
|
|
73
|
+
resolveExtensions: [...commonResolve.extensions, ".jsx"],
|
|
74
|
+
define: {
|
|
75
|
+
"process.env.RAILS_ENV": "'development'",
|
|
76
|
+
"process.env.NODE_DEBUG": "'development'",
|
|
77
|
+
...createDefinitions(process),
|
|
78
|
+
},
|
|
79
|
+
banner: {
|
|
80
|
+
js: isWatchMode
|
|
81
|
+
? `(() => new EventSource("http://localhost:${
|
|
82
|
+
process.env.ESBUILD_PORT || 8000
|
|
83
|
+
}/esbuild").addEventListener('change', () => location.reload()))();`
|
|
84
|
+
: "",
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
isWatchMode ? watch(config) : build(config);
|
|
89
|
+
|
|
90
|
+
exports.config = config;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
const babel = require("@babel/core");
|
|
2
|
+
const parser = require("@babel/parser");
|
|
3
|
+
|
|
4
|
+
const babelPlugin = () => ({
|
|
5
|
+
name: "babel-plugin",
|
|
6
|
+
setup(build) {
|
|
7
|
+
build.onLoad({ filter: /app\/javascript\/.*\.*\.jsx?$/ }, async args => {
|
|
8
|
+
const fs = require("fs").promises;
|
|
9
|
+
const contents = await fs.readFile(args.path, "utf8");
|
|
10
|
+
|
|
11
|
+
const ast = parser.parse(contents, {
|
|
12
|
+
sourceType: "module",
|
|
13
|
+
plugins: ["jsx"],
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
const result = babel.transformFromAstSync(ast, contents);
|
|
17
|
+
const transformedContents = result?.code;
|
|
18
|
+
|
|
19
|
+
return { contents: transformedContents, loader: "jsx" };
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
module.exports = { babelPlugin };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
const PkgTranslations = require("@bigbinary/neeto-commons-frontend/configs/scripts/getPkgTranslations.js");
|
|
2
|
+
|
|
3
|
+
const prevalPlugin = () => ({
|
|
4
|
+
name: "preval-plugin",
|
|
5
|
+
setup(build) {
|
|
6
|
+
build.onLoad(
|
|
7
|
+
{
|
|
8
|
+
filter:
|
|
9
|
+
/node_modules\/@bigbinary\/neeto-commons-frontend\/dist\/(cjs\/)?initializers\/i18n.js/,
|
|
10
|
+
},
|
|
11
|
+
async args => {
|
|
12
|
+
const fs = require("fs").promises;
|
|
13
|
+
const contents = await fs.readFile(args.path, "utf8");
|
|
14
|
+
|
|
15
|
+
const transformedContents = contents.replace(
|
|
16
|
+
`preval.require("../../configs/scripts/getPkgTranslations.js")`,
|
|
17
|
+
JSON.stringify(PkgTranslations)
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
return { contents: transformedContents, loader: "js" };
|
|
21
|
+
}
|
|
22
|
+
);
|
|
23
|
+
},
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
module.exports = { prevalPlugin };
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
const esbuild = require("esbuild");
|
|
2
|
+
const path = require("path");
|
|
3
|
+
const fs = require("fs");
|
|
4
|
+
|
|
5
|
+
// colors for console output
|
|
6
|
+
const consoleColors = {
|
|
7
|
+
info: "\x1b[34m", // Blue
|
|
8
|
+
success: "\x1b[32m", // Green
|
|
9
|
+
warning: "\x1b[33m", // Yellow
|
|
10
|
+
error: "\x1b[31m", // Red
|
|
11
|
+
reset: "\x1b[0m", // Reset
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const createDefinitions = process => {
|
|
15
|
+
return Object.keys(process.env).reduce((acc, key) => {
|
|
16
|
+
acc[`process.env.${key}`] = JSON.stringify(process.env[key]);
|
|
17
|
+
return acc;
|
|
18
|
+
}, {});
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const entryPoint = file => path.join(process.cwd(), file);
|
|
22
|
+
|
|
23
|
+
const createBigbinaryEntryPoints = () => {
|
|
24
|
+
const directoryPath = "node_modules/@bigbinary";
|
|
25
|
+
const excludeList = ["babel-preset-neeto", "eslint-plugin-neeto"];
|
|
26
|
+
const entries = {};
|
|
27
|
+
try {
|
|
28
|
+
const items = fs.readdirSync(directoryPath);
|
|
29
|
+
items.forEach(item => {
|
|
30
|
+
if (excludeList.includes(item)) return;
|
|
31
|
+
const itemPath = path.join(directoryPath, item, "/dist/index.js");
|
|
32
|
+
try {
|
|
33
|
+
fs.accessSync(itemPath);
|
|
34
|
+
entries[item] = entryPoint(itemPath);
|
|
35
|
+
} catch {
|
|
36
|
+
console.log(itemPath, "doesn't exist");
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
return entries;
|
|
40
|
+
} catch (error) {
|
|
41
|
+
console.error(`Error reading directory ${directoryPath}:`, error);
|
|
42
|
+
return {};
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
const createModuleEntryPoints = modules => {
|
|
47
|
+
const entries = {};
|
|
48
|
+
modules.forEach(module => {
|
|
49
|
+
const modulePath = `node_modules/${
|
|
50
|
+
module instanceof String ? module : module.path
|
|
51
|
+
}`;
|
|
52
|
+
const name = module instanceof String ? module : module.name;
|
|
53
|
+
if (fs.existsSync(modulePath)) {
|
|
54
|
+
entries[name] = entryPoint(modulePath);
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
return entries;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const build = async config => {
|
|
61
|
+
try {
|
|
62
|
+
console.info(
|
|
63
|
+
`${consoleColors.info}[esbuild]${consoleColors.reset} Building...`
|
|
64
|
+
);
|
|
65
|
+
await esbuild.build(config);
|
|
66
|
+
console.info(
|
|
67
|
+
`${consoleColors.success}[esbuild]${consoleColors.reset} Build successful`
|
|
68
|
+
);
|
|
69
|
+
} catch {
|
|
70
|
+
console.error(
|
|
71
|
+
`${consoleColors.error}[esbuild]${consoleColors.reset} Build failed`
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
const watch = async config => {
|
|
77
|
+
const ctx = await esbuild.context(config);
|
|
78
|
+
await ctx.watch();
|
|
79
|
+
await ctx.serve({
|
|
80
|
+
servedir: config.outdir,
|
|
81
|
+
port: parseInt(process.env.ESBUILD_PORT || "8000"),
|
|
82
|
+
});
|
|
83
|
+
console.log("watching...");
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
module.exports = {
|
|
87
|
+
createDefinitions,
|
|
88
|
+
entryPoint,
|
|
89
|
+
createModuleEntryPoints,
|
|
90
|
+
build,
|
|
91
|
+
watch,
|
|
92
|
+
createBigbinaryEntryPoints,
|
|
93
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bigbinary/neeto-commons-frontend",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.13.0-beta.0",
|
|
4
4
|
"description": "A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.",
|
|
5
5
|
"repository": "git@github.com:bigbinary/neeto-commons-frontend.git",
|
|
6
6
|
"author": "Amaljith K <amaljith.k@bigbinary.com>",
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
"@babel/runtime": "7.19.0",
|
|
89
89
|
"@babel/types": "^7.20.7",
|
|
90
90
|
"@bigbinary/babel-preset-neeto": "^1.0.3",
|
|
91
|
-
"@bigbinary/eslint-plugin-neeto": "1.5.
|
|
91
|
+
"@bigbinary/eslint-plugin-neeto": "1.5.6",
|
|
92
92
|
"@bigbinary/neeto-audit-frontend": "^2.0.19",
|
|
93
93
|
"@bigbinary/neeto-cist": "1.0.11",
|
|
94
94
|
"@bigbinary/neeto-commons-frontend": "4.4.6",
|
|
@@ -142,6 +142,9 @@
|
|
|
142
142
|
"cypress": "11.2.0",
|
|
143
143
|
"dayjs": "1.11.10",
|
|
144
144
|
"dompurify": "^2.4.0",
|
|
145
|
+
"esbuild": "^0.24.0",
|
|
146
|
+
"esbuild-rails": "^1.0.7",
|
|
147
|
+
"esbuild-sass-plugin": "^3.3.1",
|
|
145
148
|
"eslint": "8.14.0",
|
|
146
149
|
"eslint-config-prettier": "8.5.0",
|
|
147
150
|
"eslint-plugin-cypress": "2.12.1",
|
|
@@ -227,6 +230,9 @@
|
|
|
227
230
|
"dayjs": "1.11.10",
|
|
228
231
|
"dompurify": "^2.4.0",
|
|
229
232
|
"dotenv-webpack": "^8.0.1",
|
|
233
|
+
"esbuild": "^0.24.0",
|
|
234
|
+
"esbuild-rails": "^1.0.7",
|
|
235
|
+
"esbuild-sass-plugin": "^3.3.1",
|
|
230
236
|
"formik": "2.2.9",
|
|
231
237
|
"framer-motion": "11.2.14",
|
|
232
238
|
"husky": "7.0.4",
|