Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

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

Open
kathgironpe opened this issue Jul 18, 2016 · 5 comments
Open

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

kathgironpe opened this issue Jul 18, 2016 · 5 comments

Comments

@kathgironpe
Copy link

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
Copy link
Owner

can you show me where the error appear?

@kathgironpe
Copy link
Author

kathgironpe commented Jul 18, 2016

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
Copy link
Owner

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
Copy link
Author

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
Copy link

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.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants