orlov-vo / parcel-transformer-svelte

Parcel 2 transformer for Svelte 3
https://www.npmjs.com/package/parcel-transformer-svelte
MIT License
40 stars 18 forks source link

Parcel has removed the shouldReload config api #16

Closed JoshAshby closed 2 years ago

JoshAshby commented 3 years ago

Hey there, it looks like Parcel has recently removed the config.shouldReload() method for the config object recently which seems to break this extension on recent nightly versions of Parcel (looks like any version past 2.0.0-nightly.610) as a result of loadConfig.js using the shouldReload() method.

svelte.config.js:

const sveltePreprocess = require("svelte-preprocess")

module.exports = {
  preprocess: sveltePreprocess(),
}

.parcelrc:

{
  "extends": ["@parcel/config-default"],
  "transformers": {
    "*.svelte": ["parcel-transformer-svelte"]
  }
}

Error with a recent parcel version (2.0.0-nightly.619 in this case):

$ parcel src/manifest.json
🚨 Build failed.
parcel-transformer-svelte: config.shouldReload is not a function
TypeError: config.shouldReload is not a function
    at load ([...]/node_modules/parcel-transformer-svelte/loadConfig.js:46:14)
    at async Transformation.loadTransformerConfig ([...]/node_modules/@parcel/core/lib/Transformation.js:739:7)
    at async Transformation.loadPipeline ([...]/node_modules/@parcel/core/lib/Transformation.js:677:20)
    at async Transformation.run ([...]/node_modules/@parcel/core/lib/Transformation.js:315:20)
    at async Child.handleRequest ([...]/node_modules/@parcel/workers/lib/child.js:255:9)
zhyc9de commented 3 years ago

same issue

leeknowlton commented 3 years ago

+1

Would replacing config.shouldReload() with config.getConfig work?

schuetzm commented 2 years ago

The commit at https://github.com/schuetzm/parcel-transformer-svelte/commit/fixes seems to work, and an additional error with shouldInvalidateOnStartup(). But I don't really understand the code, so it could be wrong.

As for config.shouldReload(), the commit that removed it replaced it with a call to config.addDevDependency().

orlov-vo commented 2 years ago

Yeah, it seems shouldReload is not required anymore. I've released the fix in v1.2.3 to npm