Skip to content

Commit 8f7f57f

Browse files
jhildenbiddlesy-records
authored andcommitted
Fix for Vercal “unsupported modules” error
1 parent 208ddbb commit 8f7f57f

File tree

6 files changed

+33
-34
lines changed

6 files changed

+33
-34
lines changed

jest.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import serverConfig from './server.config.js';
1+
import serverConfigs from './server.configs.js';
22

3-
const { hostname, port } = serverConfig.test;
3+
const { hostname, port } = serverConfigs.test;
44
const TEST_HOST = `http://${hostname}:${port}`;
55
const sharedConfig = {
66
errorOnDeprecated: true,

middleware.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
import { rewriteRules } from './server.config.js';
1+
import serverConfigs from './server.configs.js';
2+
3+
const { rewriteRules } = serverConfigs.dev;
24

35
// Exports
46
// =============================================================================

playwright.config.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { devices } from '@playwright/test';
2-
import serverConfig from './server.config.js';
2+
import serverConfigs from './server.configs.js';
33

4-
const { hostname, port } = serverConfig.test;
4+
const { hostname, port } = serverConfigs.test;
55
const TEST_HOST = `http://${hostname}:${port}`;
66

77
process.env.TEST_HOST = TEST_HOST;

server.config.js renamed to server.configs.js

Lines changed: 23 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,31 +4,6 @@ import * as url from 'node:url';
44
const __filename = url.fileURLToPath(import.meta.url);
55
const __dirname = path.dirname(__filename);
66

7-
// Rewrite rules shared with Vercel middleware.js
8-
export const rewriteRules = [
9-
// Replace CDN URLs with local paths
10-
{
11-
match: /https?.*\/CHANGELOG.md/g,
12-
replace: '/CHANGELOG.md',
13-
},
14-
{
15-
// CDN versioned default
16-
// Ex1: //cdn.com/package-name
17-
// Ex2: http://cdn.com/[email protected]
18-
// Ex3: https://cdn.com/package-name@latest
19-
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g,
20-
replace: '/lib/docsify.min.js',
21-
},
22-
{
23-
// CDN paths to local paths
24-
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
25-
// Ex2: http://cdn.com/[email protected]/dist/file.js => /dist/file.js
26-
// Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js
27-
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g,
28-
replace: '/lib/',
29-
},
30-
];
31-
327
// Production (CDN URLs, watch disabled)
338
const prod = {
349
hostname: '127.0.0.1',
@@ -47,7 +22,29 @@ const dev = {
4722
...prod,
4823
files: ['CHANGELOG.md', 'docs/**/*', 'lib/**/*'],
4924
port: 3000,
50-
rewriteRules,
25+
rewriteRules: [
26+
// Replace CDN URLs with local paths
27+
{
28+
match: /https?.*\/CHANGELOG.md/g,
29+
replace: '/CHANGELOG.md',
30+
},
31+
{
32+
// CDN versioned default
33+
// Ex1: //cdn.com/package-name
34+
// Ex2: http://cdn.com/[email protected]
35+
// Ex3: https://cdn.com/package-name@latest
36+
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*(?=["'])/g,
37+
replace: '/lib/docsify.min.js',
38+
},
39+
{
40+
// CDN paths to local paths
41+
// Ex1: //cdn.com/package-name/path/file.js => /path/file.js
42+
// Ex2: http://cdn.com/[email protected]/dist/file.js => /dist/file.js
43+
// Ex3: https://cdn.com/package-name@latest/dist/file.js => /dist/file.js
44+
match: /(?:https?:)*\/\/.*cdn.*docsify[@\d.latest]*\/(?:lib\/)/g,
45+
replace: '/lib/',
46+
},
47+
],
5148
server: {
5249
...prod.server,
5350
routes: {

server.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { create } from 'browser-sync';
2-
import serverConfigs from './server.config.js';
2+
import serverConfigs from './server.configs.js';
33

44
const bsServer = create();
55
const args = process.argv.slice(2);

test/config/server.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import * as process from 'node:process';
22
import { create } from 'browser-sync';
3-
import config from '../../server.config.js';
3+
import serverConfigs from '../../server.configs.js';
44

55
const bsServer = create();
66

77
export async function startServer() {
88
// Wait for server to start
99
return new Promise(resolve => {
10-
const settings = config.test;
10+
const settings = serverConfigs.test;
1111

1212
console.log('\n');
1313

0 commit comments

Comments
 (0)