-
Notifications
You must be signed in to change notification settings - Fork 47
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
es6 import syntax error #27
Comments
@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. |
Also, what version of |
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 = {}; |
@MEGApixel23 Please check out the examples in the repo — specifically the webpack config. This is not an issue with |
You are right. Thanks a lot! Here is what I've done:
module.exports = {
module: {
loaders: [
{
test: /\.js$/,
exclude: /(node_modules|bower_components)/,
loader: 'babel-loader',
query: {
presets: ['es2015']
}
}
]
}
}; |
@plasticine Do you have any examples with Babel 7? I'm getting similar issues once upgrading to Babel 7. Worked fine with Babel 6. |
@hershmire, did you ever find a solution? |
#62 (comment) provides a workaround @Mavtak |
@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. |
Hi!
I try to use
inject-loader
on a following file:with code
and an error appears
Seems like es6 import syntax does not work in
inject-loader
The text was updated successfully, but these errors were encountered: