posabsolute / redux-flash-notification

An es6 growl notification plugin for redux
MIT License
53 stars 12 forks source link

Import declarations may only appear at top level of a module #6

Open kathgironpe opened 8 years ago

kathgironpe commented 8 years ago

I get this error:

import declarations may only appear at top level of a module

I followed suggestions. Not sure what's wrong. I use the latest version of Redux and React.js.

posabsolute commented 8 years ago

can you show me where the error appear?

kathgironpe commented 8 years ago

It only appears when I add the import line on a layout view, which is the only one I have for the app. I'm a few hours away from demo hour but I will get an app example to confirm the problem later.

posabsolute commented 8 years ago

okay, it seems it's just a question of some code being before an import statement, very curious, I use this thing in all my projects and never had this error, I can try to debug it with you if you are interested

kathgironpe commented 8 years ago

I used redux-notifications and it worked. That too, has some problems, which I can live with for now. Still I like to check to create app to confirm the problem with this later.

minifigmaster125 commented 7 years ago

I'm experiencing this error. I haven't actually used the import anywhere; the error is thrown because the module is in es6 and my webpack fails to transpile it, for some reason. Can you share your webpack and babelrc? Here are my files:

//webpack

var HtmlWebpackPlugin = require('html-webpack-plugin')
var ExtractTextPlugin = require('extract-text-webpack-plugin')
var HTMLWebpackPluginConfig = new HtmlWebpackPlugin({
  template: __dirname + '/app/index.html',
  filename: 'index.html',
  inject: 'body'
});
var path = require('path')
var webpack = require('webpack');

module.exports = {
  devtool: 'source-map',
  entry: [
    'webpack-hot-middleware/client?reload=true',
    path.join(__dirname, './app/index.js')
  ],
  module: {
    loaders: [{
      test: [/\.js$/,/\.jsx$/],
      loader: "babel-loader",
      include: [
         path.resolve(__dirname, "node_modules/flash-notification-react-redux"),
         path.resolve(__dirname, "./app")
      ],
    },{
      test: /\.(css|scss)$/,
      loader: ExtractTextPlugin.extract('css!sass')
    },{
      test: /\.(png|jpg)$/,
      loader: 'url-loader?limit=8192'
    }]
  },
  output: {
    filename: 'index.bundle.js',
    path: __dirname + '/dist',
    publicPath: '/'
  },
  plugins: [
    HTMLWebpackPluginConfig,
    new ExtractTextPlugin('public/style.css', {
      allChunks: true
    }),
    new webpack.HotModuleReplacementPlugin(),
  ]
}
//babelrc
{
  presets: [ 'es2015', 'stage-0', 'react'],
  plugins: ['transform-decorators-legacy']
}

i can open a new issue if you'd like, thanks.