apache / incubator-weex-loader

Apache License 2.0
65 stars 32 forks source link

cannot compile `we` file type in `node_modules` #59

Closed NoraGithub closed 6 years ago

NoraGithub commented 6 years ago

When I npm run dev & npm run serve in my project, it return message below, which there seems to be somethings wrong.

    ERROR in ./~/weex-chart/chart.we
    Module parse failed: /Users/NoraChan/Desktop/geekhacker.tech/datahub_weex/node_modules/weex-chart/chart.we Unexpected token (4:0)
    You may need an appropriate loader to handle this file type.
    | * Created by godsong on 16/11/3.
    | */
    | <template>
    |     <gcanvas id="wxc_gcanvas" style="width:{{width}};height:{{height}};background-color:#ffffff"></gcanvas>
    | </template>
     @ ./~/weex-chart/index.js 4:0-21
     @ ./~/babel-loader/lib!./~/vue-loader/lib/selector.js?type=script&index=0!./src/components/pivot.vue
     @ ./src/components/pivot.vue
     @ ./src/router.js
     @ ./src/entry.js

However, my config should be right. My webpack.config.js is a default one.

..
...
const webConfig = {
  context: pathTo.join(__dirname, ''),
  entry: entry,
  output: {
    path: pathTo.join(__dirname, 'dist'),
    filename: '[name].web.js',
  },
  module: {
    // webpack 2.0 
    rules: [
      {
        test: /\.js$/,
        use: [{
          loader: 'babel-loader'
        }],
        exclude: /node_modules/
      },
      {
        test: /\.vue(\?[^?]+)?$/,
        use: [{
          loader: 'vue-loader'
        }]
      }
    ]
  },
  plugins: plugins
};
const weexConfig = {
  entry: weexEntry,
  output: {
    path: pathTo.join(__dirname, 'dist'),
    filename: '[name].js',
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        use: [{
          loader: 'babel-loader',
        }],
        exclude: /node_modules(?!\/.*(weex).*)/
      },
      {
        test: /\.vue(\?[^?]+)?$/,
        use: [{
          loader: 'weex-loader'
        }]
      },
      {
        test: /\.we(\?[^?]+)?$/,
        use: [{
          loader: 'weex-loader'
        }]
      }
    ]
  },
  plugins: plugins,
};

var exports = [webConfig, weexConfig];

if (fileType === '.we') {
  exports = weexConfig;
}
module.exports = exports;
Hanks10100 commented 6 years ago

The legacy Weex DSL 1.0 (.we) front-end framework is deprecated! https://issues.apache.org/jira/browse/WEEX-90

Please use Vue.js instead.

NoraGithub commented 6 years ago

Thanks for your rapid feedback. However, I installed the official plugin and I am not the one who can do the issue. And we should also take the situation that .we is in the node_modules into consideration.

Do you have any suggests?

Her's a related issue about the plugin I said. cannot compile we file type

Hanks10100 commented 6 years ago

Our tools are also under refactoring, the .we syntax is no longer supported, plugins should be migrated to Vue.js too.

NoraGithub commented 6 years ago

Thanks for your answer