Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Broken build with posthtml #6136

Open
saltnpixels opened this issue Apr 15, 2021 · 6 comments
Open

Broken build with posthtml #6136

saltnpixels opened this issue Apr 15, 2021 · 6 comments

Comments

@saltnpixels
Copy link

I made a simple html file. Very simple. Added a js file and put it in the footer of the index.html page.
Added a sass file. I have one dependancy. normalize.css

I tried to build the html file with parcel build index.html

I get this error:

    /src/index.html: tree.render is not a function
    Documents/test-candidate1/node_modules/htmlnano/lib/modules/minifySvg.js:19:23
    Documents/test-candidate1/node_modules/posthtml/lib/api.js:91:45
    Documents/test-candidate1/node_modules/posthtml/lib/api.js:105:26)
    Documents/test-candidate1/node_modules/posthtml/lib/api.js:111:5)

I moved everything into a src folder cause i thought maybe thats what will make it happy. Nope :/
dev mode works though... weird...

Why is this happening?
I cant find any info on google....

@saltnpixels
Copy link
Author

I disabled minifcation and things magically worked...
I also had to add --public-url ./ to get links working properly.

@mischnic
Copy link
Member

Please fill out the issue template. Especially the Parcel version

@shoofar
Copy link

shoofar commented Apr 22, 2021

Hi,
I am new to posting issues so sorry for not sticking to any templates. ^_^ - will look how issue template should look like.
I have run to similar problem with parcel@2-beta.1 - working on pretty complicated project (learning JS and how to build a distribution package).
I am watching a training where trainer uses that version and it works for him.
These features are in use:

  • JS classes with private fields/methods
  • SASS (css)
  • importing *.SVG
  • some core js/stable
  • async functions

Anyway building project in DEV works fine. When I try to npm run build command
"build": "parcel build index.html --dist-dir ./dist" (my build command)

Building process gets to this point:
image

Then briefly moves to this stage

image

and fails:

image

× Build failed. @parcel/optimizer-htmlnano: tree.render is not a function TypeError: tree.render is not a function at <path>\final\node_modules\@parcel\optimizer-htmlnano\node_modules\htmlnano\lib\modules\minifySvg.js:19:23 at <path>\final\node_modules\posthtml\lib\api.js:91:45 at traverse (<path>\final\node_modules\posthtml\lib\api.js:105:26) at traverse (<path>\final\node_modules\posthtml\lib\api.js:111:5) at traverse (<path>\final\node_modules\posthtml\lib\api.js:105:17) at traverse (<path>\final\node_modules\posthtml\lib\api.js:111:5) at traverse (<path>\final\node_modules\posthtml\lib\api.js:105:17) at traverse (<path>\final\node_modules\posthtml\lib\api.js:111:5) at traverse (<path>\final\node_modules\posthtml\lib\api.js:105:17) at traverse (<path>\final\node_modules\posthtml\lib\api.js:111:5)

Hope this helps to pin-point the problem.
What more information do you need?
my package.json
{
"name": "app",
"version": "1.0.0",
"description": "app for learning",
"main": "index.html", // I also tried "default" here
"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html --dist-dir ./dist"
},
"author": "",
"license": "ISC",
"devDependencies": {
"@parcel/transformer-sass": "^2.0.0-beta.2",
"css-tree": "^1.1.3",
"htmlnano": "^1.0.0",
"parcel": "^2.0.0-beta.1",
"safe-buffer": "^5.2.1",
"sass": "^1.26.10"
},
"dependencies": {
"core-js": "^3.6.5",
"fractional": "^1.0.0",
"regenerator-runtime": "^0.13.7"
},
"minifySvg": {
"minifySvg": false
}
}

@shoofar
Copy link

shoofar commented Apr 23, 2021

I disabled minifcation and things magically worked...
I also had to add --public-url ./ to get links working properly.

I can confirm that with my project, turning off minification (adding --no-minify) makes building possible.
Now let's check if generated files work 😃

@DeMoorJasper
Copy link
Member

Maybe downgrading htmlnano to 0.2.9 works for now

@shoofar
Copy link

shoofar commented Apr 27, 2021

Thanx @DeMoorJasper ! - Your reply shed some light!

Maybe downgrading htmlnano to 0.2.9 works for now

It didn't work with 0.2.9 but I read the info what Kirill Maltsev wrote about changes in 0.2.9 so I gave a shot with 0.2.8 and build works with that version - in 0.2.9 they added:

minifyConditionalComment support [#125].
Minify JS within <script type="module"> [#135].

And it might have broken the building process :/ (at least for my project)

So in summary parcel@2.0.0-beta.1 with htmlnano (and my project):
0.2.8 works - project builds
0.2.9 fails with this error: @parcel/optimizer-htmlnano: tree.render is not a function (unless you add --no-minify to build options)
htmlnano@1.0.0 - it works O.K. - checked that also out of curiosity :)

parcel@2.0.0-beta.2 - can't make it work with JS class' private fields... (not tested after ~2021.04.01)

Thanx for your support!

jamiegluk added a commit to jamiegluk/jamiegl that referenced this issue Jan 28, 2022
- Downgrade "htmlnano" to v0.2.8 using yarn resolutions.
- See parcel-bundler/parcel#6136
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants