Comments (9)
@plasticine Do you have any examples with Babel 7? I'm getting similar issues once upgrading to Babel 7. Worked fine with Babel 6.
from inject-loader.
@MEGApixel23 Please check out the examples in the repo β specifically the webpack config. This is not an issue with inject-loader
, youβre just missing some config.
from inject-loader.
@MEGApixel23 Could you provide some more information (webpack version/config, babel config, etc)? Looks to me like things are just a bit mis-configured.
Check out the examples in https://github.com/plasticine/inject-loader/tree/master/example and let me know if they help you out.
from inject-loader.
Also, what version of inject-loader
are you using?
from inject-loader.
Here is my package.json file
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch",
"tests": "./node_modules/karma/bin/karma start karma.config.js"
},
"devDependencies": {
"bootstrap-sass": "^3.3.7",
"gulp": "^3.9.1",
"inject-loader": "^3.0.0-beta3",
"jasmine-core": "^2.5.2",
"jquery": "^3.1.0",
"karma": "^1.3.0",
"karma-babel-preprocessor": "^6.0.1",
"karma-chrome-launcher": "^2.0.0",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.1.0",
"karma-phantomjs-launcher": "^1.0.2",
"karma-webpack": "^2.0.1",
"laravel-elixir": "^6.0.0-9",
"laravel-elixir-browsersync-official": "^1.0.0",
"laravel-elixir-vue-2": "^0.2.0",
"laravel-elixir-webpack-official": "^1.0.10",
"lodash": "^4.16.2",
"vue": "^2.0.1",
"vue-resource": "^1.0.3",
"vue-router": "^2.1.1",
"vuex": "^2.1.1"
},
"dependencies": {}
}
and karma.config.js file
// Karma configuration
let webpackConf = require('./webpack.config.js');
if (webpackConf.entry) {
delete webpackConf.entry;
}
module.exports = function(config) {
config.set({
frameworks: ['jasmine'],
port: 9876, // web server port
colors: true,
logLevel: config.LOG_INFO,
reporters: ['progress'], // dots, progress
autoWatch: true, // enable / disable watching files & then run tests
browsers: ['Chrome'], //'PhantomJS', 'Firefox',
singleRun: true, // if true, Karma captures browsers, runs the tests and exits
concurrency: Infinity, // how many browser should be started simultaneous
webpack: webpackConf, // Pass your webpack.config.js file's content
webpackMiddleware: {
noInfo: true,
stats: 'errors-only'
},
/**
* base path that will be used to resolve all patterns (eg. files, exclude)
* This should be your JS Folder where all source javascript
* files are located.
*/
basePath: './resources/assets/js/',
/**
* list of files / patterns to load in the browser
* The pattern just says load all files within a
* tests directory including subdirectories
**/
files: [
{
pattern: '**/*.spec.js',
watched: false
},
],
// list of files to exclude
exclude: [],
/**
* pre-process matching files before serving them to the browser
* Add your App entry point as well as your Tests files which should be
* stored under the tests directory in your basePath also this expects
* you to save your tests with a .spec.js file extension. This assumes we
* are writing in ES6 and would run our file through babel before webpack.
*/
preprocessors: {
'app.js': ['webpack', 'babel'],
'**/*.spec.js': ['babel', 'webpack']
},
})
};
and webpack.config.js
module.exports = {};
from inject-loader.
You are right. Thanks a lot! Here is what I've done:
npm install babel-core babel-loader babel-preset-es2015 webpack --save-dev
- And added the following code into webpack config:
module.exports = {
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
};
from inject-loader.
@hershmire, did you ever find a solution?
from inject-loader.
#62 (comment) provides a workaround @Mavtak
from inject-loader.
@Mavtak Yep, as @yaakov123 mentioned the tl;dr of this is that inject-loader operates on CJS modules only (at the moment anyway), so any code you want to inject needs to be compiled to CJS before inject-loader can operate on it.
from inject-loader.
Related Issues (20)
- Thanks HOT 1
- Not working for me HOT 3
- Webpack + coffeescript + inject-loader HOT 2
- Cannot find module HOT 18
- Any chance of transitive dependencies ? HOT 2
- Webpack 3 compatibility HOT 2
- Regression: When injecting a falsey export, it shouldn't fall back to real module HOT 3
- babelrc config not used HOT 1
- Not working with React Native packager? HOT 1
- Support code-coverage instrumentation HOT 2
- Add webpack v4 to peerDependencies HOT 2
- Work with Jest HOT 3
- Mocking out the 'request-promise' library HOT 1
- Add more tests HOT 1
- Calling require() with dynamically formed paths leads to runtime issue with webpack
- Cannot mock default and named exports together HOT 1
- Add support for Babel 7 HOT 8
- Nested dependencies? HOT 1
- TS-support
- Webpack version 5.x support? HOT 2
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 inject-loader.