Skip to content

Conversation

@hi-ogawa
Copy link
Owner

@hi-ogawa hi-ogawa commented Jan 27, 2025

issues

pnpm i
pnpm build
pnpm -C packages/react-server/examples/next build
  • next/og fails
  • prerenderPlugin fails
    • due to chunking difference from rollup, virtual:react-server-build's resolveId: { id: "../rsc/index.js", external: true } needs to be adjusted?
    • this should be fixed on my side.
  • async local storage global broken packages/react-server/examples/basic
    • probably import side effect related? execution order?
    • this is also due to chunking difference and the bug would've also happened on rollup. this should be fixed on my plugin side.
  5 failed
    [chromium] › basic.test.ts:1017:1 › action context @js ─────────────────────────────────────────
    [chromium] › basic.test.ts:1023:1 › action context @nojs ───────────────────────────────────────
    [chromium] › basic.test.ts:1335:1 › React.cache @js ────────────────────────────────────────────
    [chromium] › basic.test.ts:1339:1 › React.cache @nojs ──────────────────────────────────────────
    [chromium] › basic.test.ts:1483:1 › cookies api route ──────────────────────────────────────────

todo

@hi-ogawa hi-ogawa changed the title test rolldon-vite test rolldown-vite Jan 27, 2025
github-merge-queue bot pushed a commit to rolldown/rolldown that referenced this pull request Jan 29, 2025
### Description

I added a fake "deprecated" type to reduce a churn due to ecosystem
failing by ts error (see
https://github.com/vitejs/vite-ecosystem-ci/blob/rolldown-vite/README-temp.md
and also my plugin hit by this too
hi-ogawa/vite-plugins#673).

As I wrote in
#3337 (comment),
Rolldown's plugin hook always works same as rollup's `sequential: true`
and this behavior is likely good for the ecosystem since people mostly
needed `sequential: true` to avoid running `writeBundle` hooks in
parallel on rollup.

I think the test added in #1913
already verifies such sequential behavior.
@hi-ogawa hi-ogawa force-pushed the test-rolldown-vite branch 3 times, most recently from 1842054 to f57e5c7 Compare February 3, 2025 09:59
hi-ogawa added a commit that referenced this pull request Feb 4, 2025
@hi-ogawa hi-ogawa mentioned this pull request Feb 4, 2025
hi-ogawa added a commit that referenced this pull request Feb 4, 2025
github-merge-queue bot pushed a commit to rolldown/rolldown that referenced this pull request Feb 5, 2025
### Description

Reviving #1928. I came across
`import.meta.url.ROLLUP_FILE_URL_xxx` in one of my plugins
(hi-ogawa/vite-plugins#673) and I think having
the compat in rolldown is nice to have (though it's also possible to
have a compat in rolldown-vite or user land level via a custom plugin's
`renderChunk` replacing).

Sapphi also mentioned that Astro uses this feature
#819 (comment).
I'm hoping the complexity required on rolldown side is low and it's
worth the inclusion. Let me know what you think.

<details><summary>Example user-land plugin to replace
"import.meta.ROLLUP_FILE_URL_xxx"</summary>

From hi-ogawa/vite-plugins#673

```js
import path from "node:path";
import MagicString from "magic-string";
import type { Plugin } from "vite";

// import.meta.ROLLUP_FILE_URL_xxx on rolldown
// #1928
export function rolldownPluginRollupFileUrl(): Plugin {
  return {
    name: rolldownPluginRollupFileUrl.name,
    renderChunk: {
      order: "pre",
      handler(code, chunk) {
        if (!code.includes("import.meta.ROLLUP_FILE_URL_")) {
          return;
        }
        const matches = code.matchAll(/import.meta.ROLLUP_FILE_URL_(\w+)/dg);
        const output = new MagicString(code);
        for (const match of matches) {
          const referenceId = match[1]!;
          const assetFileName = this.getFileName(referenceId);
          const relativePath =
            "./" +
            path.relative(
              path.resolve(chunk.fileName, ".."),
              path.resolve(assetFileName),
            );
          const replacement = `new URL(${JSON.stringify(relativePath)}, import.meta.url)`;
          const [start, end] = match.indices![0]!;
          output.update(start, end, replacement);
        }
        if (output.hasChanged()) {
          return {
            code: output.toString(),
            map: output.generateMap({ hires: "boundary" }),
          };
        }
        return;
      },
    },
  };
}
```

</details>
@hi-ogawa hi-ogawa changed the title test rolldown-vite feat: support rolldown-vite Feb 20, 2025
@hi-ogawa hi-ogawa changed the title feat: support rolldown-vite test: test rolldown-vite Feb 20, 2025
@hi-ogawa
Copy link
Owner Author

@hi-ogawa hi-ogawa closed this Jun 11, 2025
@hi-ogawa hi-ogawa deleted the test-rolldown-vite branch June 11, 2025 06:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants