Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: RSpack + Lingui Example #1752

Merged
merged 8 commits into from
Aug 29, 2023

Conversation

Collinbrown95
Copy link
Contributor

@Collinbrown95 Collinbrown95 commented Aug 24, 2023

Description

Including example of integration between Rspack and Lingui-JS. Closes #1749.

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update

Fixes # (issue)

Checklist

  • I have read the CONTRIBUTING and CODE_OF_CONDUCT docs
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

@vercel
Copy link

vercel bot commented Aug 24, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
js-lingui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Aug 29, 2023 1:18pm

@Collinbrown95 Collinbrown95 changed the title RSpack + Lingui Example feat: RSpack + Lingui Example Aug 24, 2023
@github-actions
Copy link

github-actions bot commented Aug 24, 2023

size-limit report 📦

Path Size
./packages/core/dist/index.mjs 2.76 KB (0%)
./packages/detect-locale/dist/index.mjs 721 B (0%)
./packages/react/dist/index.mjs 2.21 KB (0%)
./packages/remote-loader/dist/index.mjs 7.24 KB (0%)

Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Collinbrown95 thanks a lot for the contribution!

Could you please also add a link to the project on the Examples page in the docs?

examples/rspack/README.md Outdated Show resolved Hide resolved
examples/rspack/rspack.config.js Outdated Show resolved Hide resolved
examples/rspack/src/locales/en/messages.d.ts Show resolved Hide resolved
examples/rspack/src/react-env.d.ts Outdated Show resolved Hide resolved
@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Patch and project coverage have no change.

Comparison is base (47d4fdb) 75.98% compared to head (2958b03) 75.98%.
Report is 1 commits behind head on main.

❗ Current head 2958b03 differs from pull request most recent head a7c936a. Consider uploading reports for the commit a7c936a to get more accurate results

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1752   +/-   ##
=======================================
  Coverage   75.98%   75.98%           
=======================================
  Files          81       81           
  Lines        2065     2065           
  Branches      530      530           
=======================================
  Hits         1569     1569           
  Misses        383      383           
  Partials      113      113           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Co-authored-by: Andrii Bodnar <andrii.bodnar@crowdin.com>
@Collinbrown95
Copy link
Contributor Author

@andrii-bodnar thanks for the feedback!

I've added the rspack example in this commit Collinbrown95@2958b03.

Please let me know if you'd like any additional changes 😄

Copy link
Contributor

@andrii-bodnar andrii-bodnar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Collinbrown95 looks good to me, thank you! 🚀

@andrii-bodnar andrii-bodnar merged commit 87ffe72 into lingui:main Aug 29, 2023
3 checks passed
@andrii-bodnar andrii-bodnar linked an issue Sep 6, 2023 that may be closed by this pull request
12 tasks
@timofei-iatsenko
Copy link
Collaborator

@Collinbrown95 hey, I just tried to run this example in the repo and it doesn't work. There are bunch of issues:

  1. No lockfile in the example folder, so Yarn will not execute yarn install there

  2. @rspack/cli": fixed with version "latest"

  3. Then It doesn't start because of Error: Cannot find module '@rspack/core'

  4. After installing it it shows

    Resolve error: Can't resolve './Inbox' in '/Users/tim/projects/js-lingui/examples/rspack/src'
    ╭─[5:1]
    5 │ import { messages as enMessages } from "./locales/en/messages";
    6 │ import { messages as frMessages } from "./locales/fr/messages";
    7 │ import Inbox from "./Inbox";
    · ─────────
    8 │ i18n.load({
    9 │ "en": enMessages,
    ╰────
    help: Found module './Inbox.tsx'. However, it's not possible to request this module without the extension
    if its extension was not listed in the resolve.extensions. Here're some possible solutions:

     1. add the extension `".tsx"` to `resolve.extensions` in your rspack configuration
     2. use './Inbox.tsx' instead of './Inbox'
    

    For every tsx / ts file
    I tried to fix it with this rspack config:

/**
 * @type {import('@rspack/cli').Configuration}
 */
module.exports = {
  context: __dirname,
  entry: {
    main: "./src/main.tsx",
  },
  resolve: {
    extensions: [".tsx", ".js", ".ts"],
  },
  builtins: {
    html: [
      {
        template: "./index.html",
      },
    ],
  },
  module: {
    rules: [
      {
        test: /\.svg$/,
        type: "asset",
      },
      {
        test: /\.tsx?$/,
        exclude: /node_modules/,
        use: {
          loader: "babel-loader",
          options: {
            presets: ["@babel/preset-typescript", "@babel/preset-react"],
            plugins: ["macros"],
          },
        },
      },
    ],
  },
}

But it still doesn't work. it starts without errors, but dev server returned an empty page.

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.

Examples upgrade RSpack Lingui Example
3 participants