@devvit/start 0.12.9-next-2026-01-12-21-31-23-d0283fd9f.0 → 0.12.9-next-2026-01-13-19-02-46-fb8ecad92.0
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/package.json +5 -6
- package/vite/index.d.ts.map +1 -1
- package/vite/index.js +64 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devvit/start",
|
|
3
|
-
"version": "0.12.9-next-2026-01-
|
|
3
|
+
"version": "0.12.9-next-2026-01-13-19-02-46-fb8ecad92.0",
|
|
4
4
|
"license": "BSD-3-Clause",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,7 +21,6 @@
|
|
|
21
21
|
"build": "tsc",
|
|
22
22
|
"clean": "rm -rf .turbo coverage dist",
|
|
23
23
|
"clobber": "yarn clean && rm -rf node_modules",
|
|
24
|
-
"dev": "tsc -w",
|
|
25
24
|
"lint": "redlint .",
|
|
26
25
|
"lint:fix": "yarn lint --fix",
|
|
27
26
|
"prepublishOnly": "publish-package-json",
|
|
@@ -31,19 +30,19 @@
|
|
|
31
30
|
"test:unit-with-coverage": "vitest run --coverage"
|
|
32
31
|
},
|
|
33
32
|
"dependencies": {
|
|
34
|
-
"@devvit/shared-types": "0.12.9-next-2026-01-
|
|
33
|
+
"@devvit/shared-types": "0.12.9-next-2026-01-13-19-02-46-fb8ecad92.0",
|
|
35
34
|
"chalk": "4.1.2"
|
|
36
35
|
},
|
|
37
36
|
"peerDependencies": {
|
|
38
37
|
"vite": ">=6.0.0"
|
|
39
38
|
},
|
|
40
39
|
"devDependencies": {
|
|
41
|
-
"@devvit/repo-tools": "0.12.9-next-2026-01-
|
|
42
|
-
"@devvit/tsconfig": "0.12.9-next-2026-01-
|
|
40
|
+
"@devvit/repo-tools": "0.12.9-next-2026-01-13-19-02-46-fb8ecad92.0",
|
|
41
|
+
"@devvit/tsconfig": "0.12.9-next-2026-01-13-19-02-46-fb8ecad92.0",
|
|
43
42
|
"eslint": "9.11.1",
|
|
44
43
|
"typescript": "5.8.3",
|
|
45
44
|
"vite": "7.2.7",
|
|
46
45
|
"vitest": "4.0.15"
|
|
47
46
|
},
|
|
48
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "feae516f9beffc266d45383d10850887af164d0e"
|
|
49
48
|
}
|
package/vite/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vite/index.ts"],"names":[],"mappings":"AAaA,OAAO,EAEL,KAAK,kBAAkB,EAEvB,KAAK,MAAM,EAEZ,MAAM,MAAM,CAAC;AAEd;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,kCAAkC;IAClC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAE5B,kCAAkC;IAClC,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAE5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,QAAQ,CAAC;IAEhD;;;OAGG;IACH,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,CAAC;AAqEF;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,IAAI,GAAE,mBAAwB,GAAG,MAAM,CAmO7D"}
|
package/vite/index.js
CHANGED
|
@@ -7,6 +7,12 @@ import { mergeConfig, } from 'vite';
|
|
|
7
7
|
const shouldSuppressWarning = (warning) => {
|
|
8
8
|
return warning.code === 'EVAL' && (warning.id ?? '').includes('node_modules/@protobufjs/inquire');
|
|
9
9
|
};
|
|
10
|
+
const shouldCheckClientForServerImports = (environmentName) => {
|
|
11
|
+
// When Vite's Environment API is unavailable (or the hook is invoked without environment context),
|
|
12
|
+
// treat the build as "client" for safety. This prevents accidental bundling of server code into
|
|
13
|
+
// the browser output.
|
|
14
|
+
return environmentName === undefined || environmentName === 'client';
|
|
15
|
+
};
|
|
10
16
|
/**
|
|
11
17
|
* Reads and parses the devvit.json configuration file.
|
|
12
18
|
*/
|
|
@@ -61,9 +67,37 @@ function getServerEntry(projectRoot) {
|
|
|
61
67
|
*/
|
|
62
68
|
export function devvit(opts = {}) {
|
|
63
69
|
let isWatchMode = false;
|
|
70
|
+
let projectRoot = process.cwd();
|
|
64
71
|
const buildTimes = new Map();
|
|
72
|
+
const checkViolation = (id, importer) => {
|
|
73
|
+
const restrictedPaths = ['src/server', 'src/api'].map((p) => path.resolve(projectRoot, p));
|
|
74
|
+
const normalizedId = path.normalize(id);
|
|
75
|
+
const violation = restrictedPaths.find((restrictedPath) => {
|
|
76
|
+
// Use path.relative to determine if the module is inside a restricted directory.
|
|
77
|
+
// If the relative path doesn't start with '..' and isn't absolute, it's inside.
|
|
78
|
+
// This handles cross-platform path separators and edge cases better than string matching.
|
|
79
|
+
const relative = path.relative(restrictedPath, normalizedId);
|
|
80
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
81
|
+
});
|
|
82
|
+
if (violation) {
|
|
83
|
+
const relativeId = path.relative(projectRoot, id);
|
|
84
|
+
const relativeViolation = path.relative(projectRoot, violation);
|
|
85
|
+
const relativeImporter = importer ? path.relative(projectRoot, importer) : undefined;
|
|
86
|
+
let message = `\n${chalk.red.bold('Detected server code in the client!')}\n\n` +
|
|
87
|
+
`You are trying to import server code into the client.\n\n`;
|
|
88
|
+
if (relativeImporter) {
|
|
89
|
+
message += ` ${chalk.bold('Importer:')} ${chalk.cyan(relativeImporter)}\n`;
|
|
90
|
+
}
|
|
91
|
+
message +=
|
|
92
|
+
` ${chalk.bold('Imported:')} ${chalk.cyan(relativeId)}\n\n` +
|
|
93
|
+
`Server code in "${chalk.cyan(relativeViolation)}" cannot be used in the browser. If you are trying to share code between the client and server, please move the code to a separate file outside of the src/server directory and import it back into the server.`;
|
|
94
|
+
return message;
|
|
95
|
+
}
|
|
96
|
+
return null;
|
|
97
|
+
};
|
|
65
98
|
return {
|
|
66
99
|
name: 'devvit',
|
|
100
|
+
enforce: 'pre',
|
|
67
101
|
perEnvironmentStartEndDuringDev: true,
|
|
68
102
|
config(config, env) {
|
|
69
103
|
// Only support build command for now
|
|
@@ -74,7 +108,7 @@ export function devvit(opts = {}) {
|
|
|
74
108
|
}
|
|
75
109
|
// Check if watch mode is enabled
|
|
76
110
|
isWatchMode = !!config.build?.watch;
|
|
77
|
-
|
|
111
|
+
projectRoot = config.root ?? process.cwd();
|
|
78
112
|
const devvitConfig = readDevvitConfig(projectRoot);
|
|
79
113
|
if (!devvitConfig) {
|
|
80
114
|
throw new Error(`${chalk.red('✖')} ${chalk.bold('devvit plugin error')}\n\n` +
|
|
@@ -166,6 +200,35 @@ export function devvit(opts = {}) {
|
|
|
166
200
|
},
|
|
167
201
|
};
|
|
168
202
|
},
|
|
203
|
+
async resolveId(source, importer, options) {
|
|
204
|
+
const envName = this.environment?.name;
|
|
205
|
+
if (!shouldCheckClientForServerImports(envName))
|
|
206
|
+
return null;
|
|
207
|
+
const resolved = await this.resolve(source, importer, { skipSelf: true, ...options });
|
|
208
|
+
const id = resolved?.id ?? source;
|
|
209
|
+
const message = checkViolation(id, importer);
|
|
210
|
+
if (message) {
|
|
211
|
+
const error = new Error(message);
|
|
212
|
+
error.stack = '';
|
|
213
|
+
this.error(error);
|
|
214
|
+
}
|
|
215
|
+
return null;
|
|
216
|
+
},
|
|
217
|
+
load(id) {
|
|
218
|
+
const envName = this.environment?.name;
|
|
219
|
+
if (!shouldCheckClientForServerImports(envName))
|
|
220
|
+
return null;
|
|
221
|
+
// This is a safety net check.
|
|
222
|
+
// resolveId should catch the import before it reaches load, but this
|
|
223
|
+
// ensures that even if something slips through resolution or is loaded
|
|
224
|
+
// by a different mechanism, we still block server code from the client bundle.
|
|
225
|
+
const message = checkViolation(id);
|
|
226
|
+
if (message) {
|
|
227
|
+
const error = new Error(message);
|
|
228
|
+
error.stack = '';
|
|
229
|
+
this.error(error);
|
|
230
|
+
}
|
|
231
|
+
},
|
|
169
232
|
buildStart() {
|
|
170
233
|
if (!isWatchMode)
|
|
171
234
|
return;
|