-
Notifications
You must be signed in to change notification settings - Fork 7
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
Port from Batfish to Underreact #55
Conversation
Ok, after much flailing, I think this is ready to have its WIP tag removed. Tests are passing** and the page is rendering. ** tests are passing locally, but Travis is failing because it can't find |
Looks like I have been mistakingly publishing it as private. I have publicly published it now and things should be working fine. Sorry about that. |
.gitignore
Outdated
@@ -3,6 +3,7 @@ node_modules | |||
coverage | |||
.DS_Store | |||
_batfish* | |||
_underreact-site |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's upgrade to the latest version of Underreact, in which case this will be _site
.
.gitignore
Outdated
@@ -3,6 +3,7 @@ node_modules | |||
coverage | |||
.DS_Store | |||
_batfish* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we delete this line?
src/index.js
Outdated
@@ -0,0 +1,8 @@ | |||
import React from 'react'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If this file is specific to docs, lets put it in src/docs
.
underreact.config.js
Outdated
@@ -0,0 +1,11 @@ | |||
'use strict'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this for the docs or the test cases? Let's run both with Underreact.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@davidtheclark I'm not totally clear on how we would use Underreact for both the docs and the test-cases app in the same project.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Have you looked at how each app works now, without Underreact? That would be the place to start.
Underreact commands have a --config
option that you can use in order to store two different configs in one repo and run them in different Underreact processes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To give an example here is a package.json using an explicit config:
Looks like this might be a great place to enable hot reloading feature of Underreact 🔥. We can either add it in this PR or I can send another PR to specifically enable it. |
I've done some reorganizing here that I hope will make the project easier to maintain:
|
@danswick this was an interesting bug. I found that the bug is with the way we are using the basePath as We can probably send a fix to Some notes on the bug hunt 👨🚒 :
|
Yes, definitely. |
Wow, thanks for tracking that down, @kepta! I can reorganize the structure for sure. The reason I changed it in the first place was that I found it confusing to have two web apps that reference the component source, but the component source lives alongside just one of the apps. So I separated everything just to help conceptualize which parts were interacting with what. I can totally see how the diff would be hard to make sense of in this state. |
I don't think I understand the confusion here. We have |
Thanks for all of the feedback, @kepta and @davidtheclark. I went ahead and fixed up the project structure, swapped the test cases app to a |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fantastic, @danswick. I tried it out locally and had no problems at all. Seems like you got it 👍 🍕
.artifacts.yml
Outdated
@@ -0,0 +1,3 @@ | |||
version: v1 | |||
defaults: | |||
- publisher |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mr UI isn't currently being published with Publisher, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh yowza. I just got into Underreact robot mode and put this here automatically. I can remove.
.eslintignore
Outdated
@@ -6,3 +6,5 @@ src/docs/data | |||
pkg | |||
src/test-cases-app/component-index.js | |||
dist | |||
*underreact.config.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be **/underreact.config.js
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It works this way, but **/*underreact.config.js
is more precise.
@@ -6,3 +6,5 @@ src/docs/data | |||
pkg | |||
src/test-cases-app/component-index.js | |||
dist | |||
*underreact.config.js | |||
html.js |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, we shouldn't need to do this. But I don't want to clog up the PR for linting. Let's sort it out after the merge. (Hint: I think we'll use ESLint's overrides
option.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good 👍
scripts/build-module-indexes.js
Outdated
@@ -5,9 +5,8 @@ require('hard-rejection/register'); | |||
const fs = require('fs'); | |||
const path = require('path'); | |||
const pify = require('pify'); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👹
scripts/build-module-indexes.js
Outdated
const excludeDirs = new Set(['utils']); | ||
const srcRoot = path.resolve(__dirname, '../src/components'); | ||
const srcRoot = path.resolve(__dirname, '../src/components/'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👹
(This change shouldn't make any difference, right?)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👺
src/docs/docs-underreact.config.js
Outdated
|
||
module.exports = () => { | ||
return { | ||
siteBasePath: '/mr-ui/docs', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The true base path is just /mr-ui
, right? https://mapbox.github.io/mr-ui/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, yep! This is a gremlin from when I was trying to give docs
and test-cases-app
their own base paths under mr-ui
😬
src/test-cases-app/html.js
Outdated
<meta charset='utf-8'> | ||
<meta name='viewport' content='width=device-width, initial-scale=1'> | ||
<link href="https://api.mapbox.com/mapbox-assembly/mbx/v0.26.0/assembly.min.css" rel="stylesheet"> | ||
<script async src="https://api.mapbox.com/mapbox-assembly/mbx/v0.26.0/assembly.js"></script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 it's suspicious to me that we have different version of Assembly in the test cases and docs. Are you copying a mistake already in place, or is this a typo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See https://github.com/mapbox/frontend-platform-team/issues/32. For sites like this one, which do not need to generate multiple HTML files, @mapbox/frontend-platform has a new favored tool: Underreact. It's significantly simpler than Batfish, and is using the latest, fastest versions of Webpack and Babel — so it's the better choice for any sites that don't need Batfish's HTML generation.
A few notes about the changes in this PR:
<link>
and<script>
tags in the HTML to load mbx-assembly.app.js
component is just the content of the oldsrc/docs/app.js
.browserslist: ['defaults']
means Underreact won't bother building for IE11, because this is an internal site (that should speed things up).Object:
type here and I'm not familiar enough with Babel to configure my way around that issue, so I just removed it.Next steps:
@davidtheclark: I would love to talk through this a bit with you tomorrow. I am a bit fuzzy on what's going on with the Babel 7 updates I made here and I am still not entirely sure why the page isn't being rendered.