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

Fix import path in function when building on Windows #281

Merged
merged 1 commit into from
Apr 3, 2024

Conversation

mrstork
Copy link
Contributor

@mrstork mrstork commented Apr 2, 2024

Description

On Windows, run ntl build --offline on demos/vite-functions or demos/vite-edge and you will receive some version of the following error:

There was an error when loading the '...uildserverserver.js' npm module.
Support for npm modules in edge functions is an experimental feature. 
Refer to https://ntl.fyi/edge-functions-npm for more information.

This happens because export { default } from "..\..\build\server\server.js"; is generated at the top of demos/vite-functions/.netlify/functions-internal/remix-server.mjs. The backslashes are then read as escape characters, hence the '...uildserverserver.js' with missing characters in the error message.

The fix is to convert the path to posix before generating the file to create the following output instead:

export { default } from "../../build/server/server.js";

Related Tickets & Documents

QA Instructions, Screenshots, Recordings

  1. Run ntl build --offline on a Windows machine or VM targeting the vite-functions or vite-edge demo site.

For us to review and ship your PR efficiently, please perform the following steps:

  • Open a bug/issue before writing your code 🧑‍💻. This
    ensures we can discuss the changes and get feedback from everyone that should be involved. If you`re fixing a
    typo or something that`s on fire 🔥 (e.g. incident related), you can skip this step.
  • Read the contribution guidelines 📖. This ensures your code follows our style
    guide and passes our tests.
  • Update or add tests (if any source code was changed or added) 🧪
  • Update or add documentation (if features were changed or added) 📝
  • Make sure the status checks below are successful ✅

@mrstork mrstork self-assigned this Apr 2, 2024
@mrstork mrstork requested a review from a team as a code owner April 2, 2024 15:19
Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for remix-edge ready!

Name Link
🔨 Latest commit aecf292
🔍 Latest deploy log https://app.netlify.com/sites/remix-edge/deploys/660d7eaa2a0e9b0008ef46ba
😎 Deploy Preview https://deploy-preview-281--remix-edge.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Apr 2, 2024

Deploy Preview for remix-serverless ready!

Name Link
🔨 Latest commit aecf292
🔍 Latest deploy log https://app.netlify.com/sites/remix-serverless/deploys/660d7eaa03793000089e31c2
😎 Deploy Preview https://deploy-preview-281--remix-serverless.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@github-actions github-actions bot added the type: bug code to address defects in shipped code label Apr 2, 2024
@mrstork mrstork removed their assignment Apr 2, 2024
Copy link

@Skn0tt Skn0tt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks perfect! Ideally, we'd also add a test for this, but it looks like we don't have a test setup in this repository yet.

@mrstork mrstork force-pushed the invalid-import-on-windows branch from fcd4a27 to aecf292 Compare April 3, 2024 16:07
@pieh pieh merged commit 64455ed into main Apr 3, 2024
16 checks passed
@pieh pieh deleted the invalid-import-on-windows branch April 3, 2024 16:28
@token-generator-app token-generator-app bot mentioned this pull request Apr 3, 2024
@pschaeffer
Copy link

As best I can tell, the problem still exists. See the attached files. Note that I am using 'netlify serve' (without the quotes) to get the error.
Capture2

Capture1

@Skn0tt
Copy link

Skn0tt commented Apr 4, 2024

Peter, could you provide a minimal reproduction repository where this is broken?

@pschaeffer
Copy link

I am assuming you are referring to my-remix-udemy-section3-netlify4, not my-remix-udemy-section3-netlify3. Both 'netlify dev' and 'netlify serve' work great with my-remix-udemy-section3-netlify4. I upgraded to remix-adapter (2.3.1) and my problems with my-remix-udemy-section3-netlify4 went away.

@pschaeffer
Copy link

Thank you folks for all of your help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug code to address defects in shipped code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Functions Entrypoint generates invalid Import on Windows
4 participants