Babel Brunch似乎没有编译@ polymer / lit-element模块

时间:2018-07-04 03:46:20

标签: javascript polymer babel brunch

我正在尝试将Lit-element集成到早午餐中。但是,Babel插件似乎并未尝试将lit-element模块编译为输出,因为它仍使用import / export的原始ES6语法。

这是我的早午餐配置: `

exports.config = {
  // See http://brunch.io/#documentation for docs.
  files: {
    javascripts: {
      // joinTo: 'js/app.js'
      joinTo: {
        'js/app.js': [
          /^node_modules/,
          /\app.js$/
        ],
        'js/editor.js': [
          /\editor.js$/
        ],
        'js/select.js': [
          /select.js$/,
        ]
      }
    },
    stylesheets: {
      joinTo: 'css/app.css',
      order: {
        after: ['../priv/static/css/app.scss'] // concat app.css last
      }
    },
    templates: {
      joinTo: 'js/app.js'
    }
  },

  conventions: {
    // This option sets where we should place non-css and non-js assets in.
    // By default, we set this to '/web/static/assets'. Files in this directory
    // will be copied to `paths.public`, which is 'priv/static' by default.
    assets: /^(web\/static\/assets)/
  },

  // Phoenix paths configuration
  paths: {
    // Dependencies and current project directories to watch
    watched: [
      'static', 'css', 'js', 'vendor'
    ],

    // Where to compile files to
    public: '../priv/static'
  },

  // Configure your plugins
  plugins: {
    babel: {
      // Do not use ES6 compiler in vendor code
    },
    sass: {
      mode: 'native'
    },
    uglify: {
      mangle: false,
      compress: {
        global_defs: {
          DEBUG: false
        }
      }
    }
  },

  modules: {
    autoRequire: {
      "js/app.js": ["js/app"]
    }
  },

  npm: {
    enabled: true
  }
}

这是我的app.js代码

import {LitElement, html} from '@polymer/lit-element'

function autoComplete(options){ ... }

export var App = {
   autoComplete
}

最后是编译后的代码,以及控制台日志:

...
require.register("@polymer/lit-element/lit-element.js", function(exports, require, module) {
  require = __makeRelativeRequire(require, {}, "@polymer/lit-element");
  (function() {
    import { PropertiesMixin } from '@polymer/polymer/lib/mixins/properties-mixin.js';
    // "Uncaught SyntaxError: Unexpected token {" on above line
import { camelToDashCase } from '@polymer/polymer/lib/utils/case-map.js';
import { render } from 'lit-html/lib/shady-render.js';
export { html, svg } from 'lit-html/lib/lit-extended.js';
...

0 个答案:

没有答案