@tarojs/taro-loader 3.6.9-alpha.7 → 3.6.9
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/lib/native-page.js +55 -0
- package/lib/native-page.js.map +1 -0
- package/package.json +3 -3
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const helper_1 = require("@tarojs/helper");
|
|
4
|
+
const loader_utils_1 = require("loader-utils");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const page_1 = require("./page");
|
|
7
|
+
function default_1(source) {
|
|
8
|
+
var _a;
|
|
9
|
+
const options = (0, loader_utils_1.getOptions)(this);
|
|
10
|
+
const { importFrameworkStatement, frameworkArgs, isNeedRawLoader, creatorLocation } = options.loaderMeta;
|
|
11
|
+
const { config: loaderConfig } = options;
|
|
12
|
+
const config = (0, page_1.getPageConfig)(loaderConfig, this.resourcePath);
|
|
13
|
+
const configString = JSON.stringify(config);
|
|
14
|
+
const stringify = (s) => (0, loader_utils_1.stringifyRequest)(this, s);
|
|
15
|
+
// raw is a placeholder loader to locate changed .vue resource
|
|
16
|
+
const raw = path.join(__dirname, 'raw.js');
|
|
17
|
+
const loaders = this.loaders;
|
|
18
|
+
const thisLoaderIndex = loaders.findIndex(item => (0, helper_1.normalizePath)(item.path).indexOf('@tarojs/taro-loader/lib/native-page') >= 0);
|
|
19
|
+
const componentPath = isNeedRawLoader
|
|
20
|
+
? `${raw}!${this.resourcePath}`
|
|
21
|
+
: this.request.split('!').slice(thisLoaderIndex + 1).join('!');
|
|
22
|
+
const runtimePath = Array.isArray(options.runtimePath) ? options.runtimePath : [options.runtimePath];
|
|
23
|
+
const setReconciler = runtimePath.reduce((res, item) => {
|
|
24
|
+
if (/^@tarojs\/plugin-(react|vue)-devtools/.test(item))
|
|
25
|
+
return res;
|
|
26
|
+
return res + `import '${item}'\n`;
|
|
27
|
+
}, '');
|
|
28
|
+
const { globalObject } = ((_a = this._compilation) === null || _a === void 0 ? void 0 : _a.outputOptions) || { globalObject: 'wx' };
|
|
29
|
+
const prerender = `
|
|
30
|
+
if (typeof PRERENDER !== 'undefined') {
|
|
31
|
+
${globalObject}._prerender = inst
|
|
32
|
+
}`;
|
|
33
|
+
const hmr = !options.hot ? '' : `if (process.env.NODE_ENV !== 'production') {
|
|
34
|
+
const cache = __webpack_require__.c || {}
|
|
35
|
+
Object.keys(cache).forEach(item => {
|
|
36
|
+
if (item.indexOf('${options.name}') !== -1) delete cache[item]
|
|
37
|
+
})
|
|
38
|
+
}`;
|
|
39
|
+
if (typeof options.loaderMeta.modifyConfig === 'function') {
|
|
40
|
+
options.loaderMeta.modifyConfig(config, source);
|
|
41
|
+
}
|
|
42
|
+
return `${setReconciler}
|
|
43
|
+
import { createNativePageConfig } from '${creatorLocation}'
|
|
44
|
+
${importFrameworkStatement}
|
|
45
|
+
var component = require(${stringify(componentPath)}).default
|
|
46
|
+
var config = ${configString};
|
|
47
|
+
${config.enableShareTimeline ? 'component.enableShareTimeline = true' : ''}
|
|
48
|
+
${config.enableShareAppMessage ? 'component.enableShareAppMessage = true' : ''}
|
|
49
|
+
var inst = Page(createNativePageConfig(component, '${options.name}', {root:{cn:[]}}, ${frameworkArgs}))
|
|
50
|
+
${options.prerender ? prerender : ''}
|
|
51
|
+
${hmr}
|
|
52
|
+
`;
|
|
53
|
+
}
|
|
54
|
+
exports.default = default_1;
|
|
55
|
+
//# sourceMappingURL=native-page.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"native-page.js","sourceRoot":"","sources":["../src/native-page.ts"],"names":[],"mappings":";;AAAA,2CAA8C;AAC9C,+CAA2D;AAC3D,6BAA4B;AAE5B,iCAAsC;AAItC,mBAA2D,MAAc;;IACvE,MAAM,OAAO,GAAG,IAAA,yBAAU,EAAC,IAAI,CAAC,CAAA;IAChC,MAAM,EAAE,wBAAwB,EAAE,aAAa,EAAE,e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AO,GAAG,CAAA;QAClE,OAAO,GAAG,GAAG,WAAW,IAAI,KAAK,CAAA;IACnC,CAAC,EAAE,EAAE,CAAC,CAAA;IACN,MAAM,EAAE,YAAY,EAAE,GAAG,CAAA,MAAA,IAAI,CAAC,YAAY,0CAAE,aAAa,KAAI,EAAE,YAAY,EAAE,IAAI,EAAE,CAAA;IAEnF,MAAM,SAAS,GAAG;;IAEhB,YAAY;EACd,CAAA;IAEA,MAAM,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;;;wBAGV,OAAO,CAAC,IAAI;;EAElC,CAAA;IAEA,IAAI,OAAO,OAAO,CAAC,UAAU,CAAC,YAAY,KAAK,UAAU,EAAE;QACzD,OAAO,CAAC,UAAU,CAAC,YAAY,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAChD;IAED,OAAO,GAAG,aAAa;0CACiB,eAAe;EACvD,wBAAwB;0BACA,SAAS,CAAC,aAAa,CAAC;eACnC,YAAY;EACzB,MAAM,CAAC,mBAAmB,CAAC,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,EAAE;EACxE,MAAM,CAAC,qBAAqB,CAAC,CAAC,CAAC,wCAAwC,CAAC,CAAC,CAAC,EAAE;qDACzB,OAAO,CAAC,IAAI,sBAAsB,aAAa;EAClG,OAAO,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE;EAClC,GAAG;CACJ,CAAA;AACD,CAAC;AAhDD,4BAgDC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tarojs/taro-loader",
|
|
3
|
-
"version": "3.6.9
|
|
3
|
+
"version": "3.6.9",
|
|
4
4
|
"description": "Taro runner use webpack loader",
|
|
5
5
|
"author": "yuche <i@yuche.me>",
|
|
6
6
|
"homepage": "https://github.com/nervjs/taro/tree/master/packages/taro-loader#readme",
|
|
@@ -22,8 +22,8 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"loader-utils": "^1.2.3",
|
|
25
|
-
"@tarojs/helper": "3.6.9
|
|
26
|
-
"@tarojs/taro": "3.6.9
|
|
25
|
+
"@tarojs/helper": "3.6.9",
|
|
26
|
+
"@tarojs/taro": "3.6.9"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
29
29
|
"jest": "^29.3.1",
|