Skip to content
This repository was archived by the owner on Jul 13, 2020. It is now read-only.
This repository was archived by the owner on Jul 13, 2020. It is now read-only.

SyntaxError: Unexpected token import #542

@liketurbo

Description

@liketurbo

SyntaxError: Unexpected token import, despite that I use babel.

import path from 'path';
import { System } from 'es-module-loader/core/loader-polyfill';

export default class HelloWorld {
  constructor(options) {
    this.options = options;
  }

  apply(compiler) {
    compiler.plugin('done', () => {
      this.done();
    });
  }

  done() {
    System.import(path.resolve('central.consts.js'))
      .then(m => console.log(m));
  }
}  

package.json script

"webpack:dev": "babel-node ./node_modules/.bin/webpack-cli --mode=development"

webpack.config.js

import path from 'path';

import HtmlWebpackPlugin from 'html-webpack-plugin';
import CentralConstsPlugin from './src/plugins/central-consts-plugin';

const basic = {
  entry: {
    app: './src/scripts/main.js',
  },
  output: {
    path: path.join(__dirname, 'build'),
    filename: '[name].js',
  },
};

const module = {
  rules: [
    {
      test: /\.js$/,
      use: ['babel-loader'],
    },
  ],
};

const plugins = [
  new CentralConstsPlugin(),
  new HtmlWebpackPlugin({
    template: path.join(__dirname, 'src/index.html'),
  }),
];

export default {
  ...basic,
  plugins,
  module,
};

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions