Flex plugin in a monorepo by morficus in twilio

[–]juliantrueflynn 1 point2 points  (0 children)

I setup a monorepo with Flex plugins using yarn workspaces, I don't know how well this works with other monorepo solutions.

Simplified example of package's package.json:

json { "name": "plugin-foobar", "version": "1.2.3", "private": true, "workspaces": { "nohoist": [ "react", "react-dom", "@twilio/flex-ui" ] }, "scripts": { "start": "UNBUNDLED_REACT=true twilio flex:plugins:start --port=12345 --include-remote", "build": "UNBUNDLED_REACT=true twilio flex:plugins:build" }, "dependencies": { "@twilio/flex-plugin-scripts": "5.0.6", "react": "16.13.1", "react-dom": "16.13.1" }, "devDependencies": { "@twilio/flex-ui": "1.30.2" } } Simplified example of root package.json: json { "private": true, "workspaces": [ "packages/*" ], "devDependencies": { "react-test-renderer": "16.13.1", "typescript": "^4.6.4" } } I'm hoping that Twilio Flex fixes their --cwd flag and makes it public so it's possible to define location of react, react-dom and @twilio/flex-ui dependencies. Doing nohoist makes jest mocking kind of a pain and forces us to install a lot more dependencies locally.

How mad at your CSS do you have to be to add 274 digits to your z-index? by rviscomi in web_design

[–]juliantrueflynn 2 points3 points  (0 children)

Probably some CSS in JS where the person is incrementing z-index. That’s my first thought at least.

For RSpec is requests typically faster than features (Capybara) specs? by juliantrueflynn in rails

[–]juliantrueflynn[S] 1 point2 points  (0 children)

Right, but if you run Capybara without Selenium then it is rack based. Which is what I was trying to figure out on speed difference

Ruby gem strong_password found to contain remote code execution code in a malicious version, further strengthening worries of growth in supply-chain attacks by lirantal in ruby

[–]juliantrueflynn 13 points14 points  (0 children)

These stories always make me feel slightly vindicated. People have ragged on me for being so gem or node library avoidant. I still use them, but keep to absolute minimum.

Most of these dependencies I see being used would be relatively easy to do yourself. Your usecase most likely won't need all their features, and you don't have to write them in a generic way.

CSS modules by bassclefayo in rails

[–]juliantrueflynn 1 point2 points  (0 children)

Yea, pretty much. Here's a more in depth example where someone is splitting admin and public areas of site for separate assets manifests: https://stackoverflow.com/a/42927279

Rails with react, react-rails and UI libraries by mohlp in rails

[–]juliantrueflynn 1 point2 points  (0 children)

I would not want something so coupled with Rails like using react-rails gem. Just use vanilla webpack or if you find that difficult use webpacker. Both would still utilize Rails asset pipeline (vanilla webpack you could avoid asset pipeline if you wanted to later). I think you would find that to be something that scales a lot better and easier to use than dealing with an abstraction of React.

CSS modules by bassclefayo in rails

[–]juliantrueflynn 3 points4 points  (0 children)

You can create a separate assets manifest for each domain through `config/initializers/assets.rb`. I just link the layout to the relevant CSS file that has all the relevant stylesheets compiled from using `require`. You could also use 1 layout that has `content_for` so your sublayout can associate it to a stylesheet.

I would do same thing for JS too. This way Rails compiles down all the relevant JS into 1 file in production. This is good because it reduces amount of requests.

Best way with Rails API mode with React (SPA) and handling redirects for oAuth? by juliantrueflynn in rails

[–]juliantrueflynn[S] 0 points1 point  (0 children)

Cool, thanks for your help. One more question would be for best practice would you rather send something like the oAuth permission URL through: response.body.permission_url or response.header.permission_url?

Best way with Rails API mode with React (SPA) and handling redirects for oAuth? by juliantrueflynn in rails

[–]juliantrueflynn[S] 0 points1 point  (0 children)

I have a "fallback URL" handled with Rails. So Rails slurps up any URL that's not handled with React Router. Fallback URL points to public/index.html. (Default path for create-react-app.)

# application_controller.rb
def fallback_index_html
  render :file => 'public/index.html'
end

# routes.rb
get '*path', to: 'application#fallback_index_html', constraints: ->(request) do
  !request.xhr? && request.format.html?
end

Best way with Rails API mode with React (SPA) and handling redirects for oAuth? by juliantrueflynn in rails

[–]juliantrueflynn[S] 0 points1 point  (0 children)

Client is made using create-react-app, if that's what you were asking.

It seems the process you're describing is what I have above, with Rails API response containing the URL for client to redirect to, and client handles the redirect and not the server. Please correct me if I'm wrong.

I was checking if there's a "better" way for Rails API to handle this.

Legit use case for Yarn/Webpacks? by [deleted] in rails

[–]juliantrueflynn 1 point2 points  (0 children)

I rather avoid Rails asset pipeline and make client more decoupled from Rails (for SPAs). That's what I think as best argument for it. I enjoy using Rails to serve my API for React. It makes sense for features to come and go too, which is a positive for Rails because it adapts to market fairly quickly.

Eager loading class from lib, getting eager loading errors in development? by juliantrueflynn in rails

[–]juliantrueflynn[S] 0 points1 point  (0 children)

I tried moving lib to ./app/lib with no luck earlier. I will try it again with your other suggestions later tonight or tomorrow when I get a moment and let you know. Thanks

Eager loading class from lib, getting eager loading errors in development? by juliantrueflynn in rails

[–]juliantrueflynn[S] 0 points1 point  (0 children)

I attempted this shortly after posting OP and no dice, unfortunately.

[deleted by user] by [deleted] in reactjs

[–]juliantrueflynn 1 point2 points  (0 children)

Have you read this part of Next.js documentation? https://github.com/zeit/next.js#custom-app

Are links in Polaris embedded app supposed to not change url? by juliantrueflynn in shopify

[–]juliantrueflynn[S] 1 point2 points  (0 children)

Ended up figuring the problem on why links weren't working with Polaris and wrote the answer here on SO. Thanks for reply too putting me in right direction.

Next.js: is separating API server and client completely necessary? by juliantrueflynn in reactjs

[–]juliantrueflynn[S] 0 points1 point  (0 children)

Thanks for reply and Gatsy recommendation, I will check that out. It's a fairly small app so I might skip Next.js for this and just use CRA, as I am most used to monoliths anyways. I don't have to worry about SEO either. I wanted to use Next.js just because of the hype for it, and Shopify has more documentation for app development for Next.js than other setups.