question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[BUG] Built-in Optimizations Issue

See original GitHub issue

Bug Report Quick Checklist

  • I am on the latest version of Snowpack & all plugins.
  • I use package manager yarn v2.4.2.
  • I run Snowpack on OS Windows 10 21H1.
  • I run Snowpack on Node.js v14.7.0

Describe the bug

When I run cross-env TAILWIND_DISABLE_TOUCH=true NODE_ENV=production snowpack build with built-in optimize, it work but it doesn’t when using built-in optimize

To Reproduce

My repo is here (snowpack branch)

  1. git clone -b snowpack https://github.com/loctran016/eleventy-kickstart-blog.git
  2. yarn install
  3. Uncomment the following in snowpack.config.js:
    // optimize: {
    //     bundle: true,
    //     minify: true,
    //     target: 'es2017',
    //     treeshake: true,
    // },
  1. yarn build
  2. See error!

Expected behavior

The Build process work with built-in optimize enabled

Anything else?

Log is here
PS D:\frontend-template> yarn build
[10:43:45] [snowpack] config.mount[D:\frontend-template\src\images]: mounted directory does not exist.
[10:43:45] [snowpack] ! building files...
[10:43:50] [eleventy] Writing public/robots.txt from ./src/robots.ejs.
[10:43:50] [eleventy] Writing public/sitemap.xml from ./src/sitemap.njk.
[10:43:50] [eleventy] LazyImages - found 1 images in public/index.html
[10:43:50] [eleventy] LazyImages - processed 1 images in public/index.html
[10:43:50] [eleventy] Writing public/tags/index.html from ./src/tags-list.njk.
[10:43:50] [eleventy] Writing public/tags/allslides/index.html from ./src/tags.njk.
Writing public/content/posts/hi/index.html from ./src/content/posts/hi.md.
Writing public/index.html from ./src/index.njk.
[10:43:50] [eleventy] LazyImages - found 1 images in public/tags/allposts/index.html
[10:43:50] [eleventy] LazyImages - processed 1 images in public/tags/allposts/index.html
[10:43:51] [eleventy] Writing public/tags/allposts/index.html from ./src/tags.njk.
[10:43:51] [eleventy] LazyImages - found 1 images in public/tags/allpages/index.html
[10:43:51] [eleventy] LazyImages - processed 1 images in public/tags/allpages/index.html
[10:43:51] [eleventy] Writing public/tags/allpages/index.html from ./src/tags.njk.
[10:43:51] [eleventy] Wrote 8 files in 1.74 seconds (v0.12.1)
[10:43:51] [eleventy] Command completed.


warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
  ✔︎ Including:  base, components, themes[21], utilities

[10:43:52] [snowpack] import overlayscrollbars@latest → https://pkg.snowpack.dev/overlayscrollbars
[10:43:53] [snowpack] pin dependency to this version: `snowpack add overlayscrollbars`
[10:43:53] [snowpack] import @fortawesome/fontawesome-free@latest → https://pkg.snowpack.dev/@fortawesome/fontawesome-free
[10:43:53] [snowpack] pin dependency to this version: `snowpack add @fortawesome/fontawesome-free`
[10:43:53] [snowpack] import alpinejs@latest → https://pkg.snowpack.dev/alpinejs
[10:43:53] [snowpack] pin dependency to this version: `snowpack add alpinejs`
[10:43:53] [snowpack] import theme-change@latest → https://pkg.snowpack.dev/theme-change
[10:43:53] [snowpack] pin dependency to this version: `snowpack add theme-change`
[10:43:53] [snowpack] ✔ files built. [7.44s]
[10:43:53] [snowpack] ! building dependencies...
[10:43:53] [snowpack] ✔ dependencies built. [0.00s]
[10:43:53] [snowpack] ! writing to disk...
[10:43:53] [snowpack] ✔ write complete. [0.08s]
[10:43:53] [snowpack] ▶ Build Complete!
PS D:\frontend-template> yarn build
[10:44:14] [snowpack] config.mount[D:\frontend-template\src\images]: mounted directory does not exist.
[10:44:14] [snowpack] ! building files...
[10:44:19] [eleventy] Writing public/robots.txt from ./src/robots.ejs.
[10:44:19] [eleventy] Writing public/sitemap.xml from ./src/sitemap.njk.
[10:44:19] [eleventy] LazyImages - found 1 images in public/index.html
[10:44:19] [eleventy] LazyImages - processed 1 images in public/index.html
[10:44:19] [eleventy] Writing public/tags/index.html from ./src/tags-list.njk.
[10:44:19] [eleventy] Writing public/tags/allslides/index.html from ./src/tags.njk.
Writing public/content/posts/hi/index.html from ./src/content/posts/hi.md.
[10:44:19] [eleventy] Writing public/index.html from ./src/index.njk.
[10:44:19] [eleventy] LazyImages - found 1 images in public/tags/allposts/index.html
[10:44:19] [eleventy] LazyImages - processed 1 images in public/tags/allposts/index.html
[10:44:20] [eleventy] Writing public/tags/allposts/index.html from ./src/tags.njk.
[10:44:20] [eleventy] LazyImages - found 1 images in public/tags/allpages/index.html
[10:44:20] [eleventy] LazyImages - processed 1 images in public/tags/allpages/index.html
[10:44:20] [eleventy] Writing public/tags/allpages/index.html from ./src/tags.njk.
[10:44:20] [eleventy] Wrote 8 files in 1.68 seconds (v0.12.1)
[10:44:20] [eleventy] Command completed.


warn - You have enabled the JIT engine which is currently in preview.
warn - Preview features are not covered by semver, may introduce breaking changes, and can change at any time.
🌼 DaisyUI components 1.4.0  https://github.com/saadeghi/daisyui
  ✔︎ Including:  base, components, themes[21], utilities

[10:44:21] [snowpack] import overlayscrollbars@latest → https://pkg.snowpack.dev/overlayscrollbars
[10:44:21] [snowpack] pin dependency to this version: `snowpack add overlayscrollbars`
[10:44:22] [snowpack] import @fortawesome/fontawesome-free@latest → https://pkg.snowpack.dev/@fortawesome/fontawesome-free
[10:44:22] [snowpack] pin dependency to this version: `snowpack add @fortawesome/fontawesome-free`
[10:44:23] [snowpack] import alpinejs@latest → https://pkg.snowpack.dev/alpinejs
[10:44:23] [snowpack] pin dependency to this version: `snowpack add alpinejs`
[10:44:24] [snowpack] import theme-change@latest → https://pkg.snowpack.dev/theme-change
[10:44:24] [snowpack] pin dependency to this version: `snowpack add theme-change`
[10:44:25] [snowpack] ✔ files built. [11.53s]
[10:44:25] [snowpack] ! building dependencies...
[10:44:25] [snowpack] ✔ dependencies built. [0.00s]
[10:44:25] [snowpack] ! writing to disk...
[10:44:25] [snowpack] ✔ write complete. [0.05s]
[10:44:25] [snowpack] ! optimizing build...
 > build/scripts/index.js:2:7: error: Do not know how to load path: build/_snowpack/pkg/@fortawesome/fontawesome-free/js/all
    2 │ import '../_snowpack/pkg/@fortawesome/fontawesome-free/js/all'; // Import Packages
      ╵        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > build/scripts/index.js:6:28: error: Do not know how to load path: build/_snowpack/pkg/theme-change
    6 │ import { themeChange } from '../_snowpack/pkg/theme-change';
      ╵                             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > build/scripts/index.js:5:19: error: Do not know how to load path: build/_snowpack/pkg/alpinejs
    5 │ import Alpine from '../_snowpack/pkg/alpinejs';
      ╵                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > build/_snowpack/pkg/overlayscrollbars/js/OverlayScrollbars.min.js:15:14: error: Could not resolve "/_snowpack/pkg/-/overlayscrollbars@v1.13.1-ceoseDeKYXrLImSC7nQ2/dist=es2020,mode=imports/unoptimized/js/OverlayScrollbars.min.js"
    15 │ export * from '/_snowpack/pkg/-/overlayscrollbars@v1.13.1-ceoseDeKYXrLImSC7nQ2/dist=es2020,mode=imports/unoptimized/js/OverlayScroll... 
       ╵               ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

 > build/styles/index.css:1:44017: warning: All "@import" rules must come first
    1 │ ...rop-filter;transition-timing-function:cubic-bezier(.4,0,.2,1)}@import "../_snowpack/pkg/overlayscrollbars/css/OverlayScrollbars.mi... 
      ╵                                                                  ~~~~~~~
   build/styles/index.css:1:0: note: This rule cannot come before an "@import" rule
    1 │ html{-webkit-text-size-adjust:100%;line-height:1.15;-moz-tab-size:4;-o-tab-size:4;tab-size:4}body{font-family:system-ui,-apple-system... 
      ╵ ^

[10:44:26] [snowpack] Build failed with 4 errors:
build/_snowpack/pkg/overlayscrollbars/js/OverlayScrollbars.min.js:15:14: error: Could not resolve "/_snowpack/pkg/-/overlayscrollbars@v1.13.1-ceoseDeKYXrLImSC7nQ2/dist=es2020,mode=imports/unoptimized/js/OverlayScrollbars.min.js"
build/scripts/index.js:2:7: error: Do not know how to load path: build/_snowpack/pkg/@fortawesome/fontawesome-free/js/all
build/scripts/index.js:5:19: error: Do not know how to load path: build/_snowpack/pkg/alpinejs
build/scripts/index.js:6:28: error: Do not know how to load path: build/_snowpack/pkg/theme-change
[10:44:26] [snowpack] Error: Build failed with 4 errors:
build/_snowpack/pkg/overlayscrollbars/js/OverlayScrollbars.min.js:15:14: error: Could not resolve "/_snowpack/pkg/-/overlayscrollbars@v1.13.1-ceoseDeKYXrLImSC7nQ2/dist=es2020,mode=imports/unoptimized/js/OverlayScrollbars.min.js"
build/scripts/index.js:2:7: error: Do not know how to load path: build/_snowpack/pkg/@fortawesome/fontawesome-free/js/all
build/scripts/index.js:5:19: error: Do not know how to load path: build/_snowpack/pkg/alpinejs
build/scripts/index.js:6:28: error: Do not know how to load path: build/_snowpack/pkg/theme-change
    at failureErrorWithLog (D:\frontend-template\node_modules\esbuild\lib\main.js:1224:15)
    at buildResponseToResult (D:\frontend-template\node_modules\esbuild\lib\main.js:936:32)
    at D:\frontend-template\node_modules\esbuild\lib\main.js:1035:20
    at D:\frontend-template\node_modules\esbuild\lib\main.js:568:9
    at handleIncomingPacket (D:\frontend-template\node_modules\esbuild\lib\main.js:657:9)
    at Socket.readFromStdout (D:\frontend-template\node_modules\esbuild\lib\main.js:535:7)
    at Socket.emit (events.js:376:20)
    at addChunk (internal/streams/readable.js:309:12)
    at readableAddChunk (internal/streams/readable.js:284:9)
    at Socket.Readable.push (internal/streams/readable.js:223:10)
    at Pipe.onStreamRead (internal/stream_base_commons.js:188:23)

Here is a video as well:

https://user-images.githubusercontent.com/64778285/123194832-54269480-d4d1-11eb-9f3c-bc75339682be.mp4

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:8

github_iconTop GitHub Comments

1reaction
romeovscommented, Jul 9, 2021

This seems to be related to packageOptions.source when it is set to remote.

The optimiser does not seem to be able to detect the filetype of the packages that are generated under _snowpack/pkg because they do not have extensions (eg. build/snowpack/pkg/react).

1reaction
drwpowcommented, Jun 25, 2021

Thanks for raising. Our optimizations do cause issues with certain configurations currently. We’re going to be doing work soon to improve this story and resolve many bugs like this.

Read more comments on GitHub >

github_iconTop Results From Across the Web

What are some interesting bugs caused by optimizations by ...
So… just to be clear, there strictly speaking is no such thing as a bug caused by a correct optimisation. Either the original...
Read more >
[10/11 Regression] An incorrect optimization causes a function ...
Compiler output: Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-pc-linux-gnu/10.2.0/lto-wrapper Target: ...
Read more >
[5.8] sil crash with optimizations enabled #62545 - apple/swift
[5.8] sil crash with optimizations enabled #62545 ; bug A deviation from expected or documented behavior. Also: expected but undesirable behavior ...
Read more >
Issue 34112: 3.7.0 build error with --enable-optimizations
msg321655 ‑ (view) Author: Jayanth Koushik (jayanthkoushik) Date: 2018‑07‑14 16... msg321657 ‑ (view) Author: Benjamin Peterson (benjamin.peterson) * Date: 2018‑07‑14 18... msg321659 ‑ (view) Author:...
Read more >
Optimization-unstable code - LWN.net
The problem stems from C language behavior that is undefined by the standard, which allows compiler writers to optimize those statements away. Andrew...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found