Skip to content

Commit 3e5d893

Browse files
committed
fix: 修复 babel options 的 sourceType 问题
1 parent d93dd15 commit 3e5d893

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

build/createWebpackConfig.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -216,7 +216,8 @@ module.exports = async function createWebpackConfig(options, isServer = false) {
216216
...config.babel(isServer, config),
217217
// Save disk space when time isn't as important
218218
cacheCompression: isProd,
219-
compact: isProd
219+
compact: isProd,
220+
sourceType: 'unambiguous',
220221
}
221222

222223
result = Object.assign(result, {

build/setupDevEnv.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,11 @@ exports.setupServer = async function setupServer(config, options) {
7474
return runCode(sourceCode)
7575
}
7676

77-
return require(modulePath)
77+
let moduleFilePath = require.resolve(modulePath, {
78+
paths: [outputDir],
79+
})
80+
81+
return require(moduleFilePath)
7882
}
7983

8084

config/index.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,17 @@ module.exports = function getConfig(options) {
1919
customConfig = customConfig.default || customConfig
2020
break
2121
}
22+
2223
Object.assign(config, customConfig)
2324

25+
if (config.useBabelRuntime) {
26+
try {
27+
require.resolve('@babel/runtime/package.json')
28+
} catch (error) {
29+
console.error('please install @babel/runtime first, or set useBabelRuntime to false in imvc.config.js file')
30+
process.exit(1)
31+
}
32+
}
33+
2434
return config
2535
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-imvc",
3-
"version": "2.10.24",
3+
"version": "2.10.26",
44
"description": "An Isomorphic MVC Framework",
55
"main": "./index",
66
"bin": {

0 commit comments

Comments
 (0)