@shuvi/toolpack 0.0.1-rc.9 → 1.0.0-rc.0
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/babel/plugins/auto-css-modules.js +1 -1
- package/lib/babel/plugins/loadable-plugin.js +1 -1
- package/lib/babel/plugins/optimize-hook-destructuring.d.ts +1 -1
- package/lib/babel/plugins/optimize-hook-destructuring.js +4 -4
- package/lib/babel/preset.js +24 -4
- package/lib/constants.js +4 -1
- package/lib/swc/tests/fixture/auto-css-module/no-flag/input.d.ts +1 -0
- package/lib/swc/tests/fixture/auto-css-module/no-flag/input.js +4 -0
- package/lib/swc/tests/fixture/auto-css-module/no-flag/output.d.ts +1 -0
- package/lib/swc/tests/fixture/auto-css-module/no-flag/output.js +4 -0
- package/lib/swc/tests/fixture/auto-css-module/with-flag/input.d.ts +1 -0
- package/lib/swc/tests/fixture/auto-css-module/with-flag/input.js +2 -0
- package/lib/swc/tests/fixture/auto-css-module/with-flag/output.d.ts +1 -0
- package/lib/swc/tests/fixture/auto-css-module/with-flag/output.js +2 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/input.js +5 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/output.js +11 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/input.js +9 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/output.js +12 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/input.js +4 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/output.js +7 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/input.js +4 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/output.js +8 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/input.js +7 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/output.js +9 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/input.js +5 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/output.js +11 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/input.js +9 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/output.js +12 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/input.js +4 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/output.js +7 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/input.js +4 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/output.js +8 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/input.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/input.js +7 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/output.d.ts +1 -0
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/output.js +9 -0
- package/lib/swc/tests/full/auto-cjs/1/input.d.ts +1 -0
- package/lib/swc/tests/full/auto-cjs/1/input.js +8 -0
- package/lib/swc/tests/full/auto-cjs/1/output.d.ts +1 -0
- package/lib/swc/tests/full/auto-cjs/1/output.js +8 -0
- package/lib/utils/build-loaders.d.ts +2 -0
- package/lib/utils/build-loaders.js +131 -0
- package/lib/utils/bundle-require.d.ts +33 -0
- package/lib/utils/bundle-require.js +143 -0
- package/lib/utils/forkTsCheckerWebpackPlugin.js +2 -1
- package/lib/utils/formatWebpackMessages.d.ts +1 -1
- package/lib/utils/formatWebpackMessages.js +2 -1
- package/lib/utils/hotDevClient/eventsource.js +1 -0
- package/lib/utils/hotDevClient/index.js +102 -29
- package/lib/utils/load-sources.d.ts +3 -0
- package/lib/utils/load-sources.js +94 -0
- package/lib/webpack/config/base.d.ts +15 -4
- package/lib/webpack/config/base.js +109 -85
- package/lib/webpack/config/browser.d.ts +3 -4
- package/lib/webpack/config/browser.js +87 -34
- package/lib/webpack/config/index.js +18 -7
- package/lib/webpack/config/node.d.ts +3 -4
- package/lib/webpack/config/node.js +19 -26
- package/lib/webpack/config/parts/external.d.ts +3 -2
- package/lib/webpack/config/parts/external.js +16 -10
- package/lib/webpack/config/parts/helpers.d.ts +2 -1
- package/lib/webpack/config/parts/helpers.js +7 -1
- package/lib/webpack/config/parts/resolve.js +1 -0
- package/lib/webpack/config/parts/style.d.ts +5 -2
- package/lib/webpack/config/parts/style.js +125 -60
- package/lib/webpack/dynamic-dll/bundler/index.d.ts +22 -0
- package/lib/webpack/dynamic-dll/bundler/index.js +211 -0
- package/lib/webpack/dynamic-dll/bundler/webpack-config.d.ts +16 -0
- package/lib/webpack/dynamic-dll/bundler/webpack-config.js +116 -0
- package/lib/webpack/dynamic-dll/constants.d.ts +6 -0
- package/lib/webpack/dynamic-dll/constants.js +9 -0
- package/lib/webpack/dynamic-dll/dep/getCJSExports.d.ts +3 -0
- package/lib/webpack/dynamic-dll/dep/getCJSExports.js +58 -0
- package/lib/webpack/dynamic-dll/dep/getExposeFromContent.d.ts +1 -0
- package/lib/webpack/dynamic-dll/dep/getExposeFromContent.js +80 -0
- package/lib/webpack/dynamic-dll/dep/getModuleExports.d.ts +7 -0
- package/lib/webpack/dynamic-dll/dep/getModuleExports.js +46 -0
- package/lib/webpack/dynamic-dll/dep/index.d.ts +13 -0
- package/lib/webpack/dynamic-dll/dep/index.js +43 -0
- package/lib/webpack/dynamic-dll/helper/check-not-in-node-modules.d.ts +1 -0
- package/lib/webpack/dynamic-dll/helper/check-not-in-node-modules.js +15 -0
- package/lib/webpack/dynamic-dll/index.d.ts +35 -0
- package/lib/webpack/dynamic-dll/index.js +198 -0
- package/lib/webpack/dynamic-dll/metadata.d.ts +13 -0
- package/lib/webpack/dynamic-dll/metadata.js +62 -0
- package/lib/webpack/dynamic-dll/moduleCollector.d.ts +28 -0
- package/lib/webpack/dynamic-dll/moduleCollector.js +64 -0
- package/lib/webpack/dynamic-dll/plugin/dynamic-dll-plugin.d.ts +24 -0
- package/lib/webpack/dynamic-dll/plugin/dynamic-dll-plugin.js +71 -0
- package/lib/webpack/dynamic-dll/utils.d.ts +6 -0
- package/lib/webpack/dynamic-dll/utils.js +29 -0
- package/lib/webpack/index.d.ts +17 -0
- package/lib/webpack/index.js +112 -0
- package/lib/webpack/loaders/parcel-css-loader/CssSyntaxError.d.ts +4 -0
- package/lib/webpack/loaders/parcel-css-loader/CssSyntaxError.js +39 -0
- package/lib/webpack/loaders/parcel-css-loader/index.d.ts +4 -0
- package/lib/webpack/loaders/parcel-css-loader/index.js +369 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/api.d.ts +2 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/api.js +85 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/getUrl.d.ts +2 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/getUrl.js +23 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/noSourceMaps.d.ts +2 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/noSourceMaps.js +2 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/sourceMaps.d.ts +2 -0
- package/lib/webpack/loaders/parcel-css-loader/runtime/sourceMaps.js +16 -0
- package/lib/webpack/loaders/parcel-css-loader/utils.d.ts +28 -0
- package/lib/webpack/loaders/parcel-css-loader/utils.js +869 -0
- package/lib/webpack/loaders/route-component-loader.js +25 -5
- package/lib/webpack/loaders/shuvi-swc-loader.d.ts +2 -0
- package/lib/webpack/loaders/shuvi-swc-loader.js +155 -0
- package/lib/webpack/plugins/build-manifest-plugin.js +44 -23
- package/lib/webpack/plugins/dynamic-public-path-plugin.d.ts +9 -0
- package/lib/webpack/plugins/dynamic-public-path-plugin.js +50 -0
- package/lib/webpack/plugins/fix-watching-plugin.d.ts +4 -0
- package/lib/webpack/plugins/fix-watching-plugin.js +23 -0
- package/lib/webpack/plugins/jsconfig-paths-plugin.d.ts +44 -0
- package/lib/webpack/plugins/jsconfig-paths-plugin.js +228 -0
- package/lib/webpack/plugins/module-replace-plugin/index.js +5 -1
- package/lib/webpack/plugins/module-replace-plugin/plugin.d.ts +6 -6
- package/lib/webpack/plugins/module-replace-plugin/plugin.js +47 -32
- package/lib/webpack/plugins/module-replace-plugin/stub-loader.js +47 -7
- package/lib/webpack/plugins/require-cache-hot-reloader-plugin.js +9 -8
- package/lib/webpack/plugins/support-ts-extension-resolver-plugin.d.ts +4 -0
- package/lib/webpack/plugins/support-ts-extension-resolver-plugin.js +23 -0
- package/lib/webpack/types.d.ts +40 -0
- package/lib/webpack/types.js +2 -0
- package/package.json +84 -44
- package/swc-source/native/shuvi-swc.darwin-arm64.node +0 -0
- package/lib/utils/emptyComponent.d.ts +0 -1
- package/lib/utils/emptyComponent.js +0 -7
- package/lib/utils/errorOverlayMiddleware.d.ts +0 -1
- package/lib/utils/errorOverlayMiddleware.js +0 -21
- package/lib/utils/verifyTypeScriptSetup.d.ts +0 -5
- package/lib/utils/verifyTypeScriptSetup.js +0 -229
- package/lib/webpack/loaders/export-global-loader.d.ts +0 -7
- package/lib/webpack/loaders/export-global-loader.js +0 -26
|
@@ -9,7 +9,7 @@ function default_1() {
|
|
|
9
9
|
visitor: {
|
|
10
10
|
ImportDeclaration(path, { opts }) {
|
|
11
11
|
const { specifiers, source, source: { value }, } = path.node;
|
|
12
|
-
if (specifiers.length && CSS_EXTNAMES.includes(path_1.extname(value))) {
|
|
12
|
+
if (specifiers.length && CSS_EXTNAMES.includes((0, path_1.extname)(value))) {
|
|
13
13
|
if (value.indexOf('?') >= 0) {
|
|
14
14
|
source.value = `${value}&${opts.flag || 'cssmodules'}`;
|
|
15
15
|
}
|
|
@@ -28,7 +28,7 @@ function default_1({ types: t, }) {
|
|
|
28
28
|
visitor: {
|
|
29
29
|
ImportDeclaration(path) {
|
|
30
30
|
let source = path.node.source.value;
|
|
31
|
-
if (source !== '@shuvi/
|
|
31
|
+
if (source !== '@shuvi/runtime')
|
|
32
32
|
return;
|
|
33
33
|
let dynamicSpecifier = path.get('specifiers').find((specifier) => {
|
|
34
34
|
return specifier.node.imported.name === 'dynamic';
|
|
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
const isHook = /^use[A-Z]/;
|
|
7
7
|
// matches only built-in hooks provided by React et al
|
|
8
8
|
const isBuiltInHook = /^use(Callback|Context|DebugValue|Effect|ImperativeHandle|LayoutEffect|Memo|Reducer|Ref|State)$/;
|
|
9
|
-
function default_1({ types: t
|
|
9
|
+
function default_1({ types: t }) {
|
|
10
10
|
const visitor = {
|
|
11
11
|
CallExpression(path, state) {
|
|
12
12
|
const onlyBuiltIns = state.opts.onlyBuiltIns;
|
|
@@ -44,7 +44,7 @@ function default_1({ types: t, }) {
|
|
|
44
44
|
}
|
|
45
45
|
return patterns.concat(t.objectProperty(t.numericLiteral(i), element));
|
|
46
46
|
}, []));
|
|
47
|
-
}
|
|
47
|
+
}
|
|
48
48
|
};
|
|
49
49
|
return {
|
|
50
50
|
name: 'optimize-hook-destructuring',
|
|
@@ -52,8 +52,8 @@ function default_1({ types: t, }) {
|
|
|
52
52
|
// this is a workaround to run before preset-env destroys destructured assignments
|
|
53
53
|
Program(path, state) {
|
|
54
54
|
path.traverse(visitor, state);
|
|
55
|
-
}
|
|
56
|
-
}
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
57
|
};
|
|
58
58
|
}
|
|
59
59
|
exports.default = default_1;
|
package/lib/babel/preset.js
CHANGED
|
@@ -1,9 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
4
24
|
};
|
|
5
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
const
|
|
26
|
+
const path = __importStar(require("path"));
|
|
7
27
|
const env = process.env.NODE_ENV;
|
|
8
28
|
const isProduction = env === 'production';
|
|
9
29
|
const isDevelopment = env === 'development';
|
|
@@ -83,7 +103,7 @@ exports.default = (api, options = {}) => {
|
|
|
83
103
|
// Undocumented option that lets us encapsulate our runtime, ensuring
|
|
84
104
|
// the correct version is used
|
|
85
105
|
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
|
|
86
|
-
absoluteRuntime:
|
|
106
|
+
absoluteRuntime: path.dirname(require.resolve('@babel/runtime/package.json')) }, options['transform-runtime'])
|
|
87
107
|
],
|
|
88
108
|
isProduction && [
|
|
89
109
|
require('babel-plugin-transform-react-remove-prop-types'),
|
package/lib/constants.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent1 = (0, runtime_1.dynamic)(() => import('../components/hello1'));
|
|
5
|
+
const DynamicComponent2 = (0, runtime_1.dynamic)(() => import('../components/hello2'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent1 = (0, runtime_1.dynamic)(() => import('../components/hello1'), {
|
|
5
|
+
webpack: () => [require.resolveWeak('../components/hello1')],
|
|
6
|
+
modules: ['../components/hello1']
|
|
7
|
+
});
|
|
8
|
+
const DynamicComponent2 = (0, runtime_1.dynamic)(() => import('../components/hello2'), {
|
|
9
|
+
webpack: () => [require.resolveWeak('../components/hello2')],
|
|
10
|
+
modules: ['../components/hello2']
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
7
|
+
const something_else_1 = __importDefault(require("something-else"));
|
|
8
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'));
|
|
9
|
+
something_else_1.default.dynamic('should not be transformed');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
7
|
+
const something_else_1 = __importDefault(require("something-else"));
|
|
8
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
9
|
+
webpack: () => [require.resolveWeak('../components/hello')],
|
|
10
|
+
modules: ['../components/hello']
|
|
11
|
+
});
|
|
12
|
+
something_else_1.default.dynamic('should not be transformed');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
5
|
+
webpack: () => [require.resolveWeak('../components/hello')],
|
|
6
|
+
modules: ['../components/hello']
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponentWithCustomLoading = (0, runtime_1.dynamic)(() => import('../components/hello'), { loading: () => React.createElement("p", null, "...") });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponentWithCustomLoading = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
5
|
+
webpack: () => [require.resolveWeak('../components/hello')],
|
|
6
|
+
modules: ['../components/hello'],
|
|
7
|
+
loading: () => React.createElement("p", null, "...")
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => handleImport(import('./components/hello')), {
|
|
5
|
+
loading: () => null,
|
|
6
|
+
ssr: false
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => handleImport(import('./components/hello')), {
|
|
5
|
+
webpack: () => [require.resolveWeak('./components/hello')],
|
|
6
|
+
modules: ['./components/hello'],
|
|
7
|
+
loading: () => null,
|
|
8
|
+
ssr: false
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent1 = (0, runtime_1.dynamic)(() => import('../components/hello1'));
|
|
5
|
+
const DynamicComponent2 = (0, runtime_1.dynamic)(() => import('../components/hello2'));
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent1 = (0, runtime_1.dynamic)(() => import('../components/hello1'), {
|
|
5
|
+
webpack: () => [require.resolve('../components/hello1')],
|
|
6
|
+
modules: ['../components/hello1']
|
|
7
|
+
});
|
|
8
|
+
const DynamicComponent2 = (0, runtime_1.dynamic)(() => import('../components/hello2'), {
|
|
9
|
+
webpack: () => [require.resolve('../components/hello2')],
|
|
10
|
+
modules: ['../components/hello2']
|
|
11
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
7
|
+
const something_else_1 = __importDefault(require("something-else"));
|
|
8
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'));
|
|
9
|
+
something_else_1.default.dynamic('should not be transformed');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
7
|
+
const something_else_1 = __importDefault(require("something-else"));
|
|
8
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
9
|
+
webpack: () => [require.resolve('../components/hello')],
|
|
10
|
+
modules: ['../components/hello']
|
|
11
|
+
});
|
|
12
|
+
something_else_1.default.dynamic('should not be transformed');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
5
|
+
webpack: () => [require.resolve('../components/hello')],
|
|
6
|
+
modules: ['../components/hello']
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponentWithCustomLoading = (0, runtime_1.dynamic)(() => import('../components/hello'), { loading: () => React.createElement("p", null, "...") });
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponentWithCustomLoading = (0, runtime_1.dynamic)(() => import('../components/hello'), {
|
|
5
|
+
webpack: () => [require.resolve('../components/hello')],
|
|
6
|
+
modules: ['../components/hello'],
|
|
7
|
+
loading: () => React.createElement("p", null, "...")
|
|
8
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => handleImport(import('./components/hello')), {
|
|
5
|
+
loading: () => null,
|
|
6
|
+
ssr: false
|
|
7
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const runtime_1 = require("@shuvi/runtime");
|
|
4
|
+
const DynamicComponent = (0, runtime_1.dynamic)(() => handleImport(import('./components/hello')), {
|
|
5
|
+
webpack: () => [require.resolve('./components/hello')],
|
|
6
|
+
modules: ['./components/hello'],
|
|
7
|
+
loading: () => null,
|
|
8
|
+
ssr: false
|
|
9
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const esm_1 = __importDefault(require("esm"));
|
|
7
|
+
console.log(esm_1.default.foo);
|
|
8
|
+
module.exports = esm_1.default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
26
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
27
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
29
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
30
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
exports.buildToString = exports.build = void 0;
|
|
36
|
+
const file_1 = require("@shuvi/utils/lib/file");
|
|
37
|
+
const esbuild = __importStar(require("esbuild"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const loader = {
|
|
40
|
+
'.js': 'jsx',
|
|
41
|
+
'.jsx': 'jsx',
|
|
42
|
+
'.json': 'json',
|
|
43
|
+
'.ts': 'ts',
|
|
44
|
+
'.tsx': 'tsx'
|
|
45
|
+
};
|
|
46
|
+
function build(dir, mode) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
yield esbuild.build({
|
|
49
|
+
entryPoints: [path.join(dir, 'loaders.js')],
|
|
50
|
+
format: 'esm',
|
|
51
|
+
platform: 'browser',
|
|
52
|
+
target: 'esnext',
|
|
53
|
+
loader,
|
|
54
|
+
watch: mode === 'development',
|
|
55
|
+
bundle: true,
|
|
56
|
+
logLevel: 'error',
|
|
57
|
+
external: ['react', '@shuvi/*'],
|
|
58
|
+
pure: ['loader'],
|
|
59
|
+
treeShaking: true,
|
|
60
|
+
outfile: path.join(dir, 'page-loaders.js'),
|
|
61
|
+
plugins: [
|
|
62
|
+
{
|
|
63
|
+
name: 'imports',
|
|
64
|
+
setup(build) {
|
|
65
|
+
let entry;
|
|
66
|
+
build.onResolve({ filter: /.*/ }, args => {
|
|
67
|
+
if (args.kind === 'entry-point')
|
|
68
|
+
entry = args.path;
|
|
69
|
+
if (args.kind === 'entry-point' || args.importer === entry) {
|
|
70
|
+
const resolved = (0, file_1.resolveFile)(path.resolve(args.resolveDir, args.path));
|
|
71
|
+
return { path: resolved };
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
path: !args.path.startsWith('.') && !args.path.startsWith('/')
|
|
75
|
+
? args.path
|
|
76
|
+
: path.resolve(args.resolveDir, args.path),
|
|
77
|
+
external: true,
|
|
78
|
+
sideEffects: false
|
|
79
|
+
};
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
exports.build = build;
|
|
88
|
+
function buildToString(entry) {
|
|
89
|
+
var _a;
|
|
90
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
91
|
+
const result = yield esbuild.build({
|
|
92
|
+
entryPoints: [entry],
|
|
93
|
+
format: 'esm',
|
|
94
|
+
platform: 'browser',
|
|
95
|
+
target: 'esnext',
|
|
96
|
+
loader,
|
|
97
|
+
bundle: true,
|
|
98
|
+
logLevel: 'error',
|
|
99
|
+
external: ['react', '@shuvi/*'],
|
|
100
|
+
pure: ['loader'],
|
|
101
|
+
treeShaking: true,
|
|
102
|
+
outdir: 'out',
|
|
103
|
+
write: false,
|
|
104
|
+
plugins: [
|
|
105
|
+
{
|
|
106
|
+
name: 'imports',
|
|
107
|
+
setup(build) {
|
|
108
|
+
let entry;
|
|
109
|
+
build.onResolve({ filter: /.*/ }, args => {
|
|
110
|
+
if (args.kind === 'entry-point')
|
|
111
|
+
entry = args.path;
|
|
112
|
+
if (args.kind === 'entry-point' || args.importer === entry) {
|
|
113
|
+
const resolved = (0, file_1.resolveFile)(path.resolve(args.resolveDir, args.path));
|
|
114
|
+
return { path: resolved };
|
|
115
|
+
}
|
|
116
|
+
return {
|
|
117
|
+
path: !args.path.startsWith('.') && !args.path.startsWith('/')
|
|
118
|
+
? args.path
|
|
119
|
+
: path.resolve(args.resolveDir, args.path),
|
|
120
|
+
external: true,
|
|
121
|
+
sideEffects: false
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
});
|
|
128
|
+
return (_a = result.outputFiles[0]) === null || _a === void 0 ? void 0 : _a.text;
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
exports.buildToString = buildToString;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { BuildOptions, Plugin as EsbuildPlugin } from 'esbuild';
|
|
2
|
+
export declare const PATH_SEG_RE: RegExp;
|
|
3
|
+
export declare const JS_EXT_RE: RegExp;
|
|
4
|
+
export declare type GetOutputFile = (filepath: string) => string;
|
|
5
|
+
export interface Options {
|
|
6
|
+
cwd?: string;
|
|
7
|
+
/**
|
|
8
|
+
* esbuild options
|
|
9
|
+
*/
|
|
10
|
+
esbuildOptions?: BuildOptions;
|
|
11
|
+
/**
|
|
12
|
+
* Get the path to the output file
|
|
13
|
+
* By default we simply replace the extension with `.bundled.js`
|
|
14
|
+
*/
|
|
15
|
+
getOutputFile?: GetOutputFile;
|
|
16
|
+
/** External packages */
|
|
17
|
+
external?: (string | RegExp)[];
|
|
18
|
+
/**
|
|
19
|
+
* Preserve compiled temporary file for debugging
|
|
20
|
+
* Default to `process.env.BUNDLE_REQUIRE_PRESERVE`
|
|
21
|
+
*/
|
|
22
|
+
preserveTemporaryFile?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export declare const match: (id: string, patterns?: (string | RegExp)[]) => boolean;
|
|
25
|
+
/**
|
|
26
|
+
* An esbuild plugin to mark node_modules as external
|
|
27
|
+
*/
|
|
28
|
+
export declare const externalPlugin: ({ external, notExternal }?: {
|
|
29
|
+
external?: (string | RegExp)[] | undefined;
|
|
30
|
+
notExternal?: (string | RegExp)[] | undefined;
|
|
31
|
+
}) => EsbuildPlugin;
|
|
32
|
+
export declare const replaceDirnamePlugin: () => EsbuildPlugin;
|
|
33
|
+
export declare function bundleRequire(filepath: string, options?: Options): Promise<any>;
|