@prosopo/config 2.5.5 → 3.1.1
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/CHANGELOG.md +42 -0
- package/dist/cjs/dependencies.cjs +155 -0
- package/dist/cjs/index.cjs +31 -0
- package/dist/cjs/vite/TsNoCheckPlugin.cjs +18 -0
- package/dist/cjs/vite/index.cjs +24 -0
- package/dist/cjs/vite/vite-plugin-close-and-copy.cjs +46 -0
- package/dist/cjs/vite/vite-plugin-copy.cjs +42 -0
- package/dist/cjs/vite/vite-plugin-fix-absolute-imports.cjs +26 -0
- package/dist/cjs/vite/vite-plugin-remove-unused-translations.cjs +81 -0
- package/dist/cjs/vite/vite-plugin-sourcemap-exclude.cjs +17 -0
- package/dist/cjs/vite/vite.backend.config.cjs +98 -0
- package/dist/cjs/vite/vite.commonjs.config.cjs +60 -0
- package/dist/cjs/vite/vite.esm.config.cjs +54 -0
- package/dist/cjs/vite/vite.frontend.config.cjs +182 -0
- package/dist/cjs/vite/vite.test.config.cjs +59 -0
- package/dist/cjs/webpack/index.cjs +2 -0
- package/dist/cjs/webpack/webpack.config.cjs +149 -0
- package/dist/dependencies.d.ts.map +1 -1
- package/dist/dependencies.js +134 -117
- package/dist/dependencies.js.map +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +31 -6
- package/dist/index.js.map +1 -1
- package/dist/vite/NodejsPolarsDirnamePlugin.d.ts +1 -2
- package/dist/vite/NodejsPolarsDirnamePlugin.d.ts.map +1 -1
- package/dist/vite/NodejsPolarsDirnamePlugin.js +3 -3
- package/dist/vite/NodejsPolarsDirnamePlugin.js.map +1 -1
- package/dist/vite/NodejsPolarsNativeFilePlugin.d.ts +1 -2
- package/dist/vite/NodejsPolarsNativeFilePlugin.d.ts.map +1 -1
- package/dist/vite/NodejsPolarsNativeFilePlugin.js +5 -5
- package/dist/vite/NodejsPolarsNativeFilePlugin.js.map +1 -1
- package/dist/vite/TsNoCheckPlugin.js +17 -13
- package/dist/vite/index.d.ts +2 -0
- package/dist/vite/index.d.ts.map +1 -1
- package/dist/vite/index.js +24 -10
- package/dist/vite/index.js.map +1 -1
- package/dist/vite/vite-plugin-close-and-copy.d.ts.map +1 -1
- package/dist/vite/vite-plugin-close-and-copy.js +41 -38
- package/dist/vite/vite-plugin-close-and-copy.js.map +1 -1
- package/dist/vite/vite-plugin-copy.d.ts +10 -0
- package/dist/vite/vite-plugin-copy.d.ts.map +1 -0
- package/dist/vite/vite-plugin-copy.js +43 -0
- package/dist/vite/vite-plugin-copy.js.map +1 -0
- package/dist/vite/vite-plugin-fix-absolute-imports.js +25 -20
- package/dist/vite/vite-plugin-remove-unused-translations.d.ts +4 -0
- package/dist/vite/vite-plugin-remove-unused-translations.d.ts.map +1 -1
- package/dist/vite/vite-plugin-remove-unused-translations.js +79 -46
- package/dist/vite/vite-plugin-remove-unused-translations.js.map +1 -1
- package/dist/vite/vite-plugin-sourcemap-exclude.js +17 -14
- package/dist/vite/vite.backend.config.d.ts +1 -1
- package/dist/vite/vite.backend.config.d.ts.map +1 -1
- package/dist/vite/vite.backend.config.js +91 -80
- package/dist/vite/vite.backend.config.js.map +1 -1
- package/dist/vite/vite.commonjs.config.d.ts.map +1 -1
- package/dist/vite/vite.commonjs.config.js +53 -43
- package/dist/vite/vite.commonjs.config.js.map +1 -1
- package/dist/vite/vite.esm.config.d.ts +3 -0
- package/dist/vite/vite.esm.config.d.ts.map +1 -0
- package/dist/vite/vite.esm.config.js +55 -0
- package/dist/vite/vite.esm.config.js.map +1 -0
- package/dist/vite/vite.frontend.config.d.ts.map +1 -1
- package/dist/vite/vite.frontend.config.js +172 -139
- package/dist/vite/vite.frontend.config.js.map +1 -1
- package/dist/vite/vite.test.config.d.ts +1 -1
- package/dist/vite/vite.test.config.d.ts.map +1 -1
- package/dist/vite/vite.test.config.js +56 -46
- package/dist/vite/vite.test.config.js.map +1 -1
- package/dist/webpack/index.js +1 -2
- package/dist/webpack/webpack.config.js +115 -109
- package/package.json +38 -32
- package/vite.cjs.config.ts +3 -4
- package/vite.esm.config.ts +19 -0
- package/dist/projectInfo.d.ts +0 -38
- package/dist/projectInfo.d.ts.map +0 -1
- package/dist/projectInfo.js +0 -38
- package/dist/projectInfo.js.map +0 -1
- package/dist/provider/index.d.ts +0 -2
- package/dist/provider/index.d.ts.map +0 -1
- package/dist/provider/index.js +0 -2
- package/dist/provider/index.js.map +0 -1
- package/dist/provider/test.d.ts +0 -101
- package/dist/provider/test.d.ts.map +0 -1
- package/dist/provider/test.js +0 -27
- package/dist/provider/test.js.map +0 -1
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const node_module = require("node:module");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const vite = require("vite");
|
|
5
|
+
const noBundlePlugin = require("vite-plugin-no-bundle");
|
|
6
|
+
const tsconfigPaths = require("vite-tsconfig-paths");
|
|
7
|
+
const dependencies = require("../dependencies.cjs");
|
|
8
|
+
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
9
|
+
const vitePluginCopy = require("./vite-plugin-copy.cjs");
|
|
10
|
+
async function vite_esm_config(name, tsConfigPath, entry) {
|
|
11
|
+
console.info(`ViteEsmConfig: ${name}`);
|
|
12
|
+
const projectExternal = await dependencies.getExternalsFromReferences(tsConfigPath, [
|
|
13
|
+
/dev/
|
|
14
|
+
]);
|
|
15
|
+
const allExternal = [
|
|
16
|
+
...node_module.builtinModules,
|
|
17
|
+
...node_module.builtinModules.map((m) => `node:${m}`),
|
|
18
|
+
...projectExternal
|
|
19
|
+
];
|
|
20
|
+
return vite.defineConfig({
|
|
21
|
+
ssr: { external: allExternal },
|
|
22
|
+
plugins: [
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
noBundlePlugin({
|
|
25
|
+
root: "src",
|
|
26
|
+
copy: "**/*.css"
|
|
27
|
+
}),
|
|
28
|
+
vitePluginCopy({
|
|
29
|
+
srcDir: "src",
|
|
30
|
+
destDir: "dist",
|
|
31
|
+
include: ["**/*.json"]
|
|
32
|
+
}),
|
|
33
|
+
tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }),
|
|
34
|
+
vitePluginCloseAndCopy()
|
|
35
|
+
],
|
|
36
|
+
build: {
|
|
37
|
+
emptyOutDir: false,
|
|
38
|
+
ssr: true,
|
|
39
|
+
target: "node18",
|
|
40
|
+
outDir: "dist",
|
|
41
|
+
lib: {
|
|
42
|
+
name,
|
|
43
|
+
formats: ["es"],
|
|
44
|
+
entry: entry || "src/index.ts"
|
|
45
|
+
// required
|
|
46
|
+
},
|
|
47
|
+
rollupOptions: {
|
|
48
|
+
treeshake: false,
|
|
49
|
+
external: allExternal
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
module.exports = vite_esm_config;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const node_module = require("node:module");
|
|
3
|
+
const path = require("node:path");
|
|
4
|
+
const nodeResolve = require("@rollup/plugin-node-resolve");
|
|
5
|
+
const typescript = require("@rollup/plugin-typescript");
|
|
6
|
+
const pluginWasm = require("@rollup/plugin-wasm");
|
|
7
|
+
const viteReact = require("@vitejs/plugin-react");
|
|
8
|
+
const css = require("rollup-plugin-import-css");
|
|
9
|
+
const rollupPluginVisualizer = require("rollup-plugin-visualizer");
|
|
10
|
+
const vitePluginNodePolyfills = require("vite-plugin-node-polyfills");
|
|
11
|
+
const dependencies = require("../dependencies.cjs");
|
|
12
|
+
require("./index.cjs");
|
|
13
|
+
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
14
|
+
async function vite_frontend_config(packageName, bundleName, dir, entry, command, mode, copyOptions, tsConfigPaths, workspaceRoot) {
|
|
15
|
+
if (mode !== "production") {
|
|
16
|
+
mode = "development";
|
|
17
|
+
}
|
|
18
|
+
const allowedEnvironments = ["development", "staging", "production"];
|
|
19
|
+
const defaultEnvironment = process.env.NODE_ENV && allowedEnvironments.includes(process.env.NODE_ENV) ? process.env.NODE_ENV : mode;
|
|
20
|
+
console.info(`Running at ${dir} in ${mode} mode`);
|
|
21
|
+
const isProduction = mode === "production";
|
|
22
|
+
process.env.NODE_ENV = `${process.env.NODE_ENV || mode}`;
|
|
23
|
+
console.info(`NODE_ENV: ${process.env.NODE_ENV}`);
|
|
24
|
+
const define = {
|
|
25
|
+
// used to stop websockets package from breaking
|
|
26
|
+
"process.env.WS_NO_BUFFER_UTIL": JSON.stringify("true"),
|
|
27
|
+
"process.env.WS_NO_UTF_8_VALIDATE": JSON.stringify("true"),
|
|
28
|
+
"process.env.NODE_ENV": JSON.stringify(process.env.NODE_ENV),
|
|
29
|
+
"process.env.PROSOPO_DEFAULT_ENVIRONMENT": JSON.stringify(defaultEnvironment),
|
|
30
|
+
"process.env.PROSOPO_SERVER_URL": JSON.stringify(
|
|
31
|
+
process.env.PROSOPO_SERVER_URL
|
|
32
|
+
),
|
|
33
|
+
"process.env._DEV_ONLY_WATCH_EVENTS": JSON.stringify(
|
|
34
|
+
process.env._DEV_ONLY_WATCH_EVENTS
|
|
35
|
+
),
|
|
36
|
+
"process.env.PROSOPO_MONGO_EVENTS_URI": JSON.stringify(
|
|
37
|
+
process.env.PROSOPO_MONGO_EVENTS_URI
|
|
38
|
+
),
|
|
39
|
+
"process.env.PROSOPO_PACKAGE_VERSION": JSON.stringify(
|
|
40
|
+
process.env.PROSOPO_PACKAGE_VERSION
|
|
41
|
+
),
|
|
42
|
+
"process.env.PROSOPO_DOCS_URL": JSON.stringify(
|
|
43
|
+
process.env.PROSOPO_DOCS_URL
|
|
44
|
+
),
|
|
45
|
+
"process.env.PROSOPO_LOG_LEVEL": JSON.stringify(
|
|
46
|
+
process.env.PROSOPO_LOG_LEVEL
|
|
47
|
+
),
|
|
48
|
+
// only needed if bundling with a site key
|
|
49
|
+
"process.env.PROSOPO_SITE_KEY": JSON.stringify(
|
|
50
|
+
process.env.PROSOPO_SITE_KEY
|
|
51
|
+
)
|
|
52
|
+
};
|
|
53
|
+
console.info(`Env vars: ${JSON.stringify(define, null, 4)}`);
|
|
54
|
+
const { dependencies: deps, optionalPeerDependencies } = await dependencies.getDependencies(packageName, isProduction);
|
|
55
|
+
const { external, internal } = dependencies.filterDependencies(deps, [
|
|
56
|
+
"pm2",
|
|
57
|
+
"nodejs-polars",
|
|
58
|
+
"aws",
|
|
59
|
+
"webpack",
|
|
60
|
+
"vite",
|
|
61
|
+
"i18next-fs-backend"
|
|
62
|
+
]);
|
|
63
|
+
const allExternal = [
|
|
64
|
+
...node_module.builtinModules,
|
|
65
|
+
...node_module.builtinModules.map((m) => `node:${m}`),
|
|
66
|
+
...external,
|
|
67
|
+
...optionalPeerDependencies
|
|
68
|
+
];
|
|
69
|
+
console.debug(
|
|
70
|
+
`Bundling. ${JSON.stringify(internal.slice(0, 10), null, 2)}... ${internal.length} deps`
|
|
71
|
+
);
|
|
72
|
+
const proto = RegExp.prototype;
|
|
73
|
+
proto.toJSON = RegExp.prototype.toString;
|
|
74
|
+
let drop;
|
|
75
|
+
let pure = [];
|
|
76
|
+
if (isProduction) {
|
|
77
|
+
drop = ["debugger"];
|
|
78
|
+
pure = ["console.log", "console.warn", "console.info", "console.debug"];
|
|
79
|
+
}
|
|
80
|
+
const rollupExternal = allExternal;
|
|
81
|
+
console.info({ bundleName }, "Bundle name");
|
|
82
|
+
return {
|
|
83
|
+
server: {
|
|
84
|
+
host: "127.0.0.1"
|
|
85
|
+
},
|
|
86
|
+
mode: mode || "development",
|
|
87
|
+
optimizeDeps: {
|
|
88
|
+
include: ["node_modules"],
|
|
89
|
+
force: true
|
|
90
|
+
},
|
|
91
|
+
esbuild: {
|
|
92
|
+
platform: "browser",
|
|
93
|
+
target: [
|
|
94
|
+
"es2020",
|
|
95
|
+
"chrome60",
|
|
96
|
+
"edge18",
|
|
97
|
+
"firefox60",
|
|
98
|
+
"node22",
|
|
99
|
+
"safari11"
|
|
100
|
+
],
|
|
101
|
+
drop,
|
|
102
|
+
pure,
|
|
103
|
+
legalComments: "none"
|
|
104
|
+
},
|
|
105
|
+
define,
|
|
106
|
+
build: {
|
|
107
|
+
outDir: path.resolve(dir, "dist/bundle"),
|
|
108
|
+
minify: isProduction,
|
|
109
|
+
ssr: false,
|
|
110
|
+
lib: {
|
|
111
|
+
entry: path.resolve(dir, entry),
|
|
112
|
+
name: bundleName,
|
|
113
|
+
fileName: `${bundleName}.bundle.js`,
|
|
114
|
+
formats: ["es"]
|
|
115
|
+
},
|
|
116
|
+
modulePreload: { polyfill: true },
|
|
117
|
+
commonjsOptions: {
|
|
118
|
+
exclude: ["mongodb/*"],
|
|
119
|
+
transformMixedEsModules: true,
|
|
120
|
+
strictRequires: "debug"
|
|
121
|
+
},
|
|
122
|
+
rollupOptions: {
|
|
123
|
+
treeshake: {
|
|
124
|
+
annotations: false,
|
|
125
|
+
propertyReadSideEffects: false,
|
|
126
|
+
tryCatchDeoptimization: false,
|
|
127
|
+
moduleSideEffects: "no-external",
|
|
128
|
+
//true,
|
|
129
|
+
preset: "smallest",
|
|
130
|
+
unknownGlobalSideEffects: false
|
|
131
|
+
},
|
|
132
|
+
experimentalLogSideEffects: false,
|
|
133
|
+
external: rollupExternal,
|
|
134
|
+
watch: false,
|
|
135
|
+
output: {
|
|
136
|
+
dir: path.resolve(dir, "dist/bundle"),
|
|
137
|
+
entryFileNames: `${bundleName}.bundle.js`
|
|
138
|
+
},
|
|
139
|
+
plugins: [
|
|
140
|
+
vitePluginNodePolyfills.nodePolyfills({
|
|
141
|
+
include: ["crypto"]
|
|
142
|
+
}),
|
|
143
|
+
css(),
|
|
144
|
+
pluginWasm.wasm(),
|
|
145
|
+
// @ts-ignore
|
|
146
|
+
nodeResolve({
|
|
147
|
+
browser: true,
|
|
148
|
+
preferBuiltins: false,
|
|
149
|
+
rootDir: path.resolve(dir, "../../"),
|
|
150
|
+
dedupe: ["react", "react-dom"],
|
|
151
|
+
modulesOnly: true
|
|
152
|
+
}),
|
|
153
|
+
rollupPluginVisualizer.visualizer({
|
|
154
|
+
open: true,
|
|
155
|
+
template: "treemap",
|
|
156
|
+
//'list',
|
|
157
|
+
gzipSize: true,
|
|
158
|
+
brotliSize: true
|
|
159
|
+
}),
|
|
160
|
+
// I think we can use this plugin to build all packages instead of relying on the tsc step that's
|
|
161
|
+
// currently a precursor in package.json. However, it fails for the following reason:
|
|
162
|
+
// https://github.com/rollup/plugins/issues/243
|
|
163
|
+
// @ts-ignore
|
|
164
|
+
typescript({
|
|
165
|
+
tsconfig: path.resolve("./tsconfig.json"),
|
|
166
|
+
compilerOptions: { rootDir: path.resolve("./src") },
|
|
167
|
+
outDir: path.resolve(dir, "dist/bundle")
|
|
168
|
+
})
|
|
169
|
+
]
|
|
170
|
+
}
|
|
171
|
+
},
|
|
172
|
+
plugins: [
|
|
173
|
+
// Not sure if we need this plugin or not, it works without it
|
|
174
|
+
// @ts-ignore
|
|
175
|
+
viteReact(),
|
|
176
|
+
// Closes the bundler and copies the bundle to the client-bundle-example project unless we're in serve
|
|
177
|
+
// mode, in which case we don't want to close the bundler because it will close the server
|
|
178
|
+
command !== "serve" ? vitePluginCloseAndCopy(copyOptions) : void 0
|
|
179
|
+
]
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
module.exports = vite_frontend_config;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
const path = require("node:path");
|
|
3
|
+
const tsconfigPaths = require("vite-tsconfig-paths");
|
|
4
|
+
const config = require("vitest/config");
|
|
5
|
+
const vitePluginCloseAndCopy = require("./vite-plugin-close-and-copy.cjs");
|
|
6
|
+
const vitePluginSourcemapExclude = require("./vite-plugin-sourcemap-exclude.cjs");
|
|
7
|
+
function vite_test_config(tsConfigPath) {
|
|
8
|
+
const testTypeEnv = process.env.TEST_TYPE || "";
|
|
9
|
+
const testTypes = testTypeEnv.trim().split(",");
|
|
10
|
+
const testTypeGlob = `@(|${testTypes.map((t) => t ? `.${t.trim()}` : "").join("|")})`;
|
|
11
|
+
console.log(`Filtering tests by type: ${testTypeGlob}`);
|
|
12
|
+
const plugins = [
|
|
13
|
+
vitePluginSourcemapExclude({ excludeNodeModules: true }),
|
|
14
|
+
vitePluginCloseAndCopy()
|
|
15
|
+
];
|
|
16
|
+
if (tsConfigPath) {
|
|
17
|
+
plugins.push(tsconfigPaths({ projects: [path.resolve(tsConfigPath)] }));
|
|
18
|
+
}
|
|
19
|
+
return config.defineConfig({
|
|
20
|
+
build: {
|
|
21
|
+
minify: false,
|
|
22
|
+
sourcemap: false,
|
|
23
|
+
rollupOptions: {
|
|
24
|
+
maxParallelFileOps: 1,
|
|
25
|
+
cache: false,
|
|
26
|
+
output: {
|
|
27
|
+
sourcemap: false
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
test: {
|
|
32
|
+
//root: getRootDir(),
|
|
33
|
+
reporters: ["basic"],
|
|
34
|
+
include: [
|
|
35
|
+
`src/**/*${testTypeGlob}.@(test|spec).@(mts|cts|mjs|cjs|js|ts|tsx|jsx)`
|
|
36
|
+
],
|
|
37
|
+
watch: false,
|
|
38
|
+
exclude: ["**/node_modules/**", "**/dist/**"],
|
|
39
|
+
logHeapUsage: true,
|
|
40
|
+
coverage: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
include: ["packages/*/src/**"]
|
|
43
|
+
},
|
|
44
|
+
typecheck: {
|
|
45
|
+
enabled: true
|
|
46
|
+
},
|
|
47
|
+
pool: "forks",
|
|
48
|
+
// forks is slower than 'threads' but more compatible with low-level libs (e.g. bcrypt)
|
|
49
|
+
poolOptions: {
|
|
50
|
+
forks: {
|
|
51
|
+
isolate: true
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
testTimeout: 1e4
|
|
55
|
+
},
|
|
56
|
+
plugins
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
module.exports = vite_test_config;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
10
|
+
for (let key of __getOwnPropNames(from))
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
12
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
13
|
+
}
|
|
14
|
+
return to;
|
|
15
|
+
};
|
|
16
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
17
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
18
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
19
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
20
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
21
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
22
|
+
mod
|
|
23
|
+
));
|
|
24
|
+
const fs = require("node:fs");
|
|
25
|
+
const path = require("node:path");
|
|
26
|
+
const HtmlWebpackPlugin = require("html-webpack-plugin");
|
|
27
|
+
const MiniCssExtractPlugin = require("mini-css-extract-plugin");
|
|
28
|
+
const NodePolyfillPlugin = require("node-polyfill-webpack-plugin");
|
|
29
|
+
const TerserPlugin = require("terser-webpack-plugin");
|
|
30
|
+
const moduleDirs = [path.resolve("./node_modules")];
|
|
31
|
+
function resolveEntryFile() {
|
|
32
|
+
const defaultEntry = "./src/index.tsx";
|
|
33
|
+
const supportedEntries = [defaultEntry, "./src/index.ts"];
|
|
34
|
+
return supportedEntries.find((entry) => fs.existsSync(path.resolve(entry))) || defaultEntry;
|
|
35
|
+
}
|
|
36
|
+
const webpack_config = (mode) => {
|
|
37
|
+
const isProduction = mode === "production";
|
|
38
|
+
const libraryName = "react_app";
|
|
39
|
+
return {
|
|
40
|
+
resolve: {
|
|
41
|
+
extensions: [".js", ".jsx", ".ts", ".tsx", ".cjs"],
|
|
42
|
+
extensionAlias: {
|
|
43
|
+
".js": [".js", ".jsx", ".ts", ".tsx"]
|
|
44
|
+
},
|
|
45
|
+
modules: moduleDirs,
|
|
46
|
+
fullySpecified: false,
|
|
47
|
+
alias: {
|
|
48
|
+
"@polkadot/x-textdecoder": path.resolve(
|
|
49
|
+
"../../node_modules/@polkadot/util/node_modules/@polkadot/x-textdecoder"
|
|
50
|
+
),
|
|
51
|
+
"@polkadot/x-textencoder": path.resolve(
|
|
52
|
+
"../../node_modules/@polkadot/util/node_modules/@polkadot/x-textencoder"
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
},
|
|
56
|
+
externals: {
|
|
57
|
+
"node:url": "commonjs url",
|
|
58
|
+
url: "commonjs url",
|
|
59
|
+
"node:path": "commonjs path",
|
|
60
|
+
"node:fs": "commonjs fs"
|
|
61
|
+
},
|
|
62
|
+
entry: resolveEntryFile(),
|
|
63
|
+
output: {
|
|
64
|
+
filename: `${libraryName}.[name].bundle.js`,
|
|
65
|
+
path: path.resolve("./dist"),
|
|
66
|
+
publicPath: "/"
|
|
67
|
+
},
|
|
68
|
+
module: {
|
|
69
|
+
rules: [
|
|
70
|
+
// instead of using .babelrc, we can use babel-loader options
|
|
71
|
+
{
|
|
72
|
+
test: /\.(m?js|jsx|tsx|ts)$/,
|
|
73
|
+
exclude: /node_modules/,
|
|
74
|
+
use: {
|
|
75
|
+
loader: "babel-loader",
|
|
76
|
+
options: {
|
|
77
|
+
plugins: [
|
|
78
|
+
"@babel/plugin-transform-runtime",
|
|
79
|
+
"@babel/transform-class-properties",
|
|
80
|
+
"@babel/transform-object-rest-spread",
|
|
81
|
+
"@babel/plugin-transform-react-jsx",
|
|
82
|
+
[
|
|
83
|
+
"@babel/plugin-syntax-import-attributes",
|
|
84
|
+
{ deprecatedAssertSyntax: true }
|
|
85
|
+
]
|
|
86
|
+
],
|
|
87
|
+
presets: ["@babel/preset-env", "@babel/preset-typescript"]
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
include: /node_modules|src/,
|
|
93
|
+
test: /\.css$/,
|
|
94
|
+
resolve: {
|
|
95
|
+
fullySpecified: false
|
|
96
|
+
},
|
|
97
|
+
sideEffects: true,
|
|
98
|
+
use: [
|
|
99
|
+
MiniCssExtractPlugin.loader,
|
|
100
|
+
{
|
|
101
|
+
loader: require.resolve("css-loader"),
|
|
102
|
+
options: {
|
|
103
|
+
url: false
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
]
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
test: /locale\.json$/,
|
|
110
|
+
// match JSON files to optimize
|
|
111
|
+
loader: "webpack-json-access-optimizer"
|
|
112
|
+
},
|
|
113
|
+
// Fix for module
|
|
114
|
+
{
|
|
115
|
+
test: /packageInfo.js$/,
|
|
116
|
+
loader: "string-replace-loader",
|
|
117
|
+
options: {
|
|
118
|
+
search: /import\.meta && import\.meta\.url/g,
|
|
119
|
+
replace: "false"
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
plugins: [
|
|
125
|
+
new NodePolyfillPlugin(),
|
|
126
|
+
new HtmlWebpackPlugin({
|
|
127
|
+
template: "./src/index.html"
|
|
128
|
+
}),
|
|
129
|
+
new MiniCssExtractPlugin({
|
|
130
|
+
filename: "extr.[contenthash].css"
|
|
131
|
+
})
|
|
132
|
+
],
|
|
133
|
+
optimization: {
|
|
134
|
+
noEmitOnErrors: true,
|
|
135
|
+
minimize: isProduction,
|
|
136
|
+
minimizer: isProduction ? [
|
|
137
|
+
new TerserPlugin({
|
|
138
|
+
terserOptions: {
|
|
139
|
+
compress: {
|
|
140
|
+
drop_console: true
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
})
|
|
144
|
+
] : [],
|
|
145
|
+
usedExports: true
|
|
146
|
+
}
|
|
147
|
+
};
|
|
148
|
+
};
|
|
149
|
+
module.exports = webpack_config;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AAuEA,wBAAgB,YAAY,CAC3B,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,EAC7B,aAAa,GAAE,MAAM,EAAO,EAC5B,sBAAsB,UAAO,GAC3B,MAAM,EAAE,CA4CV;AAOD,wBAAsB,0BAA0B,CAC/C,YAAY,EAAE,MAAM,EACpB,cAAc,GAAE,MAAM,EAAO,GAC3B,OAAO,CAAC,MAAM,EAAE,CAAC,CAmCnB;AAOD,wBAAsB,eAAe,CACpC,WAAW,CAAC,EAAE,MAAM,EACpB,UAAU,CAAC,EAAE,OAAO,GAClB,OAAO,CAAC;IAAE,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,wBAAwB,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAwCzE;AAOD,wBAAgB,kBAAkB,CACjC,IAAI,EAAE,MAAM,EAAE,EACd,OAAO,EAAE,MAAM,EAAE,GACf;IAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAe5C"}
|