Comments (9)
@evilebottnawi i finally found the solution ^^ : https://github.com/elliottsj/babel-inline-import-loader
The README of the package is very explicit and it fix the issue. Maybe this discussion will help another developer !
Thanks for your time. 👍
from raw-loader.
@paulduthoit Can you create reproducible test repo?
from raw-loader.
Hi @evilebottnawi, i've made a very simple reproducible test repo, and it works like this. So i'm trying to investigate further to try to find where it crash i'm my project. I will let you known in the next hours.
from raw-loader.
@evilebottnawi i've found the issue. It occurred with the babel-plugin-inline-import
module in the babel.config.js
. I'm using this because i'm running my React app in SSR so i need the webpack import AND the babel import...
My test repo :
https://github.com/paulduthoit/raw-loader-watch-issue
from raw-loader.
@paulduthoit: Actually, your solution doesn't use raw-loader
anymore. But babel-inline-import-loader
+ babel-plugin-inline-import
. This solution seems more difficult to integrate in create-react-app
based applications.
Is there a solution for watch + raw-loader
? I'm suggesting to reopen the issue.
from raw-loader.
UPDATE: actually the solution to go for is:
- in webpack: use
raw-loader
; it does have reload capability; no modifs to babel config - in nodejs (e.g. during test w/ mocha): use
babel-plugin-inline-import
; it doesn't have reload capability; actually it does w/ babel cache = OFF, which in my case was no-go
In my case raw-loader
was not working, because I am using linked directories. I had to monkeypatch chokidar
to have followSymlinks = true
.
from raw-loader.
Hi @cristian-spiescu. You're right ! But i don't understand why it would be more difficult to integrate ?
In my webpack config file, i have :
...,
module: {
rules: [
{
test: /\.(js|jsx)$/,
exclude: /node_modules/,
use: [
'babel-inline-import-loader',
{
loader: 'babel-loader',
options: {
presets: [
'@babel/preset-env',
'@babel/preset-react'
]
}
}
]
}
]
},
...
And in my babel.config.js file, i have :
...,
plugins: [
...
[
'babel-plugin-inline-import',
{
extensions: [ '.css', '.md' ]
}
]
],
...
Maybe it will help you and fix your symlink issue.
I think that it's not a good idea to use raw-loader
if you need to import raw files with babel in addition to webpack. It's better to have raw-loader
if you only need webpack, but take babel-plugin-inline-import
if you need the support of both babel and webpack.
from raw-loader.
I proposed this text here:
- An alternative library for webpack is raw-loader. Advantage = detects changes to imported file w/o additional config or losing babel's cache. Disadvantage: maintain 2 separate configs. E.g. 1) one w/
raw-loader
for webpack, and 2) another one for babel usingbabel-plugin-inline-import
. E.g. if you use a create-react-app / CRA based React app, you may have 1) foryarn start
/ webpack and 2) foryarn test
/ babel. For CRA, craco and craco-raw-loader may help.
Apps created w/ CRA have little control over the webpack default. Even w/ CRACO, it's not trivial. And CRA is the default used by a lot of people I guess. Hence I use the dual config, cf. above.
And 2) losing babel's cache is a major drawback; at least for me. W/ my setup of mocha + babel + cache, every test run is executed instantly. W/o cache: each save => about 10s of recompilation. Which is no go.
from raw-loader.
I cannot help you with that, i never used CRA. :)
The only thing i can say is that when i'm using the babel-plugin-inline-import
library, my cache is still there and it's instantly rebuilt.
from raw-loader.
Related Issues (20)
- [question] how to use the new asset modules with inline requires like you could with raw loader HOT 9
- raw-loader returns export string instead of file content HOT 1
- Export incompatibility with raw-loader and awesome-typescript-loader HOT 3
- The variable contains the path to the file instead of the text HOT 4
- Cannot import file using typescript HOT 6
- Imported string contains module.exports HOT 4
- Module parse failed: Unexpected token m in JSON at position 0 while parsing near 'module.exports = "{\...' HOT 5
- raw-loader 2.0 not working with pug-html-loader HOT 8
- Not working with require statements HOT 12
- Warning/Failure Using Raw Loader 2.0.0 in Angular CLI HOT 4
- error when using with SCSS and angular7 HOT 6
- Angular and Styles HOT 2
- The template specified for component AppComponent is not a string HOT 3
- version 2.0.0 breaks ng Angular 8 -> webpack in my project HOT 5
- You may need an appropriate loader to handle this file type. HOT 3
- [Bug Report] raw-loader failed to load *.json HOT 2
- Can raw-loader catch all HOT 3
- `Module not found` when using TypeScript project references HOT 2
- Module Not Found HOT 1
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 raw-loader.