Blitz: Building store example fails on Windows

Created on 30 Apr 2020  路  1Comment  路  Source: blitz-js/blitz

What is the problem?

Maybe the relative synchronizer rule is normalizing import paths when it shouldn't? Not sure yet.

Steps to Reproduce:

  1. Clone Blitz repo on Windows
  2. Either run the tests, or cd into examples/store and try to build the store example
  3. Observe Bad character escape sequence error

Versions:

debug: monorepo
debug: pkgPath: C:\dev\contrib\blitz\node_modules\@blitzjs\cli

Windows 10 | win32-x64 | Node: v12.16.1

blitz: 0.7.0 (global)
blitz: 0.7.1-canary.1 (local)

Supporting Documentation:

Creating an optimized production build

Failed to compile.

./app/products/components/ProductForm.tsx
SyntaxError: C:\dev\contrib\blitz\examples\store\.blitz\caches\build\app\products\components\ProductForm.tsx: Bad character escape sequence (4:51)

  2 | import {Product, ProductCreateInput, ProductUpdateInput} from 'db'
  3 | import createProduct from 'app\products\mutations\createProduct'
> 4 | import updateProduct from 'app\products\mutations\updateProduct'
    |                                                    ^
  5 |
  6 | type ProductInput = ProductCreateInput | ProductUpdateInput
  7 |


> Build error occurred

Blitz code (examples\store\app\products\components\ProductForm.tsx):

import createProduct from '../mutations/createProduct'
import updateProduct from '../mutations/updateProduct'

Compiled code (examples\store\.blitz\caches\build\app\products\components\ProductForm.tsx):

import createProduct from 'app\products\mutations\createProduct'
import updateProduct from 'app\products\mutations\updateProduct'

The resulting backslashes are incorrect, they should remain forward slashes (in code).

Note:

I don't seem to run into this in a newly generated project, but we're still getting the issue reported in #299 so we might just not be making it that far yet? 馃

kinbug priorithigh scopexamples scopserver statudone

Most helpful comment

Problem

After some investigation, the relativeToAbsolute function is the culprit. path.sep, process.cwd() and the file's paths are being returned with back slashes.

relative-paths.test.ts's tests are giving a false positive since the path.normalize function replaces forward slashes with back slashes.

Possible Solution

Out of my head I can think of avoiding normalizing the paths in test, and replace any back slash with forward slash in relativeToAbsolute using replace. However, I don't yet know the extent of this function in the codebase. Perhaps it would be a better idea to transform on stream's input.

Additional Resources

Here is a screenshot of test with some debugging messages on Windows 10:

image

>All comments

Problem

After some investigation, the relativeToAbsolute function is the culprit. path.sep, process.cwd() and the file's paths are being returned with back slashes.

relative-paths.test.ts's tests are giving a false positive since the path.normalize function replaces forward slashes with back slashes.

Possible Solution

Out of my head I can think of avoiding normalizing the paths in test, and replace any back slash with forward slash in relativeToAbsolute using replace. However, I don't yet know the extent of this function in the codebase. Perhaps it would be a better idea to transform on stream's input.

Additional Resources

Here is a screenshot of test with some debugging messages on Windows 10:

image

Was this page helpful?
0 / 5 - 0 ratings

Related issues

netheril96 picture netheril96  路  4Comments

simonedelmann picture simonedelmann  路  3Comments

flybayer picture flybayer  路  4Comments

svobik7 picture svobik7  路  3Comments

markhaehnel picture markhaehnel  路  3Comments