Skip to content

Commit 074e937

Browse files
authored
Merge pull request #7 from sst/main
Sync upstream for windows support
2 parents e951bcc + 7beaf82 commit 074e937

File tree

6 files changed

+23
-5
lines changed

6 files changed

+23
-5
lines changed

.changeset/popular-kids-beam.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
[windows] Add Windows compatibility for the `resolve` ESBuild plugin

.changeset/shy-cups-notice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
[windows] Add Windows compatibility for the `replacement` ESBuild plugin

.changeset/witty-dots-film.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"open-next": patch
3+
---
4+
5+
[windows] Specify the `file://` protocol when importing config on Windows

packages/open-next/src/build.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,13 @@ export async function build(
5050

5151
// Load open-next.config.ts
5252
const tempDir = initTempDir();
53-
const configPath = compileOpenNextConfigNode(
53+
let configPath = compileOpenNextConfigNode(
5454
tempDir,
5555
openNextConfigPath,
5656
nodeExternals,
5757
);
58+
// On Windows, we need to use file:// protocol to load the config file using import()
59+
if (process.platform === "win32") configPath = `file://${configPath}`;
5860
config = (await import(configPath)).default as OpenNextConfig;
5961
validateConfig(config);
6062

@@ -333,7 +335,8 @@ async function createImageOptimizationBundle(config: OpenNextConfig) {
333335
plugins.push(
334336
openNextReplacementPlugin({
335337
name: "opennext-14.1.1-image-optimization",
336-
target: /plugins\/image-optimization\/image-optimization\.js/g,
338+
target:
339+
/plugins(\/|\\)image-optimization(\/|\\)image-optimization\.js/g,
337340
replacements: [
338341
require.resolve(
339342
"./adapters/plugins/image-optimization/image-optimization.replacement.js",

packages/open-next/src/build/createServerBundle.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,7 @@ async function generateBundle(
207207
const plugins = [
208208
openNextReplacementPlugin({
209209
name: `requestHandlerOverride ${name}`,
210-
target: /core\/requestHandler.js/g,
210+
target: /core(\/|\\)requestHandler\.js/g,
211211
deletes: disableNextPrebundledReact ? ["applyNextjsPrebundledReact"] : [],
212212
replacements: disableRouting
213213
? [
@@ -219,7 +219,7 @@ async function generateBundle(
219219
}),
220220
openNextReplacementPlugin({
221221
name: `utilOverride ${name}`,
222-
target: /core\/util.js/g,
222+
target: /core(\/|\\)util\.js/g,
223223
deletes: [
224224
...(disableNextPrebundledReact ? ["requireHooks"] : []),
225225
...(disableRouting ? ["trustHostHeader"] : []),

packages/open-next/src/plugins/resolve.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ export function openNextResolvePlugin({
4444
name: "opennext-resolve",
4545
setup(build) {
4646
logger.debug(`OpenNext Resolve plugin for ${fnName}`);
47-
build.onLoad({ filter: /core\/resolve.js/g }, async (args) => {
47+
build.onLoad({ filter: /core(\/|\\)resolve\.js/g }, async (args) => {
4848
let contents = readFileSync(args.path, "utf-8");
4949
//TODO: refactor this. Every override should be at the same place so we can generate this dynamically
5050
if (overrides?.wrapper) {

0 commit comments

Comments
 (0)