flarum / framework

Simple forum software for building great communities.
http://flarum.org/
6.36k stars 835 forks source link

fix(regression): Webpack not working on Windows with new export registry #3855

Closed dsevillamartin closed 1 year ago

dsevillamartin commented 1 year ago

Caused by #3842.

Changes proposed in this pull request:

Initially, since .replace() was hardcoding /, the entire absolute path was being added to flarum.reg.add(). Then, building still errored because it was using \ as path separators, and the following characters weren't valid escape sequences.

ERROR in ./src/common/utils/styleSelectedText.ts 354:32
Module parse failed: Bad character escape sequence (354:32)
File was processed with these loaders:
 * ../../../js-packages/webpack-config/src/autoExportLoader.cjs
 * ../../../node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
|   };
| }
> flarum.reg.add('core', 'common\utils\styleSelectedText', styleSelectedText)

Tried to use path.posix, but it can't normalize win32 paths into unix. There's a package for that (slash), but it basically just replaces \ with / - I don't think this implementation should cause any issues.

QA Build JS. Dist remains the exact same.

Necessity

Confirmed