Skip to content

Commit 0b2a1b0

Browse files
committed
Version the bundled @nimiq/core version to avoid cache issues
The @nimiq/core files are not versioned or hashed otherwise.
1 parent 4f613af commit 0b2a1b0

File tree

6 files changed

+23
-12
lines changed

6 files changed

+23
-12
lines changed

demos/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ <h2>Result</h2>
182182
crossorigin="anonymous"></script>
183183

184184
<script type="module">
185-
import init, * as Nimiq from '/albatross-client/web/index.js';
185+
import init, * as Nimiq from '/nimiq/v<%= htmlWebpackPlugin.options.coreVersion %>/web/index.js';
186186

187187
/** @type {Promise<Nimiq> | undefined} */
188188
let initPromise;

public/cashlink.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
<link rel="icon" href="<%= htmlWebpackPlugin.options.domain %>/favicon.ico">
2323

2424
<script type="module">
25-
import init, * as Nimiq from '/albatross-client/web/index.js';
25+
import init, * as Nimiq from '/nimiq/v<%= htmlWebpackPlugin.options.coreVersion %>/web/index.js';
2626

2727
/** @type {Promise<Nimiq> | undefined} */
2828
let initPromise;

public/export.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
</style>
1414

1515
<script type="module">
16-
import init, * as Nimiq from '/albatross-client/web/index.js';
16+
import init, * as Nimiq from '/nimiq/v<%= htmlWebpackPlugin.options.coreVersion %>/web/index.js';
1717

1818
/** @type {Promise<Nimiq> | undefined} */
1919
let initPromise;

public/iframe.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<meta name="robots" content="noindex">
77
<title>Nimiq Hub IFrame</title>
88
<script type="module">
9-
import init, * as Nimiq from '/albatross-client/web/index.js';
9+
import init, * as Nimiq from '/nimiq/v<%= htmlWebpackPlugin.options.coreVersion %>/web/index.js';
1010

1111
/** @type {Promise<Nimiq> | undefined} */
1212
let initPromise;

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<link rel="icon" href="<%= htmlWebpackPlugin.options.domain %>/favicon.ico">
2121

2222
<script type="module">
23-
import init, * as Nimiq from '/albatross-client/web/index.js';
23+
import init, * as Nimiq from '/nimiq/v<%= htmlWebpackPlugin.options.coreVersion %>/web/index.js';
2424

2525
/** @type {Promise<Nimiq> | undefined} */
2626
let initPromise;

vue.config.js

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,18 @@ const createHash = require('crypto').createHash;
88
// const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin;
99
const PoLoaderOptimizer = require('webpack-i18n-tools')();
1010

11+
let coreVersion = '';
12+
try {
13+
// Will fail until @nimiq/core export map is updated to also make the package.json file available
14+
coreVersion = require('@nimiq/core/package.json').version;
15+
} catch (e) {
16+
// Fallback to reading the package.json file directly
17+
pkgJson = require('fs').readFileSync(path.join(__dirname, 'node_modules/@nimiq/core/package.json'));
18+
coreVersion = JSON.parse(pkgJson).version;
19+
}
20+
21+
if (!coreVersion) throw new Error('Could not determine @nimiq/core version');
22+
1123
const crypto = require('crypto');
1224

1325
// Fix build for Node version with OpenSSL 3
@@ -28,8 +40,6 @@ const domain = buildName === 'mainnet'
2840
? process.env.VUE_APP_HUB_URL
2941
: 'http://localhost:8080';
3042

31-
const cdnDomain = 'https://cdn.nimiq-testnet.com';
32-
3343
const browserWarningTemplate = fs.readFileSync(
3444
path.join(__dirname, 'node_modules/@nimiq/browser-warning/dist/browser-warning.html.template'));
3545

@@ -73,7 +83,7 @@ const configureWebpack = {
7383
},
7484
{
7585
from: 'node_modules/@nimiq/core',
76-
to: './albatross-client/',
86+
to: `./nimiq/v${coreVersion}/`,
7787
},
7888
]}),
7989
new WriteFileWebpackPlugin(),
@@ -130,7 +140,7 @@ const pages = {
130140
browserWarningTemplate,
131141
browserWarningIntegrityHash,
132142
domain,
133-
cdnDomain,
143+
coreVersion,
134144
// output as dist/index.html
135145
filename: 'index.html',
136146
// chunks to include on this page, by default includes
@@ -142,6 +152,7 @@ const pages = {
142152
entry: 'src/iframe.ts',
143153
// the source template
144154
template: 'public/iframe.html',
155+
coreVersion,
145156
// output as dist/iframe.html
146157
filename: 'iframe.html',
147158
// chunks to include on this page, by default includes
@@ -157,7 +168,7 @@ const pages = {
157168
browserWarningTemplate,
158169
browserWarningIntegrityHash,
159170
domain,
160-
cdnDomain,
171+
coreVersion,
161172
// output as dist/cashlink/index.html
162173
filename: 'cashlink/index.html',
163174
// chunks to include on this page, by default includes
@@ -169,7 +180,7 @@ const pages = {
169180
entry: 'src/export.ts',
170181
// the source template
171182
template: 'public/export.html',
172-
cdnDomain,
183+
coreVersion,
173184
// output as dist/iframe.html
174185
filename: 'export.html',
175186
},
@@ -181,7 +192,7 @@ if (buildName === 'local' || buildName === 'testnet') {
181192
entry: 'demos/Demo.ts',
182193
// the source template
183194
template: 'demos/index.html',
184-
cdnDomain,
195+
coreVersion,
185196
bitcoinJsIntegrityHash,
186197
// output as dist/demos.html
187198
filename: 'demos.html',

0 commit comments

Comments
 (0)