ascorbic / slash-edge

Banish or add trailing slashes with a Netlify edge function
https://trailing-slash-edge.netlify.app/
2 stars 1 forks source link

Bundling of edge function fails since today #1

Closed falexwolf closed 1 year ago

falexwolf commented 2 years ago

Hi! Thank you for the great solution to the trailing slash problem!

Just, it seems to fail the netlify build since today:

────────────────────────────────────────────────────────────────
  1. Build command from Netlify app                             
────────────────────────────────────────────────────────────────
​
$ yarn build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  624.36 kB  build/static/js/main.52dd0a0a.js
  [30](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:31).36 kB   build/static/css/main.96356612.css
  2.86 kB    build/static/js/255.e08497a7.chunk.js
  1.44 kB    build/static/js/377.1baa9f5c.chunk.js

The bundle size is significantly larger than recommended.
Consider reducing it with code splitting: https://goo.gl/9VhYWB
You can also analyze the project dependencies: https://goo.gl/LeUzfb

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  https://cra.link/deployment

Done in 102.18s.
​
(build.command completed in 1m 42.9s)
​
────────────────────────────────────────────────────────────────
  2. Edge Functions bundling                                    
────────────────────────────────────────────────────────────────
​
Packaging Edge Functions from netlify/edge-functions directory:
 - strip-slash
error: Uncaught (in promise) Error: Remote modules are not allowed to import local modules. Consider using a dynamic import instead.
  Importing: netlify:edge
      var ret = new Error(getStringFromWasm0(arg0, arg1));
                ^
    at __wbg_new_55259b138[34](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:35)a484c (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:389:17)
    at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:64387)
    at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:1546059)
    at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:1978661)
    at __wbg_adapter_24 (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:213:6)
    at real (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:197:14)
​
────────────────────────────────────────────────────────────────
  Bundling of edge function failed                              
────────────────────────────────────────────────────────────────
​
  Error message
  Command failed with exit code 1: /home/runner/.config/netlify/deno-cli/deno run --allow-all --quiet /usr/local/lib/node_modules/netlify-cli/node_modules/@netlify/edge-bundler/deno/bundle.ts {"basePath":"/home/runner/work/laminhub-frontend/laminhub-frontend","destPath":"/home/runner/work/laminhub-frontend/laminhub-frontend/.netlify/edge-functions-dist/ce2d5bbd-609d-4[37](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:38)8-bcb2-7bad392237e2.eszip","functions":[{"name":"strip-slash","path":"/home/runner/work/laminhub-frontend/laminhub-frontend/netlify/edge-functions/strip-slash.ts"}],"imports":{"netlify:edge":"https://edge.netlify.com/v1/index.ts"}}
  error: Uncaught (in promise) Error: Remote modules are not allowed to import local modules. Consider using a dynamic import instead.
    Importing: netlify:edge
        var ret = new Error(getStringFromWasm0(arg0, arg1));
                  ^
      at __wbg_new_55259b1[38](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:39)34a484c (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:389:17)
      at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:6[43](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:44)87)
      at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:15[46](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:47)0[59](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:60))
      at <anonymous> (https://deno.land/x/eszip@v0.18.0/eszip_wasm_bg.wasm:1:19786[61](https://github.com/laminlabs/laminhub-frontend/runs/8090639307?check_suite_focus=true#step:8:62))
      at __wbg_adapter_24 (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:213:6)
      at real (https://deno.land/x/eszip@v0.18.0/eszip_wasm.generated.js:197:14)
​
  Error location
  While bundling edge function

My setup follows this repository:

There is a file netlify/edge-functions/strip-slash.ts

export { stripSlash as default } from "https://deno.land/x/slash_handler/mod.ts";

and the corresponding line in netlify.toml

[[edge_functions]]
function = "strip-slash"
path = "/blog/"

I build the site using the CLI with netlify --build.

ascorbic commented 1 year ago

This should be working now

falexwolf commented 1 year ago

Thank you for fixing it! 😄

It seems to work all fine again! 🙏