Giter Club home page Giter Club logo

modern-js-examples's Introduction

Modern.js Examples

Examples for Modern.js.

Examples

Here are some examples you can refer to:

React App

  • basic-app: Basic Modern.js App using React 18, TypeScript, Rspack and nested routes.
  • runtime-api: Sample code for the Modern.js Runtime API.

Modern.js Module

  • basic-module: Basic Modern.js Module using esbuild, TypeScript and changeset.

Module Federation Example

Modern.js provides an example project for Module Federation. Please refer to module-federation-examples - modernjs.

Vue App

Please use Rsbuild to build Vue applications.

modern-js-examples's People

Contributors

9aoy avatar anc95 avatar caohuilin avatar chenjiahan avatar giveme-a-name avatar hxykjc avatar rqzheng2015 avatar targeral avatar tqma113 avatar xuchaobei avatar zllkjc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

modern-js-examples's Issues

The micro-frontend example can't run correctly.

  1. cd to micro-frontend/main
  2. pnpm i
  3. pnpm dev
  4. error pops up

System Info

System:
  OS: Windows 10 10.0.16299
  CPU: (8) x64 Intel(R) Core(TM) i7-7700K CPU @ 4.20GHz
  Memory: 17.32 GB / 31.94 GB
Binaries:
  Node: 14.17.6 - D:\Programs\nodejs\node.EXE
  Yarn: 1.22.11 - G:\nodejs\npm_global_modules\yarn.CMD

Used Package Manager
pnpm

Logs

$ modern dev
 > error: The entry point "D:/study/modern-js-micro-frontend/main/modern.config.js" cannot be marked as external

You should not use <Switch> outside a <Router>

Following tutorials/c8, I've got this error.

SSR Error - App Prefetch error = Error: Invariant failed: You should not use <Switch> outside a <Router>
    at invariant (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:22743:11)
    at Object.children (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:20919:19)
    at ReactDOMServerRenderer.render (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3972:55)
    at ReactDOMServerRenderer.read (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at renderToStaticMarkup (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2635:36
    at AsyncLocalStorage.run (async_hooks.js:303:14)
    at run (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2494:40)
    at prefetch (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2632:56)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2578:81
SSR Error - App Prefetch error = Error: Invariant failed: You should not use <Switch> outside a <Router>
    at invariant (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:22743:11)
    at Object.children (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:20919:19)
    at ReactDOMServerRenderer.render (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3972:55)
    at ReactDOMServerRenderer.read (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at renderToStaticMarkup (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2635:36
    at AsyncLocalStorage.run (async_hooks.js:303:14)
    at run (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2494:40)
    at prefetch (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2632:56)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2578:81
SSR Error - App Prefetch error = Error: Invariant failed: You should not use <Switch> outside a <Router>
    at invariant (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:22743:11)
    at Object.children (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:20919:19)
    at ReactDOMServerRenderer.render (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3972:55)
    at ReactDOMServerRenderer.read (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at renderToStaticMarkup (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2635:36
    at AsyncLocalStorage.run (async_hooks.js:303:14)
    at run (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2494:40)
    at prefetch (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2632:56)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2578:81
SSR Error - App Prefetch error = Error: Invariant failed: You should not use <Switch> outside a <Router>
    at invariant (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:22743:11)
    at Object.children (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:20919:19)
    at ReactDOMServerRenderer.render (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3972:55)
    at ReactDOMServerRenderer.read (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:3690:29)
    at renderToStaticMarkup (/Volumes/Common/code/opensource/hello-modern/node_modules/.pnpm/[email protected][email protected]/node_modules/react-dom/cjs/react-dom-server.node.development.js:4314:27)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2635:36
    at AsyncLocalStorage.run (async_hooks.js:303:14)
    at run (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2494:40)
    at prefetch (/Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2632:56)
    at /Volumes/Common/code/opensource/hello-modern/dist/bundles/contacts.js:2578:81

Example code src/contacts/App.tsx

function App() {
  return (
    <div className="container lg mx-auto">
      <Switch>
        <Route path="/" exact={true}>
          <Helmet>
            <title>All</title>
          </Helmet>
          <List
            dataSource={mockData}
            renderItem={info => <Item key={info.name} info={info} />}
          />
        </Route>
        <Route path="/archives" exact={true}>
          <Helmet>
            <title>Archives</title>
          </Helmet>
          <List
            dataSource={mockArchivedData}
            renderItem={info => <Item key={info.name} info={info} />}
          />
        </Route>
      </Switch>
    </div>
  );
}

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.