question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Is this a bug report?

I’m not sure if this is a bug in create-react-app, a bug in my macro, or if this is the intended behavior.

Did you try recovering your dependencies?

This occurs in a fresh build using yarn version 1.9.4. I’ve tried with react-scripts 2.0.5 and 2.0.0

Environment

Environment Info:

System: OS: macOS 10.14 CPU: x64 Intel® Core™ i7-4850HQ CPU @ 2.30GHz Binaries: Node: 10.10.0 - /usr/local/bin/node Yarn: 1.9.4 - /usr/local/bin/yarn npm: 6.4.1 - /usr/local/bin/npm Browsers: Chrome: 70.0.3538.77 Firefox: 62.0.3 Safari: 12.0 npmPackages: react: ^16.6.0 => 16.6.0 react-dom: ^16.6.0 => 16.6.0 react-scripts: ^2.0.5 => 2.0.5 npmGlobalPackages: create-react-app: 2.0.4

Steps to Reproduce

To make the changes from a fresh create-react-app install:

  1. yarn add mdx.macro (see the package source)
  2. Create a markdown document with some content in src/test.mdx
# Hello, world
  1. replace App.js with:
import { mdx, importMDX } from 'mdx.macro';
import React, { Component } from 'react';
const App = importMDX.sync('./test.mdx')
export default App;

Expected Behavior

  1. I’d expect the content to show up on initial load, instead of needing to refresh the page manually.
  2. According to https://github.com/facebook/create-react-app/pull/5078 and https://github.com/kentcdodds/babel-plugin-macros/pull/83, I would have expected the macro to be re-called on each build, but this doesn’t appear to happen unless I actually edit the App.js file that calls the macro.

Actual Behavior

  1. When the browser loads localhost:3000 after executing yarn start, it shows a blank page. Hit refresh and the content appears.
  2. When you edit the content of test.mdx, the page refreshes (as the macro adds an import for the test.mdx file). However, the macro is not called again, so the old content is displayed.

Reproducible Demo

https://github.com/jamesknelson/mdx-cra-demo

Thoughts

I’m pretty out of my depth here, but I don’t think the babel cache is the problem. I’ve tried cleaning the cache manually (rm node_modules/.cache/babel-loader/*) and then editing the markdown file. When I do, the page reloads, but the cache directory stays empty.

I think it’s webpack itself that’s deciding not to pass the App.js file through any loaders.

The macro follows the pattern mentioned by @kentcdodds where it creates a temporary file and imports that. The generated file then imports the original MDX file so that webpack will notice changes and rebuild (but only in development mode – don’t worry).

Would love to hear any ideas for getting this working, as being able to use MDX files without ejecting would be 👌, but no refresh-on-change is a bit of a deal breaker.

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:25
  • Comments:21 (5 by maintainers)

github_iconTop GitHub Comments

10reactions
martuanezcommented, Mar 23, 2020

I think the ability to add file watchers based on file type is the minimum desirable funcionality, right?

7reactions
nik-lampecommented, Dec 17, 2019

As a workaround: If you save the file where you import the graphl file, it will be reloaded. Just add a line somewhere and have prettier active. Using VS Code Prettier will remove the line anyway but saving the file will trigger the reload and this will also reload the graphql file.

Not nice, because you have to edit two files, but better than restarting the script 😃

Read more comments on GitHub >

github_iconTop Results From Across the Web

MACRO reload | WoWWiki - Fandom
MACRO reload. Macrose · Useful macros · Macro commands. General guides. Beginner's guide · FAQs · Making a macro · Wiki Formatting ·...
Read more >
Create an Excel Macro (using VBA) to automatically refresh ...
In this Excel tutorial, I will be walk you through how to write a simple macro using Excel VBA to automatically refresh stock...
Read more >
Reload macros without reloading everything else?
Is there a way to reload JUST the “macros-cache.txt” file? I know I can do a “/reload” command to reload all the ui,...
Read more >
Using the LOAD macro - IBM
Using the LOAD macro · subpool 244 only when within a task that was created by ATTACHX with the KEY=NINE parameter · subpool...
Read more >
Reloading and Rebinding | PyXLL User Guide
Programmatic Reloading ¶. It is possible to reload PyXLL programmatically via the Python function reload or by calling the Excel macro pyxll_reload ....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found