@shuvi/toolpack 1.0.0-rc.1 → 1.0.0-rc.12
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/{loadable-plugin.d.ts → dynamic-plugin.d.ts} +1 -1
- package/lib/babel/plugins/{loadable-plugin.js → dynamic-plugin.js} +8 -8
- package/lib/babel/preset.js +1 -1
- package/lib/constants.d.ts +1 -0
- package/lib/constants.js +2 -1
- package/lib/utils/formatWebpackMessages.d.ts +18 -4
- package/lib/utils/formatWebpackMessages.js +15 -13
- package/lib/webpack/config/base.d.ts +3 -1
- package/lib/webpack/config/base.js +43 -22
- package/lib/webpack/config/browser.js +47 -31
- package/lib/webpack/config/node.js +3 -3
- package/lib/webpack/config/parts/helpers.d.ts +1 -0
- package/lib/webpack/config/parts/helpers.js +8 -1
- package/lib/webpack/config/parts/style.js +0 -6
- package/lib/webpack/dynamic-dll/bundler/webpack-config.js +1 -1
- package/lib/webpack/dynamic-dll/index.d.ts +2 -2
- package/lib/webpack/dynamic-dll/index.js +26 -26
- package/lib/webpack/dynamic-dll/plugin/dynamic-dll-plugin.js +0 -1
- package/lib/webpack/index.d.ts +3 -5
- package/lib/webpack/index.js +4 -6
- package/lib/webpack/loaders/parcel-css-loader/CssSyntaxError.d.ts +9 -2
- package/lib/webpack/loaders/parcel-css-loader/CssSyntaxError.js +2 -1
- package/lib/webpack/loaders/shuvi-swc-loader/getLoaderSWCOptions.d.ts +94 -0
- package/lib/webpack/loaders/shuvi-swc-loader/getLoaderSWCOptions.js +162 -0
- package/lib/webpack/loaders/{shuvi-swc-loader.d.ts → shuvi-swc-loader/index.d.ts} +0 -0
- package/lib/webpack/loaders/{shuvi-swc-loader.js → shuvi-swc-loader/index.js} +50 -86
- package/lib/webpack/plugins/dynamic-public-path-plugin.js +3 -2
- package/lib/webpack/plugins/module-replace-plugin/plugin.d.ts +1 -0
- package/lib/webpack/plugins/module-replace-plugin/plugin.js +9 -1
- package/package.json +13 -48
- package/lib/swc/tests/fixture/auto-css-module/no-flag/input.d.ts +0 -1
- package/lib/swc/tests/fixture/auto-css-module/no-flag/input.js +0 -4
- package/lib/swc/tests/fixture/auto-css-module/no-flag/output.d.ts +0 -1
- package/lib/swc/tests/fixture/auto-css-module/no-flag/output.js +0 -4
- package/lib/swc/tests/fixture/auto-css-module/with-flag/input.d.ts +0 -1
- package/lib/swc/tests/fixture/auto-css-module/with-flag/input.js +0 -2
- package/lib/swc/tests/fixture/auto-css-module/with-flag/output.d.ts +0 -1
- package/lib/swc/tests/fixture/auto-css-module/with-flag/output.js +0 -2
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/input.js +0 -5
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/duplicated-imports/output.js +0 -11
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/input.js +0 -9
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/member-with-same-name/output.js +0 -12
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/input.js +0 -4
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/no-options/output.js +0 -7
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/input.js +0 -4
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/with-options/output.js +0 -8
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/input.js +0 -7
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic/wrapped-import/output.js +0 -9
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/input.js +0 -5
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/duplicated-imports/output.js +0 -11
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/input.js +0 -9
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/member-with-same-name/output.js +0 -12
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/input.js +0 -4
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/no-options/output.js +0 -7
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/input.js +0 -4
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/with-options/output.js +0 -8
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/input.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/input.js +0 -7
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/output.d.ts +0 -1
- package/lib/swc/tests/fixture/shuvi-dynamic-disabled/wrapped-import/output.js +0 -9
- package/lib/swc/tests/full/auto-cjs/1/input.d.ts +0 -1
- package/lib/swc/tests/full/auto-cjs/1/input.js +0 -8
- package/lib/swc/tests/full/auto-cjs/1/output.d.ts +0 -1
- package/lib/swc/tests/full/auto-cjs/1/output.js +0 -8
- package/lib/utils/build-loaders.d.ts +0 -2
- package/lib/utils/build-loaders.js +0 -131
- package/lib/utils/hotDevClient/eventsource.d.ts +0 -1
- package/lib/utils/hotDevClient/eventsource.js +0 -64
- package/lib/utils/hotDevClient/index.d.ts +0 -4
- package/lib/utils/hotDevClient/index.js +0 -362
- package/lib/utils/load-sources.d.ts +0 -3
- package/lib/utils/load-sources.js +0 -94
- package/swc-source/native/shuvi-swc.darwin-arm64.node +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
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'));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
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, "...") });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,5 +0,0 @@
|
|
|
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'));
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,11 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,12 +0,0 @@
|
|
|
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');
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,4 +0,0 @@
|
|
|
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, "...") });
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,9 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,8 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,131 +0,0 @@
|
|
|
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;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export function getEventSourceWrapper(options: any): any;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getEventSourceWrapper = void 0;
|
|
4
|
-
const eventCallbacks = [];
|
|
5
|
-
function EventSourceWrapper(options) {
|
|
6
|
-
var source;
|
|
7
|
-
var lastActivity = new Date();
|
|
8
|
-
var listeners = [];
|
|
9
|
-
if (!options.timeout) {
|
|
10
|
-
options.timeout = 20 * 1000;
|
|
11
|
-
}
|
|
12
|
-
init();
|
|
13
|
-
var timer = setInterval(function () {
|
|
14
|
-
if (new Date() - lastActivity > options.timeout) {
|
|
15
|
-
handleDisconnect();
|
|
16
|
-
}
|
|
17
|
-
}, options.timeout / 2);
|
|
18
|
-
function init() {
|
|
19
|
-
source = new window.EventSource(options.path);
|
|
20
|
-
source.onopen = handleOnline;
|
|
21
|
-
source.onerror = handleDisconnect;
|
|
22
|
-
source.onmessage = handleMessage;
|
|
23
|
-
}
|
|
24
|
-
function handleOnline() {
|
|
25
|
-
if (options.log)
|
|
26
|
-
console.log("[HMR] connected");
|
|
27
|
-
lastActivity = new Date();
|
|
28
|
-
}
|
|
29
|
-
function handleMessage(event) {
|
|
30
|
-
lastActivity = new Date();
|
|
31
|
-
for (var i = 0; i < listeners.length; i++) {
|
|
32
|
-
listeners[i](event);
|
|
33
|
-
}
|
|
34
|
-
if (event.data.indexOf("action") !== -1) {
|
|
35
|
-
eventCallbacks.forEach(cb => cb(event));
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
function handleDisconnect() {
|
|
39
|
-
clearInterval(timer);
|
|
40
|
-
source.close();
|
|
41
|
-
setTimeout(init, options.timeout);
|
|
42
|
-
}
|
|
43
|
-
return {
|
|
44
|
-
onclose: () => {
|
|
45
|
-
clearTimeout(timer);
|
|
46
|
-
source.close();
|
|
47
|
-
},
|
|
48
|
-
addMessageListener: function (fn) {
|
|
49
|
-
listeners.push(fn);
|
|
50
|
-
}
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
function getEventSourceWrapper(options) {
|
|
54
|
-
if (!window.__whmEventSourceWrapper) {
|
|
55
|
-
window.__whmEventSourceWrapper = {};
|
|
56
|
-
}
|
|
57
|
-
if (!window.__whmEventSourceWrapper[options.path]) {
|
|
58
|
-
// cache the wrapper for other entries loaded on
|
|
59
|
-
// the same page with the same options.path
|
|
60
|
-
window.__whmEventSourceWrapper[options.path] = EventSourceWrapper(options);
|
|
61
|
-
}
|
|
62
|
-
return window.__whmEventSourceWrapper[options.path];
|
|
63
|
-
}
|
|
64
|
-
exports.getEventSourceWrapper = getEventSourceWrapper;
|