hw-weapp-compiler 1.0.13 → 1.0.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/dev.js +2 -19
- package/build/loader/js-loader.js +2 -7
- package/package.json +1 -1
package/build/dev.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
1
|
const webpack = require('webpack');
|
|
3
2
|
const { ENV } = require('./config/constants');
|
|
4
3
|
const webpackConfig = require('./webpack.config');
|
|
5
4
|
const { createCompilerHandler } = require('./utils/createCompilerHandler');
|
|
6
5
|
|
|
7
6
|
module.exports = async (opts) => {
|
|
8
|
-
//
|
|
7
|
+
// 开发环境禁用 filesystem cache,避免 output.clean 后复用旧缓存导致副作用产物漏生成。
|
|
8
|
+
// watch 进程内仍保留 webpack 的增量编译能力。
|
|
9
9
|
const compiler = webpack(
|
|
10
10
|
await webpackConfig(
|
|
11
11
|
{
|
|
@@ -16,23 +16,6 @@ module.exports = async (opts) => {
|
|
|
16
16
|
keep: /^(project\.config\.json|weapp\.env\.json)$/,
|
|
17
17
|
},
|
|
18
18
|
},
|
|
19
|
-
cache: {
|
|
20
|
-
type: 'filesystem',
|
|
21
|
-
cacheDirectory: path.resolve(process.cwd(), 'node_modules/.cache/webpack'),
|
|
22
|
-
buildDependencies: {
|
|
23
|
-
// webpack.config.js 及其 require 的 getEntries.js / loader / plugin 都作为
|
|
24
|
-
// 缓存依赖,本编译器自身代码改动后即时整体失效,避免复用旧 loader 输出。
|
|
25
|
-
config: [
|
|
26
|
-
path.resolve(__dirname, 'webpack.config.js'),
|
|
27
|
-
path.resolve(__dirname, 'config/getEntries.js'),
|
|
28
|
-
path.resolve(__dirname, 'plugin/index.js'),
|
|
29
|
-
path.resolve(__dirname, 'loader/js-loader.js'),
|
|
30
|
-
path.resolve(__dirname, 'loader/wxs-loader.js'),
|
|
31
|
-
path.resolve(__dirname, 'loader/wxml-loader.js'),
|
|
32
|
-
],
|
|
33
|
-
},
|
|
34
|
-
name: `dev-${process.version.slice(0, 6)}`,
|
|
35
|
-
},
|
|
36
19
|
},
|
|
37
20
|
opts || {},
|
|
38
21
|
),
|
|
@@ -10,6 +10,7 @@ const { getEntries } = require('../config/getEntries');
|
|
|
10
10
|
const { loadModule } = require('../utils/loadModule');
|
|
11
11
|
|
|
12
12
|
module.exports = async function loader(source) {
|
|
13
|
+
this.cacheable(true);
|
|
13
14
|
const filePath = this.resourcePath;
|
|
14
15
|
const fileInfo = path.parse(filePath);
|
|
15
16
|
const sourceStr = source.toString();
|
|
@@ -17,14 +18,8 @@ module.exports = async function loader(source) {
|
|
|
17
18
|
const imports = [sourceStr];
|
|
18
19
|
|
|
19
20
|
const entries = await getEntries();
|
|
20
|
-
const entryPath = path.resolve(fileInfo.dir, fileInfo.name);
|
|
21
|
-
const isEntryFile = Object.values(entries).indexOf(entryPath) !== -1;
|
|
22
21
|
|
|
23
|
-
|
|
24
|
-
// dev 二次启动时 output.clean 删除后的 app.json 不会重新 emit。
|
|
25
|
-
this.cacheable(!isEntryFile);
|
|
26
|
-
|
|
27
|
-
if (isEntryFile) {
|
|
22
|
+
if (Object.values(entries).indexOf(path.resolve(fileInfo.dir, fileInfo.name)) !== -1) {
|
|
28
23
|
const exts = ['.less', '.wxss', '.css', '.json', '.wxml'];
|
|
29
24
|
const checks = await Promise.all(
|
|
30
25
|
exts.map(async (ext) => {
|