@intlayer/webpack 6.1.6 → 7.0.0-canary.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/dist/cjs/_virtual/rolldown_runtime.cjs +25 -0
- package/dist/cjs/getEntries.cjs +20 -49
- package/dist/cjs/getEntries.cjs.map +1 -1
- package/dist/cjs/index.cjs +6 -34
- package/dist/cjs/utils.cjs +22 -49
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/cjs/webpack-plugin.cjs +27 -50
- package/dist/cjs/webpack-plugin.cjs.map +1 -1
- package/dist/cjs/webpack.config.cjs +90 -164
- package/dist/cjs/webpack.config.cjs.map +1 -1
- package/dist/esm/_virtual/rolldown_runtime.mjs +8 -0
- package/dist/esm/getEntries.mjs +17 -14
- package/dist/esm/getEntries.mjs.map +1 -1
- package/dist/esm/index.mjs +3 -7
- package/dist/esm/utils.mjs +15 -11
- package/dist/esm/utils.mjs.map +1 -1
- package/dist/esm/webpack-plugin.mjs +23 -25
- package/dist/esm/webpack-plugin.mjs.map +1 -1
- package/dist/esm/webpack.config.mjs +82 -137
- package/dist/esm/webpack.config.mjs.map +1 -1
- package/dist/types/getEntries.d.ts +7 -2
- package/dist/types/getEntries.d.ts.map +1 -1
- package/dist/types/index.d.ts +3 -3
- package/dist/types/utils.d.ts +5 -2
- package/dist/types/utils.d.ts.map +1 -1
- package/dist/types/webpack-plugin.d.ts +11 -5
- package/dist/types/webpack-plugin.d.ts.map +1 -1
- package/dist/types/webpack.config.d.ts +9 -5
- package/dist/types/webpack.config.d.ts.map +1 -1
- package/package.json +40 -47
- package/LICENSE +0 -202
- package/dist/cjs/index.cjs.map +0 -1
- package/dist/esm/index.mjs.map +0 -1
- package/dist/types/index.d.ts.map +0 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, { get: (a, b) => (typeof require !== "undefined" ? require : a)[b] }) : x)(function(x) {
|
|
3
|
+
if (typeof require !== "undefined") return require.apply(this, arguments);
|
|
4
|
+
throw Error("Calling `require` for \"" + x + "\" in an environment that doesn't expose the `require` function.");
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
//#endregion
|
|
8
|
+
export { __require };
|
package/dist/esm/getEntries.mjs
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config";
|
|
2
|
-
import fg from "fast-glob";
|
|
3
1
|
import { getFileHash } from "./utils.mjs";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
import fg from "fast-glob";
|
|
3
|
+
|
|
4
|
+
//#region src/getEntries.ts
|
|
5
|
+
const getEntries = (configuration) => {
|
|
6
|
+
const { content } = configuration;
|
|
7
|
+
const { watchedFilesPatternWithPath } = content;
|
|
8
|
+
return fg.sync(watchedFilesPatternWithPath).reduce((obj, el) => {
|
|
9
|
+
const hash = getFileHash(el);
|
|
10
|
+
obj[`intlayer-content/${hash}`] = {
|
|
11
|
+
import: el,
|
|
12
|
+
dependOn: void 0
|
|
13
|
+
};
|
|
14
|
+
return obj;
|
|
15
|
+
}, {});
|
|
16
16
|
};
|
|
17
|
+
|
|
18
|
+
//#endregion
|
|
19
|
+
export { getEntries };
|
|
17
20
|
//# sourceMappingURL=getEntries.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/getEntries.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getEntries.mjs","names":[],"sources":["../../src/getEntries.ts"],"sourcesContent":["import type { IntlayerConfig } from '@intlayer/types';\nimport fg from 'fast-glob';\nimport type { EntryObject } from 'webpack';\nimport { getFileHash } from './utils';\n\nexport const getEntries = (configuration: IntlayerConfig) => {\n const { content } = configuration;\n const { watchedFilesPatternWithPath } = content;\n\n const entries = fg.sync(watchedFilesPatternWithPath).reduce((obj, el) => {\n const hash = getFileHash(el);\n\n obj[`intlayer-content/${hash}`] = {\n import: el,\n dependOn: undefined,\n };\n\n return obj;\n }, {} as EntryObject);\n\n return entries;\n};\n"],"mappings":";;;;AAKA,MAAa,cAAc,kBAAkC;CAC3D,MAAM,EAAE,YAAY;CACpB,MAAM,EAAE,gCAAgC;AAaxC,QAXgB,GAAG,KAAK,4BAA4B,CAAC,QAAQ,KAAK,OAAO;EACvE,MAAM,OAAO,YAAY,GAAG;AAE5B,MAAI,oBAAoB,UAAU;GAChC,QAAQ;GACR,UAAU;GACX;AAED,SAAO;IACN,EAAE,CAAgB"}
|
package/dist/esm/index.mjs
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
1
|
import { IntlayerPlugin } from "./webpack-plugin.mjs";
|
|
2
|
-
import { devServerConfig,
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
devServerConfig,
|
|
6
|
-
webpackConfig
|
|
7
|
-
};
|
|
8
|
-
//# sourceMappingURL=index.mjs.map
|
|
2
|
+
import { devServerConfig, getWebpackConfig } from "./webpack.config.mjs";
|
|
3
|
+
|
|
4
|
+
export { IntlayerPlugin, devServerConfig, getWebpackConfig };
|
package/dist/esm/utils.mjs
CHANGED
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import { __require } from "./_virtual/rolldown_runtime.mjs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
1
4
|
import { isESModule } from "@intlayer/config";
|
|
2
5
|
import crypto from "crypto-js";
|
|
3
|
-
|
|
4
|
-
|
|
6
|
+
|
|
7
|
+
//#region src/utils.ts
|
|
8
|
+
/**
|
|
9
|
+
* Set the __dirname global variable to make the config work in both ESM and CJS environments
|
|
10
|
+
*/
|
|
5
11
|
const defineDirname = () => {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
12
|
+
const filename = isESModule ? fileURLToPath(import.meta.url) : __require("node:url").pathToFileURL(__filename).toString();
|
|
13
|
+
globalThis.__filename = globalThis.__filename ?? filename;
|
|
14
|
+
globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);
|
|
9
15
|
};
|
|
10
16
|
const getFileHash = (filePath) => {
|
|
11
|
-
|
|
12
|
-
return hash.toString(crypto.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
defineDirname,
|
|
16
|
-
getFileHash
|
|
17
|
+
return crypto.SHA3(filePath).toString(crypto.enc.Base64).replace(/[^A-Z\d]/gi, "").substring(0, 20);
|
|
17
18
|
};
|
|
19
|
+
|
|
20
|
+
//#endregion
|
|
21
|
+
export { defineDirname, getFileHash };
|
|
18
22
|
//# sourceMappingURL=utils.mjs.map
|
package/dist/esm/utils.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/utils.ts"],"sourcesContent":["import
|
|
1
|
+
{"version":3,"file":"utils.mjs","names":[],"sources":["../../src/utils.ts"],"sourcesContent":["import path from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { isESModule } from '@intlayer/config';\nimport crypto from 'crypto-js';\n\n/**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\nexport const defineDirname = () => {\n const filename = isESModule\n ? fileURLToPath(import.meta.url)\n : require('node:url').pathToFileURL(__filename).toString();\n\n globalThis.__filename = globalThis.__filename ?? filename;\n globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);\n};\n\nexport const getFileHash = (filePath: string) => {\n const hash = crypto.SHA3(filePath);\n\n return hash\n .toString(crypto.enc.Base64)\n .replace(/[^A-Z\\d]/gi, '')\n .substring(0, 20);\n};\n"],"mappings":";;;;;;;;;;AAQA,MAAa,sBAAsB;CACjC,MAAM,WAAW,aACb,cAAc,OAAO,KAAK,IAAI,aACtB,WAAW,CAAC,cAAc,WAAW,CAAC,UAAU;AAE5D,YAAW,aAAa,WAAW,cAAc;AACjD,YAAW,YAAY,WAAW,aAAa,KAAK,QAAQ,WAAW;;AAGzE,MAAa,eAAe,aAAqB;AAG/C,QAFa,OAAO,KAAK,SAAS,CAG/B,SAAS,OAAO,IAAI,OAAO,CAC3B,QAAQ,cAAc,GAAG,CACzB,UAAU,GAAG,GAAG"}
|
|
@@ -1,28 +1,26 @@
|
|
|
1
|
+
import { logger } from "@intlayer/config";
|
|
1
2
|
import { prepareIntlayer, watch } from "@intlayer/chokidar";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
}
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export {
|
|
26
|
-
IntlayerPlugin
|
|
3
|
+
|
|
4
|
+
//#region src/webpack-plugin.ts
|
|
5
|
+
var IntlayerPlugin = class {
|
|
6
|
+
isWatching = false;
|
|
7
|
+
configuration;
|
|
8
|
+
constructor(configuration) {
|
|
9
|
+
this.configuration = configuration;
|
|
10
|
+
}
|
|
11
|
+
async apply(compiler) {
|
|
12
|
+
if (this.configuration.content.watch) watch({ configuration: this.configuration });
|
|
13
|
+
compiler.hooks.beforeCompile.tapPromise("IntlayerPlugin", async () => {
|
|
14
|
+
if (!this.isWatching) try {
|
|
15
|
+
await prepareIntlayer(this.configuration);
|
|
16
|
+
this.isWatching = true;
|
|
17
|
+
} catch (error) {
|
|
18
|
+
logger(`Error in IntlayerPlugin: ${error}`, { level: "error" });
|
|
19
|
+
}
|
|
20
|
+
});
|
|
21
|
+
}
|
|
27
22
|
};
|
|
23
|
+
|
|
24
|
+
//#endregion
|
|
25
|
+
export { IntlayerPlugin };
|
|
28
26
|
//# sourceMappingURL=webpack-plugin.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport {
|
|
1
|
+
{"version":3,"file":"webpack-plugin.mjs","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":["import { prepareIntlayer, watch } from '@intlayer/chokidar';\nimport { logger } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\nimport type { Compiler } from 'webpack';\n\n// Watch mode or on time build\nexport class IntlayerPlugin {\n private isWatching = false; // Flag to ensure we only start the watcher after the first build\n private configuration;\n\n constructor(configuration: IntlayerConfig) {\n this.configuration = configuration;\n }\n\n async apply(compiler: Compiler): Promise<void> {\n if (this.configuration.content.watch) {\n // Start watching (assuming watch is also async)\n watch({ configuration: this.configuration });\n }\n\n compiler.hooks.beforeCompile.tapPromise('IntlayerPlugin', async () => {\n if (!this.isWatching) {\n try {\n await prepareIntlayer(this.configuration);\n this.isWatching = true;\n } catch (error) {\n logger(`Error in IntlayerPlugin: ${error}`, {\n level: 'error',\n });\n }\n }\n });\n }\n}\n"],"mappings":";;;;AAMA,IAAa,iBAAb,MAA4B;CAC1B,AAAQ,aAAa;CACrB,AAAQ;CAER,YAAY,eAA+B;AACzC,OAAK,gBAAgB;;CAGvB,MAAM,MAAM,UAAmC;AAC7C,MAAI,KAAK,cAAc,QAAQ,MAE7B,OAAM,EAAE,eAAe,KAAK,eAAe,CAAC;AAG9C,WAAS,MAAM,cAAc,WAAW,kBAAkB,YAAY;AACpE,OAAI,CAAC,KAAK,WACR,KAAI;AACF,UAAM,gBAAgB,KAAK,cAAc;AACzC,SAAK,aAAa;YACX,OAAO;AACd,WAAO,4BAA4B,SAAS,EAC1C,OAAO,SACR,CAAC;;IAGN"}
|
|
@@ -1,143 +1,88 @@
|
|
|
1
|
-
import { getConfiguration } from "@intlayer/config";
|
|
2
|
-
import { join } from "path";
|
|
3
|
-
import { getEntries } from "./getEntries.mjs";
|
|
4
1
|
import { defineDirname } from "./utils.mjs";
|
|
2
|
+
import { getEntries } from "./getEntries.mjs";
|
|
5
3
|
import { IntlayerPlugin } from "./webpack-plugin.mjs";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { getConfiguration } from "@intlayer/config";
|
|
6
|
+
|
|
7
|
+
//#region src/webpack.config.ts
|
|
9
8
|
const devServerConfig = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
host: "localhost",
|
|
21
|
-
port: 8080,
|
|
22
|
-
watchFiles: "./src/",
|
|
23
|
-
// watchedFilesPatternWithPath,
|
|
24
|
-
devMiddleware: {
|
|
25
|
-
// Enable write to disk to reuse the output
|
|
26
|
-
writeToDisk: true
|
|
27
|
-
},
|
|
28
|
-
// Content base
|
|
29
|
-
static: {}
|
|
30
|
-
};
|
|
31
|
-
const webpackConfig = {
|
|
32
|
-
// Define the environment mode (development or production)
|
|
33
|
-
mode: "production",
|
|
34
|
-
// or 'production'
|
|
35
|
-
// Entry point of the application
|
|
36
|
-
target: "node",
|
|
37
|
-
// Specifies the target environment
|
|
38
|
-
entry: getEntries,
|
|
39
|
-
output: {
|
|
40
|
-
clean: true,
|
|
41
|
-
// Clean the output directory before emit
|
|
42
|
-
library: "IntlLayerContent",
|
|
43
|
-
libraryTarget: "umd",
|
|
44
|
-
filename: `[name].bundle.js`
|
|
45
|
-
},
|
|
46
|
-
cache: false,
|
|
47
|
-
devtool: "source-map",
|
|
48
|
-
// stats: {
|
|
49
|
-
// preset: 'errors-only',
|
|
50
|
-
// warnings: false,
|
|
51
|
-
// },
|
|
52
|
-
ignoreWarnings: [/./],
|
|
53
|
-
resolve: {
|
|
54
|
-
// Resolve TypeScript, JavaScript and JSON files
|
|
55
|
-
extensions: [".ts", ".js", ".json", ".wasm", ".ts", ".tsx", ".mjs", ".cjs"],
|
|
56
|
-
modules: [
|
|
57
|
-
// To find the loader module
|
|
58
|
-
join(globalThis.__dirname, "..", "node_modules"),
|
|
59
|
-
// In the project node_modules
|
|
60
|
-
join(process.cwd(), "node_modules"),
|
|
61
|
-
// In the project node_modules
|
|
62
|
-
join(process.cwd(), "node_modules", "intlayer-cli", "node_modules"),
|
|
63
|
-
// Or via another project by importing intlayer
|
|
64
|
-
join(
|
|
65
|
-
process.cwd(),
|
|
66
|
-
"node_modules",
|
|
67
|
-
"intlayer-cli",
|
|
68
|
-
"node_modules",
|
|
69
|
-
"@intlayer/webpack",
|
|
70
|
-
"node_modules"
|
|
71
|
-
)
|
|
72
|
-
// Or via another project by importing intlayer
|
|
73
|
-
]
|
|
74
|
-
},
|
|
75
|
-
resolveLoader: {
|
|
76
|
-
// Configure how Webpack finds `loader` modules.
|
|
77
|
-
modules: [
|
|
78
|
-
// To find the loader module
|
|
79
|
-
join(process.cwd(), "node_modules"),
|
|
80
|
-
// In the project node_modules
|
|
81
|
-
join(process.cwd(), "node_modules", "@intlayer/webpack", "node_modules"),
|
|
82
|
-
// Or via another project by importing @intlayer/webpack
|
|
83
|
-
join(
|
|
84
|
-
process.cwd(),
|
|
85
|
-
"node_modules",
|
|
86
|
-
"intlayer-cli",
|
|
87
|
-
"node_modules",
|
|
88
|
-
"@intlayer/webpack",
|
|
89
|
-
"node_modules"
|
|
90
|
-
)
|
|
91
|
-
// Or via another project by importing intlayer
|
|
92
|
-
]
|
|
93
|
-
},
|
|
94
|
-
module: {
|
|
95
|
-
rules: [
|
|
96
|
-
{
|
|
97
|
-
// Rule for .content.ts files
|
|
98
|
-
test: new RegExp(`(${fileExtensions.join("|")})$`),
|
|
99
|
-
use: [
|
|
100
|
-
{
|
|
101
|
-
// Transpile with esbuild-loader
|
|
102
|
-
loader: "esbuild-loader",
|
|
103
|
-
options: {
|
|
104
|
-
// JavaScript version to compile to
|
|
105
|
-
target: "es2015"
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
// {
|
|
109
|
-
// // Custom loader to process the transpiled code
|
|
110
|
-
// loader: resolve('./intlayer-loader'),
|
|
111
|
-
// },
|
|
112
|
-
]
|
|
113
|
-
},
|
|
114
|
-
{
|
|
115
|
-
test: /\.node$/,
|
|
116
|
-
loader: "node-loader"
|
|
117
|
-
},
|
|
118
|
-
// Use esbuild to compile JavaScript & TypeScript
|
|
119
|
-
{
|
|
120
|
-
// Match `.js`, `.jsx`, `.ts` or `.tsx` files
|
|
121
|
-
test: /\.(jsx|js|ts|tsx|mjs|cjs)?$/,
|
|
122
|
-
loader: "esbuild-loader",
|
|
123
|
-
options: {
|
|
124
|
-
// JavaScript version to compile to
|
|
125
|
-
target: "es2015"
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
// JSON files are supported natively by Webpack 5, no specific loader required
|
|
129
|
-
]
|
|
130
|
-
},
|
|
131
|
-
devServer: devServerConfig,
|
|
132
|
-
plugins: [
|
|
133
|
-
new IntlayerPlugin()
|
|
134
|
-
// new HotModuleReplacementPlugin()
|
|
135
|
-
]
|
|
9
|
+
hot: true,
|
|
10
|
+
open: false,
|
|
11
|
+
liveReload: false,
|
|
12
|
+
compress: true,
|
|
13
|
+
historyApiFallback: false,
|
|
14
|
+
host: "localhost",
|
|
15
|
+
port: 8080,
|
|
16
|
+
watchFiles: "./src/",
|
|
17
|
+
devMiddleware: { writeToDisk: true },
|
|
18
|
+
static: {}
|
|
136
19
|
};
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
20
|
+
const getWebpackConfig = (configuration = getConfiguration()) => {
|
|
21
|
+
const { fileExtensions } = configuration.content;
|
|
22
|
+
/**
|
|
23
|
+
* Set the __dirname global variable to make the config work in both ESM and CJS environments
|
|
24
|
+
*/
|
|
25
|
+
defineDirname();
|
|
26
|
+
return {
|
|
27
|
+
mode: "production",
|
|
28
|
+
target: "node",
|
|
29
|
+
entry: getEntries(configuration),
|
|
30
|
+
output: {
|
|
31
|
+
clean: true,
|
|
32
|
+
library: "IntlLayerContent",
|
|
33
|
+
libraryTarget: "umd",
|
|
34
|
+
filename: `[name].bundle.js`
|
|
35
|
+
},
|
|
36
|
+
cache: false,
|
|
37
|
+
devtool: "source-map",
|
|
38
|
+
ignoreWarnings: [/./],
|
|
39
|
+
resolve: {
|
|
40
|
+
extensions: [
|
|
41
|
+
".ts",
|
|
42
|
+
".js",
|
|
43
|
+
".json",
|
|
44
|
+
".wasm",
|
|
45
|
+
".ts",
|
|
46
|
+
".tsx",
|
|
47
|
+
".mjs",
|
|
48
|
+
".cjs"
|
|
49
|
+
],
|
|
50
|
+
modules: [
|
|
51
|
+
join(globalThis.__dirname, "..", "node_modules"),
|
|
52
|
+
join(process.cwd(), "node_modules"),
|
|
53
|
+
join(process.cwd(), "node_modules", "intlayer-cli", "node_modules"),
|
|
54
|
+
join(process.cwd(), "node_modules", "intlayer-cli", "node_modules", "@intlayer/webpack", "node_modules")
|
|
55
|
+
]
|
|
56
|
+
},
|
|
57
|
+
resolveLoader: { modules: [
|
|
58
|
+
join(process.cwd(), "node_modules"),
|
|
59
|
+
join(process.cwd(), "node_modules", "@intlayer/webpack", "node_modules"),
|
|
60
|
+
join(process.cwd(), "node_modules", "intlayer-cli", "node_modules", "@intlayer/webpack", "node_modules")
|
|
61
|
+
] },
|
|
62
|
+
module: { rules: [
|
|
63
|
+
{
|
|
64
|
+
test: /* @__PURE__ */ new RegExp(`(${fileExtensions.join("|")})$`),
|
|
65
|
+
use: [{
|
|
66
|
+
loader: "esbuild-loader",
|
|
67
|
+
options: { target: "es2015" }
|
|
68
|
+
}]
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
test: /\.node$/,
|
|
72
|
+
loader: "node-loader"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
test: /\.(jsx|js|ts|tsx|mjs|cjs)?$/,
|
|
76
|
+
loader: "esbuild-loader",
|
|
77
|
+
options: { target: "es2015" }
|
|
78
|
+
}
|
|
79
|
+
] },
|
|
80
|
+
devServer: devServerConfig,
|
|
81
|
+
plugins: [new IntlayerPlugin(configuration)]
|
|
82
|
+
};
|
|
142
83
|
};
|
|
84
|
+
var webpack_config_default = getWebpackConfig;
|
|
85
|
+
|
|
86
|
+
//#endregion
|
|
87
|
+
export { webpack_config_default as default, devServerConfig, getWebpackConfig };
|
|
143
88
|
//# sourceMappingURL=webpack.config.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/webpack.config.ts"],"sourcesContent":["import { getConfiguration } from '@intlayer/config';\nimport {
|
|
1
|
+
{"version":3,"file":"webpack.config.mjs","names":["devServerConfig: DevServerConfiguration"],"sources":["../../src/webpack.config.ts"],"sourcesContent":["import { join } from 'node:path';\nimport { getConfiguration } from '@intlayer/config';\nimport type { IntlayerConfig } from '@intlayer/types';\n// @ts-ignore - Export exists\nimport type { Configuration as WebPackConfiguration } from 'webpack';\nimport type { Configuration as DevServerConfiguration } from 'webpack-dev-server';\nimport { getEntries } from './getEntries';\nimport { defineDirname } from './utils';\nimport { IntlayerPlugin } from './webpack-plugin';\n\n// For web interface\nexport const devServerConfig: DevServerConfiguration = {\n // Enable hot module replacement\n hot: true,\n // Open the browser\n open: false,\n liveReload: false,\n\n // Enable compression\n compress: true,\n\n // History API fallback\n historyApiFallback: false,\n\n // Host and port\n host: 'localhost',\n port: 8080,\n\n watchFiles: './src/', // watchedFilesPatternWithPath,\n\n devMiddleware: {\n // Enable write to disk to reuse the output\n writeToDisk: true,\n },\n\n // Content base\n static: {},\n};\n\nexport const getWebpackConfig = (\n configuration: IntlayerConfig = getConfiguration()\n): WebPackConfiguration => {\n const { fileExtensions } = configuration.content;\n\n /**\n * Set the __dirname global variable to make the config work in both ESM and CJS environments\n */\n defineDirname();\n\n const entries = getEntries(configuration);\n\n const webpackConfig: WebPackConfiguration = {\n // Define the environment mode (development or production)\n mode: 'production', // or 'production'\n // Entry point of the application\n target: 'node', // Specifies the target environment\n\n entry: entries,\n output: {\n clean: true, // Clean the output directory before emit\n library: 'IntlLayerContent',\n libraryTarget: 'umd',\n filename: `[name].bundle.js`,\n },\n\n cache: false,\n\n devtool: 'source-map',\n\n // stats: {\n // preset: 'errors-only',\n // warnings: false,\n // },\n ignoreWarnings: [/./],\n resolve: {\n // Resolve TypeScript, JavaScript and JSON files\n extensions: [\n '.ts',\n '.js',\n '.json',\n '.wasm',\n '.ts',\n '.tsx',\n '.mjs',\n '.cjs',\n ],\n modules: [\n // To find the loader module\n join(globalThis.__dirname, '..', 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(process.cwd(), 'node_modules', 'intlayer-cli', 'node_modules'), // Or via another project by importing intlayer\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n resolveLoader: {\n // Configure how Webpack finds `loader` modules.\n modules: [\n // To find the loader module\n join(process.cwd(), 'node_modules'), // In the project node_modules\n join(\n process.cwd(),\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing @intlayer/webpack\n join(\n process.cwd(),\n 'node_modules',\n 'intlayer-cli',\n 'node_modules',\n '@intlayer/webpack',\n 'node_modules'\n ), // Or via another project by importing intlayer\n ],\n },\n\n module: {\n rules: [\n {\n // Rule for .content.ts files\n test: new RegExp(`(${fileExtensions.join('|')})$`),\n use: [\n {\n // Transpile with esbuild-loader\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n // {\n // // Custom loader to process the transpiled code\n // loader: resolve('./intlayer-loader'),\n // },\n ],\n },\n {\n test: /\\.node$/,\n loader: 'node-loader',\n },\n // Use esbuild to compile JavaScript & TypeScript\n {\n // Match `.js`, `.jsx`, `.ts` or `.tsx` files\n test: /\\.(jsx|js|ts|tsx|mjs|cjs)?$/,\n loader: 'esbuild-loader',\n options: {\n // JavaScript version to compile to\n target: 'es2015',\n },\n },\n\n // JSON files are supported natively by Webpack 5, no specific loader required\n ],\n },\n devServer: devServerConfig,\n\n plugins: [new IntlayerPlugin(configuration)],\n };\n\n return webpackConfig;\n};\n\nexport default getWebpackConfig;\n"],"mappings":";;;;;;;AAWA,MAAaA,kBAA0C;CAErD,KAAK;CAEL,MAAM;CACN,YAAY;CAGZ,UAAU;CAGV,oBAAoB;CAGpB,MAAM;CACN,MAAM;CAEN,YAAY;CAEZ,eAAe,EAEb,aAAa,MACd;CAGD,QAAQ,EAAE;CACX;AAED,MAAa,oBACX,gBAAgC,kBAAkB,KACzB;CACzB,MAAM,EAAE,mBAAmB,cAAc;;;;AAKzC,gBAAe;AAwHf,QApH4C;EAE1C,MAAM;EAEN,QAAQ;EAER,OARc,WAAW,cAAc;EASvC,QAAQ;GACN,OAAO;GACP,SAAS;GACT,eAAe;GACf,UAAU;GACX;EAED,OAAO;EAEP,SAAS;EAMT,gBAAgB,CAAC,IAAI;EACrB,SAAS;GAEP,YAAY;IACV;IACA;IACA;IACA;IACA;IACA;IACA;IACA;IACD;GACD,SAAS;IAEP,KAAK,WAAW,WAAW,MAAM,eAAe;IAChD,KAAK,QAAQ,KAAK,EAAE,eAAe;IACnC,KAAK,QAAQ,KAAK,EAAE,gBAAgB,gBAAgB,eAAe;IACnE,KACE,QAAQ,KAAK,EACb,gBACA,gBACA,gBACA,qBACA,eACD;IACF;GACF;EAED,eAAe,EAEb,SAAS;GAEP,KAAK,QAAQ,KAAK,EAAE,eAAe;GACnC,KACE,QAAQ,KAAK,EACb,gBACA,qBACA,eACD;GACD,KACE,QAAQ,KAAK,EACb,gBACA,gBACA,gBACA,qBACA,eACD;GACF,EACF;EAED,QAAQ,EACN,OAAO;GACL;IAEE,sBAAM,IAAI,OAAO,IAAI,eAAe,KAAK,IAAI,CAAC,IAAI;IAClD,KAAK,CACH;KAEE,QAAQ;KACR,SAAS,EAEP,QAAQ,UACT;KACF,CAKF;IACF;GACD;IACE,MAAM;IACN,QAAQ;IACT;GAED;IAEE,MAAM;IACN,QAAQ;IACR,SAAS,EAEP,QAAQ,UACT;IACF;GAGF,EACF;EACD,WAAW;EAEX,SAAS,CAAC,IAAI,eAAe,cAAc,CAAC;EAC7C;;AAKH,6BAAe"}
|
|
@@ -1,3 +1,8 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
import { EntryObject } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/getEntries.d.ts
|
|
5
|
+
declare const getEntries: (configuration: IntlayerConfig) => EntryObject;
|
|
6
|
+
//#endregion
|
|
7
|
+
export { getEntries };
|
|
3
8
|
//# sourceMappingURL=getEntries.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getEntries.d.ts","
|
|
1
|
+
{"version":3,"file":"getEntries.d.ts","names":[],"sources":["../../src/getEntries.ts"],"sourcesContent":[],"mappings":";;;;cAKa,4BAA6B,mBAAc"}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import getWebpackConfig, { devServerConfig } from "./webpack.config.js";
|
|
2
|
+
import { IntlayerPlugin } from "./webpack-plugin.js";
|
|
3
|
+
export { IntlayerPlugin, devServerConfig, getWebpackConfig };
|
package/dist/types/utils.d.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
//#region src/utils.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* Set the __dirname global variable to make the config work in both ESM and CJS environments
|
|
3
4
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
declare const defineDirname: () => void;
|
|
6
|
+
declare const getFileHash: (filePath: string) => string;
|
|
7
|
+
//#endregion
|
|
8
|
+
export { defineDirname, getFileHash };
|
|
6
9
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","
|
|
1
|
+
{"version":3,"file":"utils.d.ts","names":[],"sources":["../../src/utils.ts"],"sourcesContent":[],"mappings":";;AAQA;AASA;cATa;cASA"}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
import { Compiler } from "webpack";
|
|
3
|
+
|
|
4
|
+
//#region src/webpack-plugin.d.ts
|
|
5
|
+
declare class IntlayerPlugin {
|
|
6
|
+
private isWatching;
|
|
7
|
+
private configuration;
|
|
8
|
+
constructor(configuration: IntlayerConfig);
|
|
9
|
+
apply(compiler: Compiler): Promise<void>;
|
|
6
10
|
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { IntlayerPlugin };
|
|
7
13
|
//# sourceMappingURL=webpack-plugin.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack-plugin.d.ts","
|
|
1
|
+
{"version":3,"file":"webpack-plugin.d.ts","names":[],"sources":["../../src/webpack-plugin.ts"],"sourcesContent":[],"mappings":";;;;cAMa,cAAA;;EAAA,QAAA,aAAc;EAIE,WAAA,CAAA,aAAA,EAAA,cAAA;EAIL,KAAA,CAAA,QAAA,EAAA,QAAA,CAAA,EAAW,OAAX,CAAA,IAAA,CAAA"}
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { IntlayerConfig } from "@intlayer/types";
|
|
2
|
+
import { Configuration } from "webpack";
|
|
3
|
+
import { Configuration as Configuration$1 } from "webpack-dev-server";
|
|
4
|
+
|
|
5
|
+
//#region src/webpack.config.d.ts
|
|
6
|
+
declare const devServerConfig: Configuration$1;
|
|
7
|
+
declare const getWebpackConfig: (configuration?: IntlayerConfig) => Configuration;
|
|
8
|
+
//#endregion
|
|
9
|
+
export { getWebpackConfig as default, getWebpackConfig, devServerConfig };
|
|
6
10
|
//# sourceMappingURL=webpack.config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"webpack.config.d.ts","
|
|
1
|
+
{"version":3,"file":"webpack.config.d.ts","names":[],"sources":["../../src/webpack.config.ts"],"sourcesContent":[],"mappings":";;;;;cAWa,iBAAiB;cA4BjB,mCACI,mBACd"}
|