Skip to content

Commit

Permalink
Vicb (#2)
Browse files Browse the repository at this point in the history
worker assets
  • Loading branch information
petebacondarwin authored Sep 12, 2024
1 parent b439dfe commit 7d8ce35
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 15 deletions.
8 changes: 4 additions & 4 deletions TODO.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

- wrangler alias
- move the wrangler.toml to the templates
- figure out the assets
- dependency graph

DONE:

- figure out the assets
- copy the template folders

## Install:
Expand All @@ -32,7 +32,7 @@ export default nextConfig;

- add "node-url": "npm:url@^0.11.4" to the package.json

- add a wrangler.tom int the generated app
- add a wrangler.toml int the generated app

```
#:schema node_modules/wrangler/config-schema.json
Expand Down Expand Up @@ -66,11 +66,11 @@ pnpm --filter builder build:watch
Build the next app once:

```
node /path/to/poc-next/builder/dist/index.mjs && wrangler dev
node /path/to/poc-next/builder/dist/index.mjs && npx wrangler dev
```

Then you can skip building the next app

```
SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/builder/dist/index.mjs && wrangler dev
SKIP_NEXT_APP_BUILD=1 node /path/to/poc-next/builder/dist/index.mjs && npx wrangler dev
```
2 changes: 1 addition & 1 deletion builder/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@
"tsup": "^8.2.4",
"typescript": "^5.5.4"
}
}
}
12 changes: 8 additions & 4 deletions builder/src/build/build-worker/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,13 @@ export async function buildWorker(
updateWebpackChunksFile(nextjsAppPaths);

console.log(`\x1b[35m⚙️ Copying asset files...\n\x1b[0m`);
await cp(`${nextjsAppPaths.dotNextDir}/static`, `${outputDir}/assets/_next`, {
recursive: true,
});
await cp(
`${nextjsAppPaths.dotNextDir}/static`,
`${outputDir}/assets/_next/static`,
{
recursive: true,
}
);

console.log(`\x1b[35mWorker saved in \`${workerOutputFile}\` 🚀\n\x1b[0m`);
}
Expand Down Expand Up @@ -187,4 +191,4 @@ function createFixRequiresESBuildPlugin(templateDir: string): Plugin {
}));
},
};
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* Hopefully this should not be necessary after this unenv PR lands: https://github.com/unjs/unenv/pull/292
*/
export function patchUrl(code: string): string {
console.log("# patchUrl");
console.log("# patchUrl");
return code.replace(
/ ([a-zA-Z0-9_]+) = require\("url"\);/g,
` $1 = require("url");
Expand Down
8 changes: 4 additions & 4 deletions builder/src/build/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ export async function build(
if (!opts.skipBuild) {
// Build the next app and save a copy in .save.next
buildNextjsApp(inputNextAppDir);
rmSync(`${inputNextAppDir}/${SAVE_DIR}`, {
recursive: true,
force: true,
});
rmSync(`${inputNextAppDir}/${SAVE_DIR}`, {
recursive: true,
force: true,
});
cpSync(`${inputNextAppDir}/.next`, `${inputNextAppDir}/${SAVE_DIR}`, {
recursive: true,
});
Expand Down
2 changes: 1 addition & 1 deletion next/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@
"node-url": "npm:url@^0.11.4",
"wrangler": "3.76.0"
}
}
}

0 comments on commit 7d8ce35

Please sign in to comment.