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: console errors in Windows-based build (#1228) #1236

Merged
merged 3 commits into from Apr 24, 2019

Conversation

wincent
Copy link
Contributor

@wincent wincent commented Apr 23, 2019

It turns out that the "test" property in the Webpack build needs to be in a different format on Windows, otherwise it never matches, which means that our file at "scripts/build/version.js" doesn't pass through the val-loader, and in turn means that we produce untransformed output that IE 11 will choke on (an arrow function, and even if we fixed it, it would probably choke on the backticks).

You can make the build work on Windows by passing path.resolve('scripts/build/version.js') instead; this produces an absolute path with the appropriate Windows-style backslashes. But then the build doesn't work on macOS. If you try to make it a relative path (path.relative('', path.resolve(...))) then Webpack rejects it.

So, the solution is to make a RegExp with the backslashes (if present) escaped.

Test plan: build on macOS and Windows (with yarn build, yarn start) and confirm console errors are gone and version is correctly transpiled. Note that the demo misbehaves still on IE 11 (not console errors, but some misbehavior of the editor itself, but I think that's expected).

Closes: #1228

It turns out that the "test" property in the Webpack build needs to be
in a different format on Windows, otherwise it never matches, which
means that our file at "scripts/build/version.js" doesn't pass through
the val-loader, and in turn means that we produce untransformed output
that IE 11 will choke on (an arrow function, and even if we fixed it, it
would probably choke on the backticks).

You can make the build work on Windows by passing
`path.resolve('scripts/build/version.js')` instead; this produces an
absolute path with the appropriate Windows-style backslashes. But then
the build doesn't work on macOS. If you try to make it a relative path
(`path.relative('', path.resolve(...))`) then Webpack rejects it.

So, the solution is to make a RegExp with the backslashes (if present)
escaped.

Test plan: build on macOS and Windows (with `yarn build`, `yarn start`)
and confirm console errors are gone and version is correctly transpiled.
Note that the demo misbehaves still on IE 11 (not console errors, but
some misbehavior of the editor itself, but I think that's expected).

Closes: #1228
@blzaugg
Copy link

blzaugg commented Apr 23, 2019

@wincent
Copy link
Contributor Author

wincent commented Apr 24, 2019

Ah yes, path.normalize() is probably better than split() + join(), but we'll still need to use replace() to prepare the regular expression (because we have to pass a regular expression, and not a string).

@wincent
Copy link
Contributor Author

wincent commented Apr 24, 2019

CI failures are spurious and will be fixed by #1238

@julien
Copy link
Contributor

julien commented Apr 24, 2019

Just started reviewing :)

@julien julien merged commit 31857ea into master Apr 24, 2019
@wincent wincent deleted the wincent/windows-build branch April 24, 2019 08:46
gregory-bretall added a commit to gregory-bretall/alloy-editor that referenced this pull request Apr 26, 2019
…nverting the backslashes into the proper regular expression format that they need to be in
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Advanced Editing Demo fails with console errors in IE11
3 participants