Skip to content

Commit

Permalink
fix($core): include polyfills correctly (close #1168) (#2317)
Browse files Browse the repository at this point in the history
Co-Authored-By: meteorlxy <meteor.lxy@foxmail.com>
  • Loading branch information
psalaets and meteorlxy authored Apr 27, 2020
1 parent c80c36b commit 69c193a
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/@vuepress/core/lib/node/webpack/createBaseConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,22 +137,30 @@ module.exports = function createBaseConfig (context, isServer) {
.rule('js')
.test(/\.jsx?$/)
.exclude.add(filePath => {
// Always transpile lib directory
// transpile lib directory
if (filePath.startsWith(libDir)) {
return false
}
// always transpile js in vue files and md files

// transpile js in vue files and md files
if (/\.(vue|md)\.js$/.test(filePath)) {
return false
}

// transpile all core packages and vuepress related packages.
// i.e.
// @vuepress/*
// vuepress-*
if (/(@vuepress[\/\\][^\/\\]*|vuepress-[^\/\\]*)[\/\\](?!node_modules).*\.js$/.test(filePath)) {
return false
}
// Don't transpile node_modules

// transpile @babel/runtime until fix for babel/babel#7597 is released
if (filePath.includes(path.join('@babel', 'runtime'))) {
return false
}

// don't transpile node_modules
return /node_modules/.test(filePath)
}).end()
.use('cache-loader')
Expand All @@ -171,7 +179,11 @@ module.exports = function createBaseConfig (context, isServer) {
// ref: http://babeljs.io/docs/en/config-files
configFile: false,
presets: [
require.resolve('@vue/babel-preset-app')
[require.resolve('@vue/babel-preset-app'), {
entryFiles: [
path.resolve(__dirname, '../../client', isServer ? 'serverEntry.js' : 'clientEntry.js')
]
}]
]
})
}
Expand Down

0 comments on commit 69c193a

Please sign in to comment.