@shuvi/toolpack 1.0.0-rc.18 → 1.0.0-rc.19

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.
@@ -38,8 +38,8 @@ export declare type SWCLoaderOptions = {
38
38
  filename: string;
39
39
  isServer: boolean;
40
40
  isPageFile: boolean;
41
+ pagePickLoader: boolean;
41
42
  development: boolean;
42
- keep: string[];
43
43
  minify: boolean | Obj;
44
44
  hasReactRefresh: boolean;
45
45
  supportedBrowsers: any[];
@@ -55,7 +55,7 @@ export declare function getParserOptions({ filename, compiler, ...rest }: {
55
55
  decorators: boolean;
56
56
  importAssertions: boolean;
57
57
  };
58
- export default function getLoaderSWCOptions({ filename, development, isServer, minify, isPageFile, hasReactRefresh, compiler, supportedBrowsers, swcCacheDir, keep }: SWCLoaderOptions): {
58
+ export default function getLoaderSWCOptions({ filename, development, isServer, minify, isPageFile, pagePickLoader, hasReactRefresh, compiler, supportedBrowsers, swcCacheDir }: SWCLoaderOptions): {
59
59
  isDevelopment: boolean;
60
60
  jsc: {
61
61
  externalHelpers: boolean;
@@ -104,9 +104,7 @@ export default function getLoaderSWCOptions({ filename, development, isServer, m
104
104
  sourceMaps: undefined;
105
105
  isServer: boolean;
106
106
  isPageFile: boolean;
107
- shakeExports: {
108
- ignore: string[];
109
- } | null;
107
+ pagePickLoader: boolean;
110
108
  cssModuleFlag: string;
111
109
  removeConsole: boolean | undefined;
112
110
  reactRemoveProperties: boolean | undefined;
@@ -22,7 +22,7 @@ function getParserOptions(_a) {
22
22
  [isTypeScript ? 'tsx' : 'jsx']: !isTSFile, importAssertions: true });
23
23
  }
24
24
  exports.getParserOptions = getParserOptions;
25
- function getBaseSWCOptions({ filename, isPageFile, minify, development, hasReactRefresh, isServer, compiler, swcCacheDir, keep }) {
25
+ function getBaseSWCOptions({ filename, isPageFile, pagePickLoader, minify, development, hasReactRefresh, isServer, compiler, swcCacheDir }) {
26
26
  var _a, _b;
27
27
  const parserConfig = getParserOptions({ filename, compiler });
28
28
  const enableDecorators = Boolean(compiler === null || compiler === void 0 ? void 0 : compiler.experimentalDecorators);
@@ -77,7 +77,7 @@ function getBaseSWCOptions({ filename, isPageFile, minify, development, hasReact
77
77
  // shuvi specific
78
78
  isServer,
79
79
  isPageFile,
80
- shakeExports: keep.length > 0 ? { ignore: keep } : null,
80
+ pagePickLoader,
81
81
  cssModuleFlag: 'cssmodules',
82
82
  // advanced
83
83
  removeConsole: compiler === null || compiler === void 0 ? void 0 : compiler.removeConsole,
@@ -131,17 +131,17 @@ function getEmotionOptions(compiler, development) {
131
131
  sourcemap: development ? (_a = emotion.sourceMap) !== null && _a !== void 0 ? _a : true : false
132
132
  };
133
133
  }
134
- function getLoaderSWCOptions({ filename, development, isServer, minify, isPageFile, hasReactRefresh, compiler, supportedBrowsers, swcCacheDir, keep }) {
134
+ function getLoaderSWCOptions({ filename, development, isServer, minify, isPageFile, pagePickLoader, hasReactRefresh, compiler, supportedBrowsers, swcCacheDir }) {
135
135
  let baseOptions = getBaseSWCOptions({
136
136
  filename,
137
137
  isPageFile,
138
+ pagePickLoader,
138
139
  development,
139
140
  isServer,
140
141
  minify,
141
142
  hasReactRefresh,
142
143
  compiler,
143
- swcCacheDir,
144
- keep
144
+ swcCacheDir
145
145
  });
146
146
  if (isServer) {
147
147
  baseOptions.env = {
@@ -15,28 +15,21 @@ Object.defineProperty(exports, "__esModule", { value: true });
15
15
  exports.raw = void 0;
16
16
  const querystring_1 = __importDefault(require("querystring"));
17
17
  const constants_1 = require("@shuvi/shared/lib/constants");
18
- const escapeRegExp_1 = require("@shuvi/utils/lib/escapeRegExp");
19
18
  const compiler_1 = require("@shuvi/compiler");
20
19
  const getLoaderSWCOptions_1 = __importDefault(require("./getLoaderSWCOptions"));
21
- const IS_PAGE_FILE = RegExp((0, escapeRegExp_1.escapeRegExp)(`?${constants_1.ROUTE_RESOURCE_QUERYSTRING}`));
22
20
  function loaderTransform(source, inputSourceMap) {
23
21
  return __awaiter(this, void 0, void 0, function* () {
24
22
  // Make the loader async
25
23
  const filename = this.resourcePath;
26
24
  let loaderOptions = this.getOptions() || {};
27
25
  const { isServer, compiler, supportedBrowsers, swcCacheDir, hasReactRefresh, minify = false } = loaderOptions;
28
- const isPageFile = !!(this.resourceQuery && IS_PAGE_FILE.test(this.resourceQuery));
29
- let keep = [];
26
+ let isPageFile = false;
27
+ let pagePickLoader = false;
30
28
  if (this.resourceQuery) {
31
29
  const query = querystring_1.default.parse(this.resourceQuery.slice(1));
32
- if (query.keep) {
33
- if (Array.isArray(query.keep)) {
34
- keep = query.keep;
35
- }
36
- else {
37
- keep.push(query.keep);
38
- }
39
- }
30
+ pagePickLoader = query[constants_1.LOADER_RESOURCE_QUERYSTRING] !== undefined;
31
+ isPageFile =
32
+ pagePickLoader || query[constants_1.ROUTE_RESOURCE_QUERYSTRING] !== undefined;
40
33
  }
41
34
  const isDevelopment = this.mode === 'development';
42
35
  const swcOptions = (0, getLoaderSWCOptions_1.default)({
@@ -44,8 +37,8 @@ function loaderTransform(source, inputSourceMap) {
44
37
  filename,
45
38
  isServer,
46
39
  isPageFile,
40
+ pagePickLoader,
47
41
  minify,
48
- keep,
49
42
  hasReactRefresh: hasReactRefresh !== undefined
50
43
  ? hasReactRefresh
51
44
  : isDevelopment && !isServer,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shuvi/toolpack",
3
- "version": "1.0.0-rc.18",
3
+ "version": "1.0.0-rc.19",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/shuvijs/shuvi.git",
@@ -20,7 +20,7 @@
20
20
  "node": ">= 12.0.0"
21
21
  },
22
22
  "dependencies": {
23
- "@shuvi/compiler": "1.0.0-rc.18",
23
+ "@shuvi/compiler": "1.0.0-rc.19",
24
24
  "@babel/core": "7.12.10",
25
25
  "@babel/plugin-proposal-class-properties": "7.12.1",
26
26
  "@babel/plugin-proposal-nullish-coalescing-operator": "7.10.1",
@@ -35,8 +35,8 @@
35
35
  "@babel/preset-typescript": "7.12.7",
36
36
  "@babel/runtime": "7.12.5",
37
37
  "lightningcss": "1.15.0",
38
- "@shuvi/shared": "1.0.0-rc.18",
39
- "@shuvi/utils": "1.0.0-rc.18",
38
+ "@shuvi/shared": "1.0.0-rc.19",
39
+ "@shuvi/utils": "1.0.0-rc.19",
40
40
  "babel-loader": "8.2.2",
41
41
  "babel-plugin-syntax-jsx": "6.18.0",
42
42
  "babel-plugin-transform-define": "2.0.0",