Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Improve: Babelの設定を最新化する #244

Closed
manabuyasuda opened this issue Jul 5, 2019 · 3 comments
Closed

Improve: Babelの設定を最新化する #244

manabuyasuda opened this issue Jul 5, 2019 · 3 comments

Comments

@manabuyasuda
Copy link
Owner

No description provided.

@manabuyasuda
Copy link
Owner Author

@babel/polyfillを削除。

🚨 As of Babel 7.4.0, this package has been deprecated in favor of directly including core-js/stable (to polyfill ECMAScript features) and regenerator-runtime/runtime (needed to use transpiled generator functions):

https://babeljs.io/docs/en/babel-polyfill

@babel/preset-env"useBuiltIns": "usage"と指定して、必要なモジュールを読み込むようにしている。
@babel/polyfillを残しても結果は変わらなかったが、必要ないので削除する。

@manabuyasuda
Copy link
Owner Author

Babel7からプロジェクトワイドなコンフィグにbabel.config.jsが、ディレクトリごとに設定を上書き?変更?する場合に.babelrcや.babelrc.jsを使うらしい。

Babel has two parallel config file formats, which can be used together, or independently.

Project-wide configuration
File-relative configuration
.babelrc (and .babelrc.js) files
package.json files with a "babel" key

https://babeljs.io/docs/en/config-files#project-wide-configuration

@manabuyasuda
Copy link
Owner Author

manabuyasuda commented Jul 5, 2019

babel.config.jsにするとエラーになってしまう。

// パターン1
module.exports = function (api) {
  api.cache(true);

  const presets = [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: 3
      }
    ]
  ];

  return {
    presets
  };
}
// パターン2
module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: 3
      }
    ]
  ]
};
module.exports = {
  presets: [
    [
      '@babel/preset-env',
      {
        useBuiltIns: 'usage',
        corejs: 3
      }
    ]
  ]
};
// パターン3
const presets =  [
  ['@babel/preset-env', {
    'useBuiltIns': 'usage',
    'corejs': 3
  }]
];
module.exports = { presets }

エラー

WARNING in ./src/assets/js/polyfill.js 6:0-13
"export 'default' (imported as 'svg4everybody') was not found in 'svg4everybody'
 @ ./src/assets/js/site.js

rootModeを指定したり、

 module: {
  rules: [{
    loader: "babel-loader",
    options: {
      rootMode: "upward",
    }
  }]
}

resolveを指定してもダメだった。

        resolve: {
          modules: ['node_modules'],
          extensions: ['.js'],
          alias: {
            vue$: 'vue/dist/vue.esm.js',
          },
        },

manabuyasuda added a commit that referenced this issue Jul 5, 2019
@babel/preset-envで必要なモジュールだけを読み込むように設定しているため。

#244
manabuyasuda added a commit that referenced this issue Jul 5, 2019
webpack-streamのwebpackバージョンをdevDependenciesに合わせる。

#244
manabuyasuda added a commit that referenced this issue Jul 5, 2019
Improve: Babelの設定を最新化する
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant