Help

Renaming and moving files breaks block run

Topic Labels: Custom Extensions
2318 5
cancel
Showing results for 
Search instead for 
Did you mean: 
Ronen_Babayoff
7 - App Architect
7 - App Architect

Hey,

Every time I’m renaming or moving a typescript file, I get the following error in block run:

Bundle Error: Cannot find module './OldFileName' from '/home/user/superblocks/my-block/build/development/transpiled/user/frontend'

The only way I found that makes block run work again (if I don’t want to rename or move the file back) is to delete the build folder, the block node_modules folder, uninstall the blocks-cli and today I also had to run npm cache clean --force.

I’m guessing it has something to do with the typescript or babel transpilation process that keeps previously transpiled files around in a cache.

Questions:

  1. Is there a way to rename or move files without breaking block run?

  2. If not, is there a more time efficient way to fix this after it breaks? Someway to efficiently clear the relevant cache without having to uninstall and clear everything npm?

Thanks,
Ronen Babayoff
Superblocks.at

5 Replies 5

Hi Ronen, sorry you’re running into this.

  • Can you share what OS you’re using to develop blocks?
  • To confirm, this only happens with .ts typescript files, but it doesn’t happen with .js files?

Hey Kasra,

Sorry, I assumed it’s a known issue, since it happened to me on 2 different OSs (Ubuntu and WSL). But it’s not an OS issue - I tried to reproduce it with a new clean typescript block (which I should have done in the first place), and a similar config to mine and wasn’t able to. Once I’ll figure out how to reproduce it, I’ll let you know.

Regarding js files, yes, it only happens with ts/tsx files, not js files, in the block in question.

Any clue into which cache I can clear and it’s location, instead of uninstalling stuff?

Thanks,
Ronen

@Kasra - updates:

  1. I thought it was because I have files outside of frontend, but it started happening to me in a block where there are no files outside of frontend.

  2. Now it happened to me after renaming an internal package the block depends on, and nothing that I do seems to fix the bundling error. This is the error:

Bundle Error: Cannot find module ‘@superblocks/lib-package’ from ‘/…/example-block/build/development/transpiled/user/frontend’

I’m trying to avoid re-cloning my repo or reinstalling my dev env every time this happens, which is quite frequent.

Since deleting the build folder doesn’t work,it looks like some tool is maintaining metadata about the folders and files that should be transpiled / bundled, which is not updated when files are renamed.

So repeating my question - which cache of which tool is creating this problem and how can I clear it, since it’s clear the cached data that creates the problem is not maintained in the build folder.

Awaiting your answer,
Ronen

Richard_Sinn
Airtable Employee
Airtable Employee

Hi @Ronen_Babayoff - we just released a new version of the CLI (version 0.0.52) that might resolve your renaming/moving files issue. Could you try updating to the latest version and see if that resolves your issue?

Thanks!

Hey @Richard_Sinn, updated to latest version, and yes, it solved the issue. That is going to have a really nice boosting effect on my productivity. Thanks! :pray: