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.
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.
npx create-remix@latest
- Named
stencil-remix
- Remix App Server
- JavaScript
- Run
npm install
- Named
cd stencil-remix
- Downgrade
react
andreact-dom
from17.02
to16.7.0
due to output target peer deps npm i @esri/calcite-components-react
- 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>
...
npm run dev
- Open app in the browser
- 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
From your terminal:
npm run dev
This starts your app in development mode, rebuilding assets on file changes.
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.
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/
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