Skip to content

Comment that babel-inline-import-loader relies on is not generated #11

@jimsimon

Description

@jimsimon

I have BABEL_DISABLE_CACHE=1 set and I've tried setting cacheDirectory: false and neither option helps (as expected since the comment is missing from the output).

.babelrc contents:

{
  "presets": [
    [
      "env", {
      "targets": {
        "browsers": [
          "last 2 Chrome versions"
        ]
      },
      "modules": "umd"
    }]
  ],
  "plugins": [
    [
      "babel-plugin-inline-import", {
        "extensions": [
          ".css"
        ]
      }
    ],
    [
      "transform-incremental-dom", {
        "moduleSource": "incremental-dom"
      }
    ],
    ["transform-class-properties"]
  ],
  "env": {
    "test": {
      "plugins": [
        ["istanbul", {
          "exclude": [
            "tests/**/*"
          ]
        }]
      ]
    },
    "production": {
      "presets": ["babili"]
    }
  }
}

webpack.config.js:

const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')

module.exports = {
  entry: './docs/index.js',
  devtool: 'inline-source-map',
  output: {
    path: __dirname + '/docs/generated',
    filename: 'docs.js'
  },
  module: {
    rules: [
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: [
          'babel-inline-import-loader',
          'babel-loader'
        ]
      }
    ]
  },
  plugins: [
    new HtmlWebpackPlugin({
      filename: 'index.html',
      template: 'docs/template.html'
    })
  ]
}

input code:

import Component from '../../component'
import styles from './styles.css'

customElements.define('wc-button', class WcButton extends Component {
  renderCss () {
    super.renderCss()
    return (
      <style>
        {styles}
      </style>
    )
  }

  render () {
    return <button><slot /></button>
  }
})

relevant output:

  const styles = 'button {\n  background: red;\n}\n';

  customElements.define('wc-button', class WcButton extends _component2.default {
    renderCss() {
      super.renderCss();
      (0, _incrementalDom.elementOpen)('style');

      _renderArbitrary(styles);

      return (0, _incrementalDom.elementClose)('style');
    }

    render() {
      (0, _incrementalDom.elementOpen)('button');
      (0, _incrementalDom.elementVoid)('slot');
      return (0, _incrementalDom.elementClose)('button');
    }
  });

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions