@mainset/builder-rslib 0.1.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.
- package/LICENSE +2 -0
- package/dist/esm/index.mjs +2 -0
- package/dist/esm/rslib.node-package.config.mjs +62 -0
- package/dist/esm/rslib.react.config.mjs +14 -0
- package/dist/esm/rslib.ssr-server.config.mjs +68 -0
- package/dist/esm/utils.mjs +5 -0
- package/dist/types/index.d.mts +2 -0
- package/dist/types/rslib.node-package.config.d.mts +5 -0
- package/dist/types/rslib.react.config.d.mts +5 -0
- package/dist/types/rslib.ssr-server.config.d.mts +4 -0
- package/dist/types/utils.d.mts +4 -0
- package/package.json +40 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import '@mainset/cli/process-env-type';
|
|
2
|
+
import { NODE_ENV, runtimePathById } from '@mainset/cli/runtime';
|
|
3
|
+
import { defineConfig } from '@rslib/core';
|
|
4
|
+
import path from 'path';
|
|
5
|
+
import { initRslibConfigGenerator } from './utils.mjs';
|
|
6
|
+
// NOTE: there is no sense in minimizing {*.min.js} / {*.min.css} output files in node package
|
|
7
|
+
// during development debugging complete JS code / full CSS class gives a better dev experience
|
|
8
|
+
// the bundler of the final web app should be responsible for the minification of the final output files
|
|
9
|
+
const nodePackageCommonPresetRslib = defineConfig({
|
|
10
|
+
mode: process.env.NODE_ENV || NODE_ENV.PRODUCTION,
|
|
11
|
+
lib: [
|
|
12
|
+
{
|
|
13
|
+
format: 'esm',
|
|
14
|
+
// OutBase: runtimePathById.dist,
|
|
15
|
+
output: {
|
|
16
|
+
filename: {
|
|
17
|
+
js: 'esm/index.mjs',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
format: 'cjs',
|
|
23
|
+
// OutBase: runtimePathById.dist,
|
|
24
|
+
output: {
|
|
25
|
+
filename: {
|
|
26
|
+
js: 'cjs/index.cjs',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
],
|
|
31
|
+
source: {
|
|
32
|
+
entry: {
|
|
33
|
+
index: [path.join(runtimePathById.src, 'index.mts')],
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
output: {
|
|
37
|
+
target: 'web',
|
|
38
|
+
distPath: {
|
|
39
|
+
root: runtimePathById.dist,
|
|
40
|
+
},
|
|
41
|
+
filename: {
|
|
42
|
+
css: `css/main.css`,
|
|
43
|
+
},
|
|
44
|
+
// CssModules: {
|
|
45
|
+
// localIdentName: '[local]--[hash:base64:6]',
|
|
46
|
+
// },
|
|
47
|
+
// https://rsbuild.dev/config/output/source-map#default-behavior
|
|
48
|
+
// sourceMap: true,
|
|
49
|
+
},
|
|
50
|
+
tools: {
|
|
51
|
+
cssLoader: {
|
|
52
|
+
modules: {
|
|
53
|
+
// Support CSS Modules syntax as {import styles from './styles.module.css'}
|
|
54
|
+
namedExport: true,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
},
|
|
58
|
+
});
|
|
59
|
+
const generateNodePackageRslibConfig = initRslibConfigGenerator(nodePackageCommonPresetRslib);
|
|
60
|
+
export { generateNodePackageRslibConfig, nodePackageCommonPresetRslib };
|
|
61
|
+
// NOTE: the default export is used to point config file in {mainset-cli}
|
|
62
|
+
export default nodePackageCommonPresetRslib;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import '@mainset/cli/process-env-type';
|
|
2
|
+
import { merge } from '@mainset/toolkit-js';
|
|
3
|
+
import { pluginReact } from '@rsbuild/plugin-react';
|
|
4
|
+
import { pluginSass } from '@rsbuild/plugin-sass';
|
|
5
|
+
import { nodePackageCommonPresetRslib } from './rslib.node-package.config.mjs';
|
|
6
|
+
import { initRslibConfigGenerator } from './utils.mjs';
|
|
7
|
+
const reactCommonPresetRslib = merge(nodePackageCommonPresetRslib, {
|
|
8
|
+
lib: [],
|
|
9
|
+
plugins: [pluginReact(), pluginSass()],
|
|
10
|
+
});
|
|
11
|
+
const generateReactRslibConfig = initRslibConfigGenerator(reactCommonPresetRslib);
|
|
12
|
+
export { generateReactRslibConfig };
|
|
13
|
+
// NOTE: the default export is used to point config file in {mainset-cli}
|
|
14
|
+
export default reactCommonPresetRslib;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import '@mainset/cli/process-env-type';
|
|
2
|
+
import { NODE_ENV, runtimePathById } from '@mainset/cli/runtime';
|
|
3
|
+
import { merge } from '@mainset/toolkit-js';
|
|
4
|
+
import { pluginReact } from '@rsbuild/plugin-react';
|
|
5
|
+
import { pluginSass } from '@rsbuild/plugin-sass';
|
|
6
|
+
import { defineConfig } from '@rslib/core';
|
|
7
|
+
import path from 'path';
|
|
8
|
+
const devPresetRslib = {
|
|
9
|
+
mode: NODE_ENV.DEVELOPMENT,
|
|
10
|
+
output: {
|
|
11
|
+
minify: false,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const prodPresetRslib = {
|
|
15
|
+
mode: NODE_ENV.PRODUCTION,
|
|
16
|
+
output: {
|
|
17
|
+
minify: false,
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
const ssrServerPresetRslib = defineConfig({
|
|
21
|
+
lib: [
|
|
22
|
+
{
|
|
23
|
+
format: 'esm',
|
|
24
|
+
// OutBase: runtimePathById.dist,
|
|
25
|
+
output: {
|
|
26
|
+
filename: {
|
|
27
|
+
js: '[name].mjs',
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
],
|
|
32
|
+
source: {
|
|
33
|
+
entry: {
|
|
34
|
+
'ssr-server.config': [
|
|
35
|
+
path.join(runtimePathById.root, 'config', 'ssr-server.config.mts'),
|
|
36
|
+
],
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
output: {
|
|
40
|
+
target: 'node',
|
|
41
|
+
distPath: {
|
|
42
|
+
root: path.join(runtimePathById.dist, 'private'),
|
|
43
|
+
},
|
|
44
|
+
filename: {
|
|
45
|
+
css: `css/main.css`,
|
|
46
|
+
},
|
|
47
|
+
// CssModules: {
|
|
48
|
+
// localIdentName: '[local]--[hash:base64:6]',
|
|
49
|
+
// },
|
|
50
|
+
// https://rsbuild.dev/config/output/source-map#default-behavior
|
|
51
|
+
// sourceMap: true,
|
|
52
|
+
},
|
|
53
|
+
plugins: [pluginReact(), pluginSass()],
|
|
54
|
+
tools: {
|
|
55
|
+
cssLoader: {
|
|
56
|
+
modules: {
|
|
57
|
+
// Support CSS Modules syntax as {import styles from './styles.module.css'}
|
|
58
|
+
namedExport: true,
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
const ssrServerEnvBasedPresetRslib = {
|
|
64
|
+
[NODE_ENV.DEVELOPMENT]: merge(ssrServerPresetRslib, devPresetRslib),
|
|
65
|
+
[NODE_ENV.PRODUCTION]: merge(ssrServerPresetRslib, prodPresetRslib),
|
|
66
|
+
};
|
|
67
|
+
// NOTE: the default export is used to point config file in {mainset-cli}
|
|
68
|
+
export default ssrServerEnvBasedPresetRslib[process.env.NODE_ENV || NODE_ENV.PRODUCTION];
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '@mainset/cli/process-env-type';
|
|
2
|
+
declare const nodePackageCommonPresetRslib: import("@rslib/core").RslibConfig;
|
|
3
|
+
declare const generateNodePackageRslibConfig: (extendedConfig?: Omit<import("@rslib/core").RslibConfig, "lib">) => Omit<import("@rslib/core").RslibConfig, "lib">;
|
|
4
|
+
export { generateNodePackageRslibConfig, nodePackageCommonPresetRslib };
|
|
5
|
+
export default nodePackageCommonPresetRslib;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import '@mainset/cli/process-env-type';
|
|
2
|
+
declare const reactCommonPresetRslib: import("@rslib/core").RslibConfig;
|
|
3
|
+
declare const generateReactRslibConfig: (extendedConfig?: Omit<import("@rslib/core").RslibConfig, "lib">) => Omit<import("@rslib/core").RslibConfig, "lib">;
|
|
4
|
+
export { generateReactRslibConfig };
|
|
5
|
+
export default reactCommonPresetRslib;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { merge } from '@mainset/toolkit-js';
|
|
2
|
+
import type { RslibConfig } from '@rslib/core';
|
|
3
|
+
declare function initRslibConfigGenerator(dynamicConfigRslib: RslibConfig): (extendedConfig?: Omit<RslibConfig, "lib">) => Omit<RslibConfig, "lib">;
|
|
4
|
+
export { initRslibConfigGenerator, merge };
|
package/package.json
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mainset/builder-rslib",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Builder for node packages",
|
|
5
|
+
"homepage": "https://github.com/mainset/dev-stack-fe/tree/main/packages/builder-rslib",
|
|
6
|
+
"bugs": {
|
|
7
|
+
"url": "https://github.com/mainset/dev-stack-fe/issues"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/mainset/dev-stack-fe.git"
|
|
12
|
+
},
|
|
13
|
+
"license": "CC-BY-NC-4.0",
|
|
14
|
+
"author": "yevhen uzhva",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"sideEffects": false,
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"exports": {
|
|
21
|
+
".": {
|
|
22
|
+
"types": "./dist/types/index.d.mts",
|
|
23
|
+
"import": "./dist/esm/index.mjs"
|
|
24
|
+
}
|
|
25
|
+
},
|
|
26
|
+
"dependencies": {
|
|
27
|
+
"@rsbuild/plugin-react": "^1.3.2",
|
|
28
|
+
"@rsbuild/plugin-sass": "^1.3.2",
|
|
29
|
+
"@rslib/core": "^0.10.2"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@mainset/cli": "^0.1.0",
|
|
33
|
+
"@mainset/toolkit-js": "^0.1.0",
|
|
34
|
+
"@mainset/dev-stack-fe": "^0.1.0"
|
|
35
|
+
},
|
|
36
|
+
"scripts": {
|
|
37
|
+
"build": "ms-cli source-code --exec compile",
|
|
38
|
+
"dev": "cross-env NODE_ENV=development ms-cli source-code --exec watch"
|
|
39
|
+
}
|
|
40
|
+
}
|