@cpp.js/plugin-webpack 2.0.0-beta.13 → 2.0.0-beta.15

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.
Files changed (2) hide show
  1. package/index.js +15 -4
  2. package/package.json +2 -2
package/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
 
2
2
  import fs from 'node:fs';
3
- import { state, createLib, buildWasm, createBridgeFile, getData, getCppJsScript, getTargetParams, getFilteredBuildTargets } from 'cpp.js';
3
+ import {
4
+ state, createLib, buildWasm, createBridgeFile, getData, getCppJsScript, getTargetParams, getFilteredBuildTargets, isSourceNewer,
5
+ } from 'cpp.js';
4
6
 
5
7
  const targetParams = getTargetParams({ platform: ['wasm'], arch: ['wasm32'], runtime: ['st'], runtimeEnv: ['browser'] }, true);
6
8
  let buildTargetRelease = getFilteredBuildTargets(targetParams, { buildType: 'release' })?.[0];
@@ -38,9 +40,10 @@ export default class CppjsWebpackPlugin {
38
40
  async onDone({ compilation }) {
39
41
  const isDev = compilation.options.mode === 'development';
40
42
  const buildTarget = isDev ? buildTargetDebug : buildTargetRelease;
41
- createLib(buildTarget, 'Source', { buildSource: true });
42
- createLib(buildTarget, 'Bridge', { buildSource: false, nativeGlob: [`${state.config.paths.cli}/assets/commonBridges.cpp`, ...this.bridges] });
43
- await buildWasm(buildTarget);
43
+ const force = isSourceNewer(buildTarget);
44
+ createLib(buildTarget, 'Source', { force, buildSource: true });
45
+ createLib(buildTarget, 'Bridge', { force, buildSource: false, nativeGlob: [`${state.config.paths.cli}/assets/cpp-runtime/commonBridges.cpp`, ...this.bridges] });
46
+ await buildWasm(buildTarget, { force });
44
47
  if (!isDev) {
45
48
  const output = state.config.paths.output === state.config.paths.build ? compilation.options.output.path : state.config.paths.output;
46
49
  fs.copyFileSync(`${state.config.paths.build}/${buildTarget.jsName}`, `${output}/cpp.js`);
@@ -88,6 +91,8 @@ export default class CppjsWebpackPlugin {
88
91
  middleware: (req, res) => {
89
92
  const filePath = `${state.config.paths.build}/${buildTargetDebug.jsName}`;
90
93
  res.setHeader('Content-Type', 'application/javascript');
94
+ res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
95
+ res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
91
96
  fs.createReadStream(filePath).pipe(res);
92
97
  },
93
98
  });
@@ -98,6 +103,8 @@ export default class CppjsWebpackPlugin {
98
103
  middleware: (req, res) => {
99
104
  const filePath = `${state.config.paths.build}/${buildTargetDebug.wasmName}`;
100
105
  res.setHeader('Content-Type', 'application/wasm');
106
+ res.setHeader('Cross-Origin-Opener-Policy', 'same-origin');
107
+ res.setHeader('Cross-Origin-Embedder-Policy', 'require-corp');
101
108
  fs.createReadStream(filePath).pipe(res);
102
109
  },
103
110
  });
@@ -110,6 +117,10 @@ export default class CppjsWebpackPlugin {
110
117
  watchFiles: state.config.paths.native,
111
118
  hot: true,
112
119
  liveReload: true,
120
+ headers: {
121
+ 'Cross-Origin-Opener-Policy': 'same-origin',
122
+ 'Cross-Origin-Embedder-Policy': 'require-corp',
123
+ },
113
124
  setupMiddlewares: (middlewares, devServer) => {
114
125
  return this.setDevServerMiddleware(middlewares, devServer);
115
126
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cpp.js/plugin-webpack",
3
- "version": "2.0.0-beta.13",
3
+ "version": "2.0.0-beta.15",
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-rollup#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.13"
11
+ "cpp.js": "^2.0.0-beta.15"
12
12
  },
13
13
  "keywords": [
14
14
  "cpp.js-plugin",