Skip to content

Commit

Permalink
fix #172 & #185
Browse files Browse the repository at this point in the history
  • Loading branch information
Diablohu committed Nov 5, 2019
1 parent 2c4a054 commit dbb8bd0
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 16 deletions.
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/test/projects/*/dist*/**/*
7 changes: 5 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,13 @@

**koot**

- **重大改动**
- _Node.js_ 最低版本要求提升到 `8.12.0`
- [SSR & 客户端渲染] 组件 CSS 的 `<style>` 标签上不再有 `id` 属性,以避免和元素冲突
- 如果项目中有用到根据 `id` 选择 `<style>` 标签的场景,可改为选择标签属性 `[data-koot-module]`
- [服务器] 服务器端打包代码不再会对 `await` `async` 进行转译 ([#172](https://github.com/cmux/koot/issues/172), [#186](https://github.com/cmux/koot/issues/186))
- **新特性**
- **新工具函数** `koot/utils/client-get-styles` - 获取当前全局 CSS 和所有组件 CSS。具体用法请参见文档 [全局与工具函数/工具函数/客户端](https://koot.js.org/#/utilities?id=客户端) ([#185](https://github.com/cmux/koot/issues/185))
- 优化
- 组件 CSS 的 `<style>` 标签上不再有 `id` 属性,以避免和元素冲突

## [0.11.15] - 2019-10-15

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
},
"homepage": "https://github.com/cmux/koot",
"engines": {
"node": ">=8.0.0"
"node": ">=8.12.0"
},
"license": "Apache-2.0",
"dependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ module.exports = (kootBuildConfig = {}) => {
{
test: /\.(js|mjs|cjs|jsx)$/,
use: [
...ruleUseLoaders(),
...ruleUseLoaders({}),
require.resolve('../../../loaders/koot-dev-ssr.js')
]
},
Expand All @@ -184,11 +184,13 @@ module.exports = (kootBuildConfig = {}) => {
return [
{
test: /\.(js|mjs|cjs|jsx)$/,
use: ruleUseBabelLoader()
use: ruleUseBabelLoader({})
},
{
test: /\.(ts|tsx)$/,
use: ruleUseBabelLoader({ __typescript: true })
use: ruleUseBabelLoader({
__typescript: true
})
}
];
};
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ module.exports = async (kootBuildConfig = {}) => {
// entry / 入口
const entryIndex = [
// '@babel/register',
'@babel/polyfill',
// '@babel/polyfill',
// 'core-js/stable',
// path.resolve(__dirname, '../../../defaults/server-stage-0.js'),
require('../libs/get-koot-file')(`${appType}/server`)
Expand Down
38 changes: 30 additions & 8 deletions packages/koot-webpack/loaders/babel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,10 @@ module.exports = require('babel-loader').custom(babel => {
__typescript = false
} = customOptions;
const { presets, plugins, ...options } = cfg.options;
const stage = process.env.WEBPACK_BUILD_STAGE;
// console.log({ options });

// presets ========================================================
const newPresets = [...presets];
if (__typescript) {
newPresets.unshift([
Expand Down Expand Up @@ -68,7 +70,25 @@ module.exports = require('babel-loader').custom(babel => {
// }
// return preset
// })
if (stage === 'server') {
newPresets.map(preset => {
if (
typeof preset.file === 'object' &&
/^@babel\/preset-env$/.test(preset.file.request)
) {
if (!preset.options) preset.options = {};
preset.options.modules = false;
preset.options.exclude = [
'@babel/plugin-transform-regenerator',
'@babel/plugin-transform-async-to-generator'
];
return preset;
}
return preset;
});
}

// plugins ========================================================
const newPlugins = plugins.filter(plugin => {
if (
typeof plugin.file === 'object' &&
Expand All @@ -78,14 +98,16 @@ module.exports = require('babel-loader').custom(babel => {
))
)
return false;
// if (
// process.env.WEBPACK_BUILD_STAGE === 'server' &&
// typeof plugin.file === 'object' &&
// /@babel(\/|\\)plugin-transform-regenerator/.test(
// plugin.file.request
// )
// )
// return false;

if (
stage === 'server' &&
typeof plugin.file === 'object' &&
/@babel(\/|\\)plugin-transform-regenerator/.test(
plugin.file.request
)
)
return false;

return true;
});

Expand Down
2 changes: 1 addition & 1 deletion packages/koot/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
},
"homepage": "https://github.com/cmux/koot",
"engines": {
"node": ">=8.9.0"
"node": ">=8.12.0"
},
"dependencies": {
"@babel/core": "^7.6.4",
Expand Down

0 comments on commit dbb8bd0

Please sign in to comment.