aboutsummaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
Diffstat (limited to 'config')
-rw-r--r--config/tsconfig.json3
-rw-r--r--config/webpack.config.js18
-rw-r--r--config/webpack/loader/arrange-shared-module-loader.js37
-rw-r--r--config/webpack/utils/get-injection-code.js11
4 files changed, 47 insertions, 22 deletions
diff --git a/config/tsconfig.json b/config/tsconfig.json
index 120bfcb..8615fcb 100644
--- a/config/tsconfig.json
+++ b/config/tsconfig.json
@@ -1,4 +1,7 @@
{
+ "files": [
+ "../src/types/html2pdf.js.d.ts"
+ ],
"compilerOptions": {
"outDir": "dist",
"sourceMap": true,
diff --git a/config/webpack.config.js b/config/webpack.config.js
index 15cae74..629a373 100644
--- a/config/webpack.config.js
+++ b/config/webpack.config.js
@@ -1,5 +1,6 @@
const path = require("path");
const fs = require("fs");
+const webpack = require("webpack");
const { merge } = require("webpack-merge");
const CopyPlugin = require("copy-webpack-plugin");
@@ -75,6 +76,7 @@ for (const sharedModule of sharedModules) {
const commonOptions = {
mode: "production",
+ target: "web",
resolve: {
extensions: [".ts", ".js"],
alias: {
@@ -93,11 +95,17 @@ const commonOptions = {
]
},
optimization: {
- minimize: process.env.NODE_ENV === "production"
+ minimize: process.env.NODE_ENV === "production",
+ runtimeChunk: false
},
output: {
iife: true
- }
+ },
+ plugins: [
+ new webpack.optimize.LimitChunkCountPlugin({
+ maxChunks: 1
+ })
+ ]
};
const sharedModuleOptions = {
@@ -106,7 +114,7 @@ const sharedModuleOptions = {
module: {
rules: [
{
- test: /\.(j|t)s$/,
+ test: /banglar-bhumi-utils\/src\/.*.(^.?|\.[^d]|[^.]d|[^.][^d])\.(t|j)s$/,
loader: path.resolve(CONFIG_DIR, "webpack/loader/count-imports-loader.js"),
options: {
sharedModulesImportedCount
@@ -114,7 +122,7 @@ const sharedModuleOptions = {
enforce: "post"
}
]
- },
+ }
};
const uninjectedScriptConfiguration = merge(
@@ -170,7 +178,7 @@ const sharedModulesConfiguration = merge(
module: {
rules: [
{
- test: /\.(j|t)s$/,
+ test: /banglar-bhumi-utils\/src\/.*.(^.?|\.[^d]|[^.]d|[^.][^d])\.(t|j)s$/,
loader: path.resolve(CONFIG_DIR, "webpack/loader/arrange-shared-module-loader.js"),
options: {
sortedSharedModules
diff --git a/config/webpack/loader/arrange-shared-module-loader.js b/config/webpack/loader/arrange-shared-module-loader.js
index 9e21b23..1669a64 100644
--- a/config/webpack/loader/arrange-shared-module-loader.js
+++ b/config/webpack/loader/arrange-shared-module-loader.js
@@ -5,22 +5,39 @@ const { ImportManager } = require("import-manager");
const sharedModules = webpackRequire("utils/shared-modules.js");
module.exports = function(source) {
- const { sortedSharedModules } = this.getOptions();
- const manager = new ImportManager(source);
+ const currentSharedModuleName = path.basename(this.resourcePath.substring(0, this.resourcePath.length - 3));
- for (const unit of manager.imports.es6.units) {
- const moduleIndex = sharedModules.indexOf(unit.module.name);
+ if (sharedModules.includes(currentSharedModuleName)) {
+ const { sortedSharedModules } = this.getOptions();
+ const manager = new ImportManager(source);
+ const modulesToBeIncluded = [];
- if (moduleIndex >= 0) {
- const currentSharedModuleName = sharedModules[moduleIndex];
+ for (const unit of manager.imports.es6.units) {
+ const moduleIndex = sharedModules.indexOf(unit.module.name);
- if (!sortedSharedModules.includes(currentSharedModuleName)) {
- sortedSharedModules.push(currentSharedModuleName);
+ if (moduleIndex >= 0) {
+ const currentSharedModuleName = sharedModules[moduleIndex];
+
+ if (!(sortedSharedModules.includes(currentSharedModuleName) || modulesToBeIncluded.includes(currentSharedModuleName))) {
+ modulesToBeIncluded.push(currentSharedModuleName);
+ }
}
}
- }
- sortedSharedModules.push(path.basename(this.resourcePath.substring(0, this.resourcePath.length - 3)));
+ const currentModuleIndex = sortedSharedModules.indexOf(currentSharedModuleName);
+
+ if (currentModuleIndex >= 0) {
+ for (const sharedModule of modulesToBeIncluded) {
+ sortedSharedModules.splice(currentModuleIndex, 0, sharedModule);
+ }
+ } else {
+ for (const sharedModule of modulesToBeIncluded) {
+ sortedSharedModules.push(sharedModule);
+ }
+
+ sortedSharedModules.push(currentSharedModuleName);
+ }
+ }
return source;
};
diff --git a/config/webpack/utils/get-injection-code.js b/config/webpack/utils/get-injection-code.js
index 6333a6a..ec969c1 100644
--- a/config/webpack/utils/get-injection-code.js
+++ b/config/webpack/utils/get-injection-code.js
@@ -1,11 +1,8 @@
module.exports.getInjectionCode = (code, front) => {
- const escapeSequences = ["b", "f", "n", "r", "t", "v"];
- let finalCode = code.replaceAll("`","\\`");
-
- for (const escapeSequence of escapeSequences) {
- finalCode = finalCode
- .replaceAll("\\" + escapeSequence, "\\\\" + escapeSequence)
- }
+ let finalCode = code
+ .replaceAll("\\", "\\\\")
+ .replaceAll("`","\\`")
+ .replaceAll("${", "\\${");
const concatenationCode = front
? "t.innerHTML=i+t.innerHTML"