Comments (13)
I recommend using a separate modules directory when requiring non-bucklescript files. See the documentation on resolve.modules
. This lets you still require JS files, just not co-located with your Reason or OCaml files.
from bs-loader.
Hm this issue is about bs files only, I actually used files from your example.
from bs-loader.
I'll try to elaborate.
This is src
from the example:
| -- src/
|-- fib.re
|-- print.re
/* print.re */
Js.log (Fib.fib 10);
^ This what loader receives. Internally loader passes it to bsb
and it compiles it to:
...
var Fib = require('./fib.js');
...
This output as a string is passed from loader to webpack, but webpack is dealing w/ src/print.re
and looking for './fib.js'
in src
folder (it expectsfib.js
to be right next to src/print.re
, not to lib/js/src/print.js
).
from bs-loader.
Can you please paste your webpack config and bucklescript config?
from bs-loader.
Sure, here is the repo to reproduce: https://github.com/alexfedoseev/bs-loader-issue
Output:
from bs-loader.
Looks like the newer version of Bucklescript broke this! I was using 1.5 on my example, but as soon as I installed 1.7 it started to repro your issue. I'll look further into this now that I know what the problem is.
from bs-loader.
Looks like the problem was created in the Bucklescript 1.6.1 release with this issue: rescript-lang/rescript-compiler#1465. I'll try to look more into this when I get the time, but the fix will probably be on the Bucklescript side.
from bs-loader.
Looks like with 1.5 when webpack receives require('./foo')
, it resolves src/foo.re
and it most likely causes double compilation work as src/foo.re
was already compiled by bsb
when it dealt w/ src/app.re
. It might be significant overhead w/ big dependency tree.
from bs-loader.
The double compilation overhead was pretty small when I was first testing this, bsb
seemed to cache pretty well. Haven't done it with a large codebase though.
from bs-loader.
Good to know! I also tried to switch the context of the file inside the loader so webpack can resolve already compiled files, but looks like webpack doesn't allow this. And most likely it will cause issues w/ watch
mode.
from bs-loader.
I make a pretty hacky fix in b815752 and published version 1.2 to npm. Can you see if that works for you?
from bs-loader.
Works, thanks! Should I close this?
from bs-loader.
Yep, re-open it if 1.2 is buggy for whatever reason!
from bs-loader.
Related Issues (19)
- ES Modules HOT 6
- Error running jest on fresh clone without building first HOT 2
- ES6 example is broken HOT 1
- Cannot find upper-cased file in linux HOT 14
- EOF errors HOT 25
- jest doesn't work without testMatch config HOT 1
- jest watcher isn't watching interface files HOT 2
- Special case super-errors output
- Read bs-config instead of having webpack options HOT 3
- bs-loader doesn't work with sources in parent dirs HOT 1
- bs-loader doesn't work out-of-the-box with react bsb template HOT 5
- Workaround 'script' for WSL HOT 3
- "script" doesn't exist on some linuxes HOT 2
- Hi any news on new release ? HOT 6
- An option to hide warnings only for deps HOT 2
- Webpack won't reload .re files HOT 1
- ocamlyacc/ocamllex/menhir support HOT 1
- webpack --watch ignores changes in local dependencies after receiving syntax error there HOT 14
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bs-loader.