@edgeone/opennextjs-pages 0.2.1 → 0.2.2
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.
|
@@ -59,7 +59,7 @@ const config: NextConfig = {
|
|
|
59
59
|
images: {
|
|
60
60
|
...(originalConfig as any)?.images,
|
|
61
61
|
loader: 'custom',
|
|
62
|
-
loaderFile: './.edgeone/
|
|
62
|
+
loaderFile: './.edgeone/image-loader.mjs',
|
|
63
63
|
},
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -74,7 +74,7 @@ const config = {
|
|
|
74
74
|
images: {
|
|
75
75
|
...originalConfig?.images,
|
|
76
76
|
loader: 'custom',
|
|
77
|
-
loaderFile: './.edgeone/
|
|
77
|
+
loaderFile: './.edgeone/image-loader.mjs',
|
|
78
78
|
},
|
|
79
79
|
};
|
|
80
80
|
|
|
@@ -89,18 +89,12 @@ module.exports = {
|
|
|
89
89
|
images: {
|
|
90
90
|
...resolved?.images,
|
|
91
91
|
loader: 'custom',
|
|
92
|
-
loaderFile: './.edgeone/
|
|
92
|
+
loaderFile: './.edgeone/image-loader.mjs',
|
|
93
93
|
},
|
|
94
94
|
};
|
|
95
95
|
`;
|
|
96
96
|
}
|
|
97
97
|
function injectImageLoader(cwd) {
|
|
98
|
-
const loaderDir = join(cwd, ".edgeone", "cloud-functions", "ssr-node");
|
|
99
|
-
if (!existsSync(loaderDir)) {
|
|
100
|
-
mkdirSync(loaderDir, { recursive: true });
|
|
101
|
-
}
|
|
102
|
-
const loaderPath = join(loaderDir, "image-loader.mjs");
|
|
103
|
-
writeFileSync(loaderPath, IMAGE_LOADER_CONTENT, "utf-8");
|
|
104
98
|
const config = findNextConfig(cwd);
|
|
105
99
|
if (!config) {
|
|
106
100
|
console.log("[opennext] next.config not found, skipping image loader injection");
|
|
@@ -111,6 +105,17 @@ function injectImageLoader(cwd) {
|
|
|
111
105
|
console.log("[opennext] images.loaderFile already configured, skipping injection");
|
|
112
106
|
return;
|
|
113
107
|
}
|
|
108
|
+
const contentWithoutComments = originalContent.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
109
|
+
if (/unoptimized\s*:\s*true/.test(contentWithoutComments)) {
|
|
110
|
+
console.log("[opennext] images.unoptimized detected, skipping image loader injection");
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const edgeoneDir = join(cwd, ".edgeone");
|
|
114
|
+
if (!existsSync(edgeoneDir)) {
|
|
115
|
+
mkdirSync(edgeoneDir, { recursive: true });
|
|
116
|
+
}
|
|
117
|
+
const loaderPath = join(edgeoneDir, "image-loader.mjs");
|
|
118
|
+
writeFileSync(loaderPath, IMAGE_LOADER_CONTENT, "utf-8");
|
|
114
119
|
const configDir = config.path.substring(0, config.path.lastIndexOf("/"));
|
|
115
120
|
const backupPath = join(configDir, `next.config.original${config.ext}`);
|
|
116
121
|
renameSync(config.path, backupPath);
|
|
@@ -125,6 +130,13 @@ function injectImageLoader(cwd) {
|
|
|
125
130
|
console.log("[opennext] Image optimization loader injected");
|
|
126
131
|
}
|
|
127
132
|
function restoreNextConfig(cwd) {
|
|
133
|
+
const loaderPath = join(cwd, ".edgeone", "image-loader.mjs");
|
|
134
|
+
if (existsSync(loaderPath)) {
|
|
135
|
+
try {
|
|
136
|
+
unlinkSync(loaderPath);
|
|
137
|
+
} catch {
|
|
138
|
+
}
|
|
139
|
+
}
|
|
128
140
|
const markerPath = getBackupMarker(cwd);
|
|
129
141
|
if (!existsSync(markerPath)) {
|
|
130
142
|
return;
|
|
@@ -28,7 +28,7 @@ module.exports = __toCommonJS(tags_handler_exports);
|
|
|
28
28
|
|
|
29
29
|
// package.json
|
|
30
30
|
var name = "@edgeone/opennextjs-pages";
|
|
31
|
-
var version = "0.2.
|
|
31
|
+
var version = "0.2.2";
|
|
32
32
|
|
|
33
33
|
// src/run/handlers/tags-handler.cts
|
|
34
34
|
var import_request_context = require("./request-context.cjs");
|