@intlayer/webpack 1.2.1 → 2.0.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/package.json +6 -8
- package/src/getEntries.ts +0 -19
- package/src/utils.ts +0 -26
- package/src/webpack-plugin.ts +0 -10
- package/src/webpack.config.ts +0 -153
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@intlayer/webpack",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Webpack application for IntLayer - Transpile Intlayer declaration files into dictionaries using webpack.",
|
|
6
6
|
"keywords": [
|
|
@@ -41,8 +41,6 @@
|
|
|
41
41
|
},
|
|
42
42
|
"files": [
|
|
43
43
|
"./dist",
|
|
44
|
-
"./src",
|
|
45
|
-
"./bin",
|
|
46
44
|
"./package.json"
|
|
47
45
|
],
|
|
48
46
|
"dependencies": {
|
|
@@ -57,11 +55,11 @@
|
|
|
57
55
|
"webpack": "^5.91.0",
|
|
58
56
|
"webpack-cli": "^5.1.4",
|
|
59
57
|
"webpack-dev-server": "^5.0.4",
|
|
60
|
-
"@intlayer/chokidar": "^
|
|
61
|
-
"@intlayer/cli": "^
|
|
62
|
-
"@intlayer/config": "^
|
|
63
|
-
"@intlayer/core": "^
|
|
64
|
-
"intlayer": "^
|
|
58
|
+
"@intlayer/chokidar": "^2.0.1",
|
|
59
|
+
"@intlayer/cli": "^2.0.1",
|
|
60
|
+
"@intlayer/config": "^2.0.1",
|
|
61
|
+
"@intlayer/core": "^2.0.1",
|
|
62
|
+
"intlayer": "^2.0.1"
|
|
65
63
|
},
|
|
66
64
|
"devDependencies": {
|
|
67
65
|
"@changesets/cli": "2.27.1",
|
package/src/getEntries.ts
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getConfiguration } from '@intlayer/config';
|
|
2
|
-
import { sync } from 'glob';
|
|
3
|
-
import type { EntryObject } from 'webpack';
|
|
4
|
-
import { getFileHash } from './utils';
|
|
5
|
-
|
|
6
|
-
const { content } = getConfiguration();
|
|
7
|
-
const { watchedFilesPatternWithPath } = content;
|
|
8
|
-
|
|
9
|
-
export const getEntries = (): EntryObject =>
|
|
10
|
-
sync(watchedFilesPatternWithPath).reduce((obj, el) => {
|
|
11
|
-
const hash = getFileHash(el);
|
|
12
|
-
|
|
13
|
-
obj[`intlayer-content/${hash}`] = {
|
|
14
|
-
import: el,
|
|
15
|
-
dependOn: undefined,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
return obj;
|
|
19
|
-
}, {} as EntryObject);
|
package/src/utils.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import path from 'path';
|
|
2
|
-
import { fileURLToPath } from 'url';
|
|
3
|
-
import crypto from 'crypto-js';
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* Set the __dirname global variable to make the config work in both ESM and CJS environments
|
|
7
|
-
*/
|
|
8
|
-
export const defineDirname = () => {
|
|
9
|
-
const isESModule = typeof import.meta.url === 'string';
|
|
10
|
-
|
|
11
|
-
const filename = isESModule
|
|
12
|
-
? fileURLToPath(import.meta.url)
|
|
13
|
-
: require('url').pathToFileURL(__filename).toString();
|
|
14
|
-
|
|
15
|
-
globalThis.__filename = globalThis.__filename ?? filename;
|
|
16
|
-
globalThis.__dirname = globalThis.__dirname ?? path.dirname(__filename);
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export const getFileHash = (filePath: string) => {
|
|
20
|
-
const hash = crypto.SHA3(filePath);
|
|
21
|
-
|
|
22
|
-
return hash
|
|
23
|
-
.toString(crypto.enc.Base64)
|
|
24
|
-
.replace(/[^A-Z\d]/gi, '')
|
|
25
|
-
.substring(0, 20);
|
|
26
|
-
};
|
package/src/webpack-plugin.ts
DELETED
package/src/webpack.config.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
import { join } from 'path';
|
|
2
|
-
import { getConfiguration } from '@intlayer/config';
|
|
3
|
-
import type { Configuration as WebPackConfiguration } from 'webpack';
|
|
4
|
-
import type { Configuration as DevServerConfiguration } from 'webpack-dev-server';
|
|
5
|
-
import { getEntries } from './getEntries';
|
|
6
|
-
import { defineDirname } from './utils';
|
|
7
|
-
import { IntLayerPlugin } from './webpack-plugin';
|
|
8
|
-
|
|
9
|
-
const { content } = getConfiguration({
|
|
10
|
-
verbose: false,
|
|
11
|
-
});
|
|
12
|
-
const { fileExtensions } = content;
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Set the __dirname global variable to make the config work in both ESM and CJS environments
|
|
16
|
-
*/
|
|
17
|
-
defineDirname();
|
|
18
|
-
|
|
19
|
-
// For web interface
|
|
20
|
-
export const devServerConfig: DevServerConfiguration = {
|
|
21
|
-
// Enable hot module replacement
|
|
22
|
-
hot: true,
|
|
23
|
-
// Open the browser
|
|
24
|
-
open: false,
|
|
25
|
-
liveReload: false,
|
|
26
|
-
|
|
27
|
-
// Enable compression
|
|
28
|
-
compress: true,
|
|
29
|
-
|
|
30
|
-
// History API fallback
|
|
31
|
-
historyApiFallback: false,
|
|
32
|
-
|
|
33
|
-
// Host and port
|
|
34
|
-
host: 'localhost',
|
|
35
|
-
port: 8080,
|
|
36
|
-
|
|
37
|
-
watchFiles: './src/', // watchedFilesPatternWithPath,
|
|
38
|
-
|
|
39
|
-
devMiddleware: {
|
|
40
|
-
// Enable write to disk to reuse the output
|
|
41
|
-
writeToDisk: true,
|
|
42
|
-
},
|
|
43
|
-
|
|
44
|
-
// Content base
|
|
45
|
-
static: {},
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
export const webpackConfig: WebPackConfiguration = {
|
|
49
|
-
// Define the environment mode (development or production)
|
|
50
|
-
mode: 'production', // or 'production'
|
|
51
|
-
// Entry point of the application
|
|
52
|
-
target: 'node', // Specifies the target environment
|
|
53
|
-
|
|
54
|
-
entry: getEntries,
|
|
55
|
-
output: {
|
|
56
|
-
clean: true, // Clean the output directory before emit
|
|
57
|
-
library: 'IntlLayerContent',
|
|
58
|
-
libraryTarget: 'umd',
|
|
59
|
-
filename: `[name].bundle.js`,
|
|
60
|
-
},
|
|
61
|
-
|
|
62
|
-
cache: false,
|
|
63
|
-
|
|
64
|
-
devtool: 'source-map',
|
|
65
|
-
|
|
66
|
-
// stats: {
|
|
67
|
-
// preset: 'errors-only',
|
|
68
|
-
// warnings: false,
|
|
69
|
-
// },
|
|
70
|
-
ignoreWarnings: [/./],
|
|
71
|
-
resolve: {
|
|
72
|
-
// Resolve TypeScript, JavaScript and JSON files
|
|
73
|
-
extensions: ['.ts', '.js', '.json', '.wasm', '.ts', '.tsx', '.mjs', '.cjs'],
|
|
74
|
-
modules: [
|
|
75
|
-
// To find the loader module
|
|
76
|
-
join(globalThis.__dirname, '..', 'node_modules'), // In the project node_modules
|
|
77
|
-
join(process.cwd(), 'node_modules'), // In the project node_modules
|
|
78
|
-
join(process.cwd(), 'node_modules', 'intlayer-cli', 'node_modules'), // Or via another project by importing intlayer
|
|
79
|
-
join(
|
|
80
|
-
process.cwd(),
|
|
81
|
-
'node_modules',
|
|
82
|
-
'intlayer-cli',
|
|
83
|
-
'node_modules',
|
|
84
|
-
'@intlayer/webpack',
|
|
85
|
-
'node_modules'
|
|
86
|
-
), // Or via another project by importing intlayer
|
|
87
|
-
],
|
|
88
|
-
},
|
|
89
|
-
|
|
90
|
-
resolveLoader: {
|
|
91
|
-
// Configure how Webpack finds `loader` modules.
|
|
92
|
-
modules: [
|
|
93
|
-
// To find the loader module
|
|
94
|
-
join(process.cwd(), 'node_modules'), // In the project node_modules
|
|
95
|
-
join(process.cwd(), 'node_modules', '@intlayer/webpack', 'node_modules'), // Or via another project by importing @intlayer/webpack
|
|
96
|
-
join(
|
|
97
|
-
process.cwd(),
|
|
98
|
-
'node_modules',
|
|
99
|
-
'intlayer-cli',
|
|
100
|
-
'node_modules',
|
|
101
|
-
'@intlayer/webpack',
|
|
102
|
-
'node_modules'
|
|
103
|
-
), // Or via another project by importing intlayer
|
|
104
|
-
],
|
|
105
|
-
},
|
|
106
|
-
|
|
107
|
-
module: {
|
|
108
|
-
rules: [
|
|
109
|
-
{
|
|
110
|
-
// Rule for .content.ts files
|
|
111
|
-
test: new RegExp(`(${fileExtensions.join('|')})$`),
|
|
112
|
-
use: [
|
|
113
|
-
{
|
|
114
|
-
// Transpile with esbuild-loader
|
|
115
|
-
loader: 'esbuild-loader',
|
|
116
|
-
options: {
|
|
117
|
-
// JavaScript version to compile to
|
|
118
|
-
target: 'es2015',
|
|
119
|
-
},
|
|
120
|
-
},
|
|
121
|
-
// {
|
|
122
|
-
// // Custom loader to process the transpiled code
|
|
123
|
-
// loader: resolve('./intlayer-loader'),
|
|
124
|
-
// },
|
|
125
|
-
],
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
test: /\.node$/,
|
|
129
|
-
loader: 'node-loader',
|
|
130
|
-
},
|
|
131
|
-
// Use esbuild to compile JavaScript & TypeScript
|
|
132
|
-
{
|
|
133
|
-
// Match `.js`, `.jsx`, `.ts` or `.tsx` files
|
|
134
|
-
test: /\.(jsx|js|ts|tsx|mjs|cjs)?$/,
|
|
135
|
-
loader: 'esbuild-loader',
|
|
136
|
-
options: {
|
|
137
|
-
// JavaScript version to compile to
|
|
138
|
-
target: 'es2015',
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
|
|
142
|
-
// JSON files are supported natively by Webpack 5, no specific loader required
|
|
143
|
-
],
|
|
144
|
-
},
|
|
145
|
-
devServer: devServerConfig,
|
|
146
|
-
|
|
147
|
-
plugins: [
|
|
148
|
-
new IntLayerPlugin(),
|
|
149
|
-
// new HotModuleReplacementPlugin()
|
|
150
|
-
],
|
|
151
|
-
};
|
|
152
|
-
|
|
153
|
-
export default webpackConfig;
|