@fontoxml/fontoxml-development-tools 3.9.0-beta.1 → 3.9.0-beta.2
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/npm-shrinkwrap.json +17998 -9575
- package/package.json +14 -12
- package/src/editorVersions.js +23 -0
- package/src/modules/editor/src/commands/command.run.controller.js +7 -12
- package/src/modules/editor/src/getWebpackConfig.js +178 -33
- package/src/modules/editor/src/getWebpackDevMiddlewareConfig.js +16 -9
- package/src/modules/editor/src/templates/app-entry.cjs +69 -0
- package/src/modules/editor/src/webpackLoaders/generatedLoader.cjs +61 -79
- package/src/modules/editor/src/webpackLoaders/platformSourceMapLoader.cjs +7 -4
- package/src/modules/editor/src/webpackLoaders/symbolLoader.cjs +7 -7
- package/src/modules/editor/src/webpackLoaders/vendorsSourceMapLoader.cjs +5 -3
- package/src/modules/editor/src/webpackPlugins/CopyPlugin.js +172 -224
- package/src/modules/editor/src/webpackPlugins/DependenciesInLoadOrderPlugin.js +2 -11
- package/src/modules/editor/src/webpackPlugins/FdtOutputPlugin.js +102 -95
- package/src/modules/editor/src/webpackPlugins/RemoveExplicitExtensionResolvePlugin.js +19 -18
- package/src/modules/editor/src/webpackPlugins/ResolveImportAliasPlugin.js +10 -18
- package/src/modules/editor/src/webpackPlugins/UnitTestPlugin.js +13 -23
- package/src/modules/editor-pre-7-7-0/src/api/init/createConfigConfiguration.js +39 -10
- package/src/modules/editor-pre-7-7-0/src/api/schema/buildElementConfigurations.js +70 -0
- package/src/modules/editor-pre-7-7-0/src/api/schema/createSchemaExperiencePackages.js +31 -53
- package/src/modules/editor-pre-7-7-0/src/command.init.controller.js +4 -2
- package/src/modules/editor-pre-7-7-0/test/api/init/createConfigConfiguration.test.js +47 -0
- package/src/modules/editor-pre-7-7-0/test/api/schema/buildElementConfigurations.test.js +119 -0
- package/src/modules/editor/src/templates/app-entry.ts +0 -66
|
@@ -1,269 +1,217 @@
|
|
|
1
|
-
/** @typedef {import('webpack').Compiler} Compiler */
|
|
2
|
-
|
|
3
1
|
import fastGlob from 'fast-glob';
|
|
4
2
|
import fs from 'fs-extra';
|
|
5
3
|
import path from 'path';
|
|
6
4
|
import { fileURLToPath } from 'url';
|
|
7
|
-
import webpack from 'webpack';
|
|
8
5
|
|
|
9
6
|
import normalisePath from '../helpers/normalisePath.js';
|
|
10
7
|
|
|
11
8
|
const emittedAssets = new Map();
|
|
9
|
+
const plugin = { name: 'CopyPlugin' };
|
|
12
10
|
|
|
13
11
|
const __filename = fileURLToPath(import.meta.url);
|
|
14
12
|
const __dirname = path.dirname(__filename);
|
|
15
13
|
|
|
16
|
-
/**
|
|
17
|
-
* This plugin add assets to the compilation which do not exist in the
|
|
18
|
-
* dependency tree ('assets' folders of packages).
|
|
19
|
-
*/
|
|
20
14
|
export default class CopyPlugin {
|
|
21
15
|
constructor(options) {
|
|
22
16
|
this.options = options;
|
|
23
17
|
}
|
|
24
18
|
|
|
25
|
-
/**
|
|
26
|
-
* @param {Compiler} compiler
|
|
27
|
-
*/
|
|
28
19
|
apply(compiler) {
|
|
29
20
|
let packageInfos;
|
|
30
21
|
|
|
31
|
-
compiler.hooks.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
)
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
22
|
+
compiler.hooks.emit.tapAsync(plugin, async (compilation, callback) => {
|
|
23
|
+
if (
|
|
24
|
+
compilation.packagesInfoInLoadOrderError ||
|
|
25
|
+
!compilation.packagesInfoInLoadOrder
|
|
26
|
+
) {
|
|
27
|
+
const error =
|
|
28
|
+
compilation.packagesInfoInLoadOrderError ||
|
|
29
|
+
new Error('Could not get package load order information.');
|
|
30
|
+
packageInfos = error.packageInfos || [];
|
|
31
|
+
compilation.errors.push(error);
|
|
32
|
+
callback();
|
|
33
|
+
return;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const templatesPath = normalisePath(
|
|
37
|
+
path.resolve(__dirname, '..', 'templates')
|
|
38
|
+
);
|
|
39
|
+
const assetInfoByTargetPath = new Map();
|
|
40
|
+
|
|
41
|
+
// TODO: It's not stricly necessary to process these assets every (re)compile.
|
|
42
|
+
// TODO: Consider placing these assets somewhere where they're unlikely to cause conflicts.
|
|
43
|
+
(
|
|
44
|
+
await fastGlob(
|
|
45
|
+
[`${fastGlob.escapePath(templatesPath)}/assets/**/*`],
|
|
46
|
+
{
|
|
47
|
+
absolute: true,
|
|
48
|
+
stats: true,
|
|
47
49
|
}
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
50
|
+
)
|
|
51
|
+
).forEach((globResult) => {
|
|
52
|
+
assetInfoByTargetPath.set(
|
|
53
|
+
normalisePath(
|
|
54
|
+
path.relative(templatesPath, globResult.path)
|
|
55
|
+
),
|
|
56
|
+
{
|
|
57
|
+
path: globResult.path,
|
|
58
|
+
stats: globResult.stats,
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
if (this.options.unitTest) {
|
|
64
|
+
const testAssetsPath = normalisePath(
|
|
65
|
+
path.resolve(this.options.paths.contextFolder)
|
|
66
|
+
);
|
|
67
|
+
(
|
|
68
|
+
await fastGlob(
|
|
69
|
+
[
|
|
70
|
+
`${fastGlob.escapePath(
|
|
71
|
+
testAssetsPath
|
|
72
|
+
)}/test/assets/**/*`,
|
|
73
|
+
],
|
|
74
|
+
{
|
|
75
|
+
absolute: true,
|
|
76
|
+
stats: true,
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
).forEach((globResult) => {
|
|
80
|
+
const targetPath = normalisePath(
|
|
81
|
+
path.relative(
|
|
82
|
+
path.join(this.options.paths.contextFolder, 'test'),
|
|
83
|
+
globResult.path
|
|
69
84
|
)
|
|
70
|
-
)
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
),
|
|
75
|
-
{
|
|
76
|
-
path: globResult.path,
|
|
77
|
-
stats: globResult.stats,
|
|
78
|
-
}
|
|
79
|
-
);
|
|
85
|
+
);
|
|
86
|
+
assetInfoByTargetPath.set(targetPath, {
|
|
87
|
+
path: globResult.path,
|
|
88
|
+
stats: globResult.stats,
|
|
80
89
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
path.relative(
|
|
101
|
-
path.join(
|
|
102
|
-
this.options.paths.contextFolder,
|
|
103
|
-
'test'
|
|
104
|
-
),
|
|
105
|
-
globResult.path
|
|
106
|
-
)
|
|
107
|
-
);
|
|
108
|
-
assetInfoByTargetPath.set(targetPath, {
|
|
109
|
-
path: globResult.path,
|
|
110
|
-
stats: globResult.stats,
|
|
111
|
-
});
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
packageInfos = compilation.packagesInfoInLoadOrder;
|
|
94
|
+
|
|
95
|
+
(
|
|
96
|
+
await Promise.all(
|
|
97
|
+
packageInfos.map(async (packageInfo) => {
|
|
98
|
+
const glob =
|
|
99
|
+
fastGlob.escapePath(
|
|
100
|
+
normalisePath(packageInfo.path)
|
|
101
|
+
) +
|
|
102
|
+
(packageInfo.name === 'config'
|
|
103
|
+
? '/assets/**/*'
|
|
104
|
+
: '/src/assets/**/*');
|
|
105
|
+
|
|
106
|
+
return await fastGlob([glob], {
|
|
107
|
+
absolute: true,
|
|
108
|
+
stats: true,
|
|
112
109
|
});
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
fastGlob.escapePath(
|
|
122
|
-
normalisePath(packageInfo.path)
|
|
123
|
-
) +
|
|
124
|
-
(packageInfo.name === 'config'
|
|
125
|
-
? '/assets/**/*'
|
|
126
|
-
: '/src/assets/**/*');
|
|
127
|
-
|
|
128
|
-
return await fastGlob([glob], {
|
|
129
|
-
absolute: true,
|
|
130
|
-
stats: true,
|
|
131
|
-
});
|
|
132
|
-
})
|
|
110
|
+
})
|
|
111
|
+
)
|
|
112
|
+
).reduce((map, globResults) => {
|
|
113
|
+
globResults.forEach((globResult) => {
|
|
114
|
+
const relativePath = normalisePath(
|
|
115
|
+
path.relative(
|
|
116
|
+
this.options.paths.contextFolder,
|
|
117
|
+
globResult.path
|
|
133
118
|
)
|
|
134
|
-
)
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
path.posix.sep
|
|
144
|
-
);
|
|
145
|
-
const isRootPackage =
|
|
146
|
-
relativePath.startsWith('config') ||
|
|
147
|
-
(this.options.unitTest &&
|
|
148
|
-
relativePath.startsWith('src/'));
|
|
149
|
-
const targetPath = path.posix.join(
|
|
150
|
-
...pathParts.slice(isRootPackage ? 1 : 3)
|
|
151
|
-
);
|
|
152
|
-
|
|
153
|
-
map.set(targetPath, {
|
|
154
|
-
path: globResult.path,
|
|
155
|
-
stats: globResult.stats,
|
|
156
|
-
});
|
|
157
|
-
});
|
|
119
|
+
);
|
|
120
|
+
const pathParts = relativePath.split(path.posix.sep);
|
|
121
|
+
const isRootPackage =
|
|
122
|
+
relativePath.startsWith('config') ||
|
|
123
|
+
(this.options.unitTest &&
|
|
124
|
+
relativePath.startsWith('src/'));
|
|
125
|
+
const targetPath = path.posix.join(
|
|
126
|
+
...pathParts.slice(isRootPackage ? 1 : 3)
|
|
127
|
+
);
|
|
158
128
|
|
|
159
|
-
|
|
160
|
-
|
|
129
|
+
map.set(targetPath, {
|
|
130
|
+
path: globResult.path,
|
|
131
|
+
stats: globResult.stats,
|
|
132
|
+
});
|
|
133
|
+
});
|
|
161
134
|
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
if (!assetInfoByTargetPath.has(targetPath)) {
|
|
165
|
-
const assetOutputPath = path.join(
|
|
166
|
-
compilation.getPath(compiler.outputPath),
|
|
167
|
-
targetPath
|
|
168
|
-
);
|
|
135
|
+
return map;
|
|
136
|
+
}, assetInfoByTargetPath);
|
|
169
137
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
138
|
+
await Promise.all(
|
|
139
|
+
[...emittedAssets.keys()].map(async (targetPath) => {
|
|
140
|
+
if (!assetInfoByTargetPath.has(targetPath)) {
|
|
141
|
+
const assetOutputPath = path.join(
|
|
142
|
+
compilation.getPath(compiler.outputPath),
|
|
143
|
+
targetPath
|
|
144
|
+
);
|
|
177
145
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
146
|
+
await new Promise((resolve, reject) =>
|
|
147
|
+
compiler.outputFileSystem.unlink(
|
|
148
|
+
assetOutputPath,
|
|
149
|
+
(error) => (error ? reject(error) : resolve())
|
|
150
|
+
)
|
|
151
|
+
);
|
|
182
152
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
assetInfoByTargetPath.get(targetPath);
|
|
153
|
+
emittedAssets.delete(targetPath);
|
|
154
|
+
}
|
|
155
|
+
})
|
|
156
|
+
);
|
|
188
157
|
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
assetInfo.path &&
|
|
193
|
-
emittedAssets.get(targetPath).stats
|
|
194
|
-
.mtimeMs === assetInfo.stats.mtimeMs
|
|
195
|
-
) {
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
158
|
+
await Promise.all(
|
|
159
|
+
[...assetInfoByTargetPath.keys()].map(async (targetPath) => {
|
|
160
|
+
const assetInfo = assetInfoByTargetPath.get(targetPath);
|
|
198
161
|
|
|
199
|
-
|
|
162
|
+
if (
|
|
163
|
+
emittedAssets.has(targetPath) &&
|
|
164
|
+
emittedAssets.get(targetPath).path === assetInfo.path &&
|
|
165
|
+
emittedAssets.get(targetPath).stats.mtimeMs ===
|
|
166
|
+
assetInfo.stats.mtimeMs
|
|
167
|
+
) {
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
200
170
|
|
|
201
|
-
|
|
202
|
-
assetInfo.path
|
|
203
|
-
);
|
|
171
|
+
emittedAssets.set(targetPath, assetInfo);
|
|
204
172
|
|
|
205
|
-
|
|
206
|
-
targetPath,
|
|
207
|
-
new webpack.sources.RawSource(content)
|
|
208
|
-
);
|
|
209
|
-
}
|
|
210
|
-
)
|
|
211
|
-
);
|
|
173
|
+
const content = await fs.readFile(assetInfo.path);
|
|
212
174
|
|
|
213
|
-
|
|
214
|
-
|
|
175
|
+
compilation.assets[targetPath] = {
|
|
176
|
+
size() {
|
|
177
|
+
return assetInfo.stats.size;
|
|
178
|
+
},
|
|
179
|
+
source() {
|
|
180
|
+
return content;
|
|
181
|
+
},
|
|
182
|
+
};
|
|
183
|
+
})
|
|
215
184
|
);
|
|
216
185
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
186
|
+
callback();
|
|
187
|
+
});
|
|
188
|
+
|
|
189
|
+
compiler.hooks.afterEmit.tapAsync(plugin, (compilation, callback) => {
|
|
190
|
+
const platformPath = path.normalize(
|
|
191
|
+
this.options.paths.platformFolder
|
|
192
|
+
);
|
|
223
193
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
packageInfo.path
|
|
228
|
-
);
|
|
194
|
+
// TODO: Consider checking if the assets folder/manifest file exists before watching.
|
|
195
|
+
packageInfos.forEach((packageInfo) => {
|
|
196
|
+
const packagePath = path.normalize(packageInfo.path);
|
|
229
197
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
) {
|
|
234
|
-
return;
|
|
235
|
-
}
|
|
198
|
+
if (packagePath === path.join(platformPath, packageInfo.name)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
236
201
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
202
|
+
compilation.contextDependencies.add(
|
|
203
|
+
path.join(
|
|
204
|
+
packagePath,
|
|
205
|
+
packageInfo.name === 'config' ? 'assets' : 'src/assets'
|
|
206
|
+
)
|
|
207
|
+
);
|
|
243
208
|
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
const exists = await fs
|
|
249
|
-
.access(fontoManifestPath)
|
|
250
|
-
.then(() => true)
|
|
251
|
-
.catch(() => false);
|
|
252
|
-
if (exists) {
|
|
253
|
-
compilation.fileDependencies.add(
|
|
254
|
-
fontoManifestPath
|
|
255
|
-
);
|
|
256
|
-
} else {
|
|
257
|
-
compilation.missingDependencies.add(
|
|
258
|
-
fontoManifestPath
|
|
259
|
-
);
|
|
260
|
-
}
|
|
261
|
-
})
|
|
262
|
-
);
|
|
209
|
+
compilation.fileDependencies.add(
|
|
210
|
+
path.join(packagePath, 'fonto-manifest.json')
|
|
211
|
+
);
|
|
212
|
+
});
|
|
263
213
|
|
|
264
|
-
|
|
265
|
-
}
|
|
266
|
-
);
|
|
214
|
+
callback();
|
|
267
215
|
});
|
|
268
216
|
}
|
|
269
217
|
}
|
|
@@ -1,24 +1,15 @@
|
|
|
1
|
-
/** @typedef {import('webpack').Compiler} Compiler */
|
|
2
|
-
|
|
3
1
|
import getDependenciesInLoadOrder from '../getDependenciesInLoadOrder.js';
|
|
4
2
|
|
|
5
|
-
/**
|
|
6
|
-
* This plugin exposes Fonto Editor's dependency tree through webpack's
|
|
7
|
-
* compilation objects for use by other plugins.
|
|
8
|
-
*/
|
|
9
3
|
export default class DependenciesInLoadOrderPlugin {
|
|
10
4
|
constructor(options) {
|
|
11
5
|
this.options = options;
|
|
12
6
|
}
|
|
13
7
|
|
|
14
|
-
/**
|
|
15
|
-
* @param {Compiler} compiler
|
|
16
|
-
*/
|
|
17
8
|
apply(compiler) {
|
|
18
9
|
// Listen to thisCompilation hook and get dependencies in load order once per compilation.
|
|
19
10
|
compiler.hooks.thisCompilation.tap(
|
|
20
|
-
DependenciesInLoadOrderPlugin
|
|
21
|
-
(compilation) => {
|
|
11
|
+
'DependenciesInLoadOrderPlugin',
|
|
12
|
+
(compilation, _compilationParams) => {
|
|
22
13
|
try {
|
|
23
14
|
const packageRootFolders =
|
|
24
15
|
this.options.paths.packageRootFolders;
|