You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{Parcel}from'@parcel/core';importpathfrom'path';import{fileURLToPath}from'url';importopenfrom"open";// Required to convert the current module URL to a pathconst__filename=fileURLToPath(import.meta.url);const__dirname=path.dirname(__filename);asyncfunctionbuildAndRetrieveHashes(){// Define the entry file or directoryconstentryFile=path.join(__dirname,'src/index.html')constdistDir=path.join(__dirname,'dist')// Define the portconstportArgIndex=process.argv.indexOf("--port")constport=Number.parseInt(process.argv[portArgIndex+1])if(Number.isNaN(port)||portArgIndex<0)returnconsole.error("🚨 CUSTOM WATCHER ERROR: Port not supplied. Please provide a port using ")// Initialize a new Parcel bundlerconstbundler=newParcel({entries: entryFile,defaultConfig: '@parcel/config-default',mode: 'development',// 'production' or 'development'targets: {default: {distDir: distDir,publicUrl: "."}},serveOptions: {
port
},hmrOptions: {
port
},additionalReporters: [{packageName: '@parcel/reporter-cli',resolveFrom: __filename}]})try{letopened// Tell the bundler to watch the projectawaitbundler.watch(async(error,event)=>{if(error)throwerrorif(event.type==="buildSuccess"){// Make placement ts files into JSON// await generateJSONFiles(distDir)if(!opened)awaitopen(`http://localhost:${port}`)opened=true}else{console.log(event.diagnostics)}})}catch(error){console.error('Build failed:',error);}}buildAndRetrieveHashes();
This issue makes it impossible to write any custom bundlers. Even when using the CLI for building and the most basic form of a transformer, it still returns this errors. The following code also gives the same error:
I know that it is successfully running because it outputs the code when it runs, however, it just refuses to build anything.
My ultimate goal is to make a transformer that will remove any code that follows a comment such as //removeOnCompile or something similar. Unfortunately, there is no way to ensure functionality without Parcel even compiling anything.
*.{js,mjs,jsm,jsx,es6,cjs,ts,tsx,cts,mts} might work better, for unfortunate implementation specific reasons: #9038
That seems to work. I wish it was documented, but oh well. Thank you very much for the help. Hopefully this will help any other people that end up falling victims to this.
🐛 bug report
When importing and trying to use custom transformers, Parcel will simply refuse to build anything, resulting in a "Cannot find module 'hash'" error.
🎛 Configuration (.babelrc, package.json, cli command)
Command for starting server is:
node parcel-watch.mjs --port 2004
.parcelrc
:parcel-watch.mjs
:parcel-transformer.mjs
:🤔 Expected Behavior
Parcel should successfully compile the files and open the dev server.
😯 Current Behavior
Parcel fails to compile the code and returns the following error:
🔦 Context
This issue makes it impossible to write any custom bundlers. Even when using the CLI for building and the most basic form of a transformer, it still returns this errors. The following code also gives the same error:
I know that it is successfully running because it outputs the code when it runs, however, it just refuses to build anything.
My ultimate goal is to make a transformer that will remove any code that follows a comment such as
//removeOnCompile
or something similar. Unfortunately, there is no way to ensure functionality without Parcel even compiling anything.💻 Code Sample
https://github.com/chky-nmnsoftware/ParcelTransformerError
🌍 Your Environment
The text was updated successfully, but these errors were encountered: