Code Monkey home page Code Monkey logo

stencil-remix's Introduction

Stencil Remix

Repro case for ionic-team/stencil-ds-output-targets#226

I haven't tried to transpile the modules with babel yet, if I get it working I'll add another branch and update this readme. Remix is an SSR framework so, even after transpiling, there will likely be additional complications using web components, which rely on browser APIs.

Update

Remix does not support pre-rendering at this time, but they have an open issue discussing it. Go give it a thumbs up!

I was able to get the components to render on the client and put an example on the fix branch. However, you might as well use CRA if you can't render your UI on the server or during build. The better option is to use NextJS or another framework that supports pre-rendering until Remix does too.

Issue Repro Setup/Steps

  1. npx create-remix@latest
    • Named stencil-remix
    • Remix App Server
    • JavaScript
    • Run npm install
  2. cd stencil-remix
  3. Downgrade react and react-dom from 17.02 to 16.7.0 due to output target peer deps
  4. npm i @esri/calcite-components-react
  5. Add stencil code to app/routes/index.jsx:
+ import { setAssetPath } from "@esri/calcite-components/dist/components";
+ import "@esri/calcite-components/dist/components/calcite-button.js";
+ import { CalciteButton } from "@esri/calcite-components-react";
+ import styles from "@esri/calcite-components/dist/calcite/calcite.css";
+ setAssetPath("https://js.arcgis.com/calcite-components/1.0.0-beta.76/assets");

+ export function links() {
+   return [{ rel: "stylesheet", href: styles }];
+ }

export default function Index() {
  return (
    <div style={{ fontFamily: "system-ui, sans-serif", lineHeight: "1.4" }}>
      <h1>Welcome to Remix</h1>
+     <CalciteButton>Test</CalciteButton>
      <ul>
   ...
  1. npm run dev
  2. Open app in the browser
  3. Error:
export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
^^^^^^

SyntaxError: Unexpected token 'export'
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1031:15)
    at Module._compile (node:internal/modules/cjs/loader:1065:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/ben/dev/stencil-remix/build/index.js:408:36)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
GET / 500 - - 29.345 ms

Welcome to Remix!

Development

From your terminal:

npm run dev

This starts your app in development mode, rebuilding assets on file changes.

Deployment

First, build your app for production:

npm run build

Then run the app in production mode:

npm start

Now you'll need to pick a host to deploy it to.

DIY

If you're familiar with deploying node applications, the built-in Remix app server is production-ready.

Make sure to deploy the output of remix build

  • build/
  • public/build/

Using a Template

When you ran npx create-remix@latest there were a few choices for hosting. You can run that again to create a new project, then copy over your app/ folder to the new project that's pre-configured for your target server.

cd ..
# create a new project, and pick a pre-configured host
npx create-remix@latest
cd my-new-remix-app
# remove the new project's app (not the old one!)
rm -rf app
# copy your app over
cp -R ../my-old-remix-app/app app

stencil-remix's People

Contributors

benelan avatar

Watchers

 avatar

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.