Transcrypt
Transcrypt copied to clipboard
Parcel instructions do not work: Error: Cannot find module 'parcel-bundler/src/Logger'
I'm not a parcel expert, but my best guess is that you're importing a deprecated module in parcel?
Error: Cannot find module 'parcel-bundler/src/Logger'
at Function.Module._resolveFilename (module.js:547:15)
at Function.Module._load (module.js:474:25)
at Module.require (module.js:596:17)
at require (/usr/local/lib/node_modules/parcel-bundler/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/home/kkinder/Projects/parcel-exp/node_modules/parcel-plugin-transcrypt/asset.js:2:16)
at Module._compile (/usr/local/lib/node_modules/parcel-bundler/node_modules/v8-compile-cache/v8-compile-cache.js:194:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3) falling back to RawAsset
I'm getting the same thing. Running on linux.
Building index.html...
⚠️ Parser "parcel-plugin-transcrypt/asset.js" failed to initialize when processing asset "main.py". Threw the following error:
Error: Cannot find module 'parcel-bundler/src/Logger'
I was able to get it to work by manually creating these 3 files in their respective folders: parcel-bundler/src/Logger.js parcel-bundler/src//utils/prettyError.js parcel-bundler/src//utils/emoji.js
@JennaSys -- what's the whole picture for how you got it working? Does it create any redundant files? How well does it work? Do share your sauce -- this could be really cool!
No redundant files, you just need to add in three missing files required by the build process. It's a work around for an underlying issue, but it fixes the problem for now. I use 3 wget commands to pull the files out of github and put them into the appropriate node_modules folder. So after installing parcel-bundler with npm, from the root folder of the project I run these:
wget -P ./node_modules/parcel-bundler/src/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/Logger.js
wget -P ./node_modules/parcel-bundler/src/utils/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/utils/prettyError.js
wget -P ./node_modules/parcel-bundler/src/utils/ https://raw.githubusercontent.com/parcel-bundler/parcel/b1e6d59cc44489f20013fa3171e09788978d7aed/packages/core/parcel-bundler/src/utils/emoji.js
I have a repo with the Intro to React tutorial that I coded in Python (try it here), and another one where I used React with Material UI. That one is a simple CRUD type interface you can see here. And yes the fact I can write front end web UI with Python is very cool!
Rather than manually copying files to fix this issue, I found it is better to just patch the plug-in file itself to fix the Logger dependency location in the asset.js file of the transcrypt plug-in. It's a pretty simple one-line fix:
require('parcel-bundler/src/Logger'); gets changed to require('@parcel/logger/src/Logger');
asset.js.patch
--- asset_old.js 2020-11-30 17:49:49.690000000 -0800
+++ asset.js 2020-11-30 17:50:42.795302864 -0800
@@ -1,5 +1,5 @@
const Asset = require('parcel-bundler/src/Asset');
-const logger = require('parcel-bundler/src/Logger');
+const logger = require('@parcel/logger/src/Logger');
const child_process = require('child_process');
const path = require('path');
const fs = require('fs');
patch ./node_modules/parcel-plugin-transcrypt/asset.js < asset.js.patch
Does anyone know how to get this updated on npm?
require('@parcel/logger/src/Logger');
submit a PR?
npm has this one tagged as the repo, but I can not locate the source files here.
Since the version of Parcel that this plugin was designed for has been deprecated and replaced by Parcel v2, I created a new plugin for Transcrypt that works with the newer version of Parcel.
It is configured and works pretty much the same way as the old one did, with a few additions. Instructions to use it are on the NPM site.