@cpp.js/plugin-webpack 2.0.0-beta.29 → 2.0.0-beta.30
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/index.js +25 -3
- package/package.json +2 -2
package/index.js
CHANGED
|
@@ -44,11 +44,17 @@ export default class CppjsWebpackPlugin {
|
|
|
44
44
|
const buildTarget = isDev ? buildTargetDebug : buildTargetRelease;
|
|
45
45
|
await buildDependencies({ targetParams: { ...targetParams, buildType: [buildTarget.buildType] } });
|
|
46
46
|
const force = isSourceNewer(buildTarget);
|
|
47
|
-
createLib(buildTarget, 'Source', { force, buildSource: true });
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
const sourceBuilt = createLib(buildTarget, 'Source', { force, buildSource: true });
|
|
48
|
+
// Bridge cache is keyed on the nativeGlob fingerprint: a changed bridge
|
|
49
|
+
// set rebuilds the lib even without source changes, and a rebuilt lib
|
|
50
|
+
// must force the final link too.
|
|
51
|
+
const bridgeBuilt = createLib(buildTarget, 'Bridge', { force, buildSource: false, nativeGlob: [`${state.config.paths.cli}/assets/cpp-runtime/commonBridges.cpp`, ...this.bridges] });
|
|
52
|
+
await buildWasm(buildTarget, { force: force || Boolean(sourceBuilt) || Boolean(bridgeBuilt) });
|
|
50
53
|
if (!isDev) {
|
|
51
54
|
const output = state.config.paths.output === state.config.paths.build ? compilation.options.output.path : state.config.paths.output;
|
|
55
|
+
// On a first-ever build the output dir may not exist yet when this
|
|
56
|
+
// hook runs; copyFileSync reports that as ENOENT too.
|
|
57
|
+
fs.mkdirSync(output, { recursive: true });
|
|
52
58
|
fs.copyFileSync(`${state.config.paths.build}/${buildTarget.jsName}`, `${output}/cpp.js`);
|
|
53
59
|
fs.copyFileSync(`${state.config.paths.build}/${buildTarget.wasmName}`, `${output}/cpp.wasm`);
|
|
54
60
|
|
|
@@ -112,6 +118,22 @@ export default class CppjsWebpackPlugin {
|
|
|
112
118
|
},
|
|
113
119
|
});
|
|
114
120
|
|
|
121
|
+
middlewares.unshift({
|
|
122
|
+
name: '/cpp.data.txt',
|
|
123
|
+
path: '/cpp.data.txt',
|
|
124
|
+
middleware: (req, res) => {
|
|
125
|
+
const filePath = `${state.config.paths.build}/${buildTargetDebug.dataTxtName}`;
|
|
126
|
+
res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
|
|
127
|
+
res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
|
|
128
|
+
if (!fs.existsSync(filePath)) {
|
|
129
|
+
res.statusCode = 404;
|
|
130
|
+
res.end();
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
fs.createReadStream(filePath).pipe(res);
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
|
|
115
137
|
return middlewares;
|
|
116
138
|
}
|
|
117
139
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cpp.js/plugin-webpack",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.30",
|
|
4
4
|
"description": "Cpp.js Webpack plugin: A tool for seamless C++ integration with the Webpack bundler.",
|
|
5
5
|
"homepage": "https://github.com/bugra9/cpp.js/tree/main/packages/cppjs-plugin-webpack#readme",
|
|
6
6
|
"repository": "https://github.com/bugra9/cpp.js.git",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"type": "module",
|
|
9
9
|
"main": "index.js",
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"cpp.js": "^2.0.0-beta.
|
|
11
|
+
"cpp.js": "^2.0.0-beta.30"
|
|
12
12
|
},
|
|
13
13
|
"peerDependencies": {
|
|
14
14
|
"webpack": ">=5"
|