@rsbuild/core 0.3.10 → 0.3.11
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/compiled/dotenv/index.js +1 -1
- package/compiled/dotenv/lib/main.d.ts +1 -6
- package/compiled/dotenv/package.json +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/provider/core/createContext.js +1 -1
- package/dist/provider/index.d.ts +1 -0
- package/dist/provider/index.js +3 -0
- package/dist/provider/plugins/swc.d.ts +1 -0
- package/dist/provider/plugins/swc.js +53 -39
- package/package.json +2 -2
package/compiled/dotenv/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={
|
|
1
|
+
(()=>{var e={845:(e,t,r)=>{const o=r(147);const n=r(17);const s=r(37);const c=r(113);const a=r(684);const i=a.version;const u=/(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/gm;function parse(e){const t={};let r=e.toString();r=r.replace(/\r\n?/gm,"\n");let o;while((o=u.exec(r))!=null){const e=o[1];let r=o[2]||"";r=r.trim();const n=r[0];r=r.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(n==='"'){r=r.replace(/\\n/g,"\n");r=r.replace(/\\r/g,"\r")}t[e]=r}return t}function _parseVault(e){const t=_vaultPath(e);const r=l.configDotenv({path:t});if(!r.parsed){throw new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`)}const o=_dotenvKey(e).split(",");const n=o.length;let s;for(let e=0;e<n;e++){try{const t=o[e].trim();const n=_instructions(r,t);s=l.decrypt(n.ciphertext,n.key);break}catch(t){if(e+1>=n){throw t}}}return l.parse(s)}function _log(e){console.log(`[dotenv@${i}][INFO] ${e}`)}function _warn(e){console.log(`[dotenv@${i}][WARN] ${e}`)}function _debug(e){console.log(`[dotenv@${i}][DEBUG] ${e}`)}function _dotenvKey(e){if(e&&e.DOTENV_KEY&&e.DOTENV_KEY.length>0){return e.DOTENV_KEY}if(process.env.DOTENV_KEY&&process.env.DOTENV_KEY.length>0){return process.env.DOTENV_KEY}return""}function _instructions(e,t){let r;try{r=new URL(t)}catch(e){if(e.code==="ERR_INVALID_URL"){throw new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development")}throw e}const o=r.password;if(!o){throw new Error("INVALID_DOTENV_KEY: Missing key part")}const n=r.searchParams.get("environment");if(!n){throw new Error("INVALID_DOTENV_KEY: Missing environment part")}const s=`DOTENV_VAULT_${n.toUpperCase()}`;const c=e.parsed[s];if(!c){throw new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`)}return{ciphertext:c,key:o}}function _vaultPath(e){let t=n.resolve(process.cwd(),".env");if(e&&e.path&&e.path.length>0){t=e.path}return t.endsWith(".vault")?t:`${t}.vault`}function _resolveHome(e){return e[0]==="~"?n.join(s.homedir(),e.slice(1)):e}function _configVault(e){_log("Loading env from encrypted .env.vault");const t=l._parseVault(e);let r=process.env;if(e&&e.processEnv!=null){r=e.processEnv}l.populate(r,t,e);return{parsed:t}}function configDotenv(e){let t=n.resolve(process.cwd(),".env");let r="utf8";const s=Boolean(e&&e.debug);if(e){if(e.path!=null){t=_resolveHome(e.path)}if(e.encoding!=null){r=e.encoding}else{if(s){_debug("No encoding is specified. UTF-8 is used by default")}}}try{const n=l.parse(o.readFileSync(t,{encoding:r}));let s=process.env;if(e&&e.processEnv!=null){s=e.processEnv}l.populate(s,n,e);return{parsed:n}}catch(e){if(s){_debug(`Failed to load ${t} ${e.message}`)}return{error:e}}}function config(e){const t=_vaultPath(e);if(_dotenvKey(e).length===0){return l.configDotenv(e)}if(!o.existsSync(t)){_warn(`You set DOTENV_KEY but you are missing a .env.vault file at ${t}. Did you forget to build it?`);return l.configDotenv(e)}return l._configVault(e)}function decrypt(e,t){const r=Buffer.from(t.slice(-64),"hex");let o=Buffer.from(e,"base64");const n=o.subarray(0,12);const s=o.subarray(-16);o=o.subarray(12,-16);try{const e=c.createDecipheriv("aes-256-gcm",r,n);e.setAuthTag(s);return`${e.update(o)}${e.final()}`}catch(e){const t=e instanceof RangeError;const r=e.message==="Invalid key length";const o=e.message==="Unsupported state or unable to authenticate data";if(t||r){const e="INVALID_DOTENV_KEY: It must be 64 characters long (or more)";throw new Error(e)}else if(o){const e="DECRYPTION_FAILED: Please check your DOTENV_KEY";throw new Error(e)}else{console.error("Error: ",e.code);console.error("Error: ",e.message);throw e}}}function populate(e,t,r={}){const o=Boolean(r&&r.debug);const n=Boolean(r&&r.override);if(typeof t!=="object"){throw new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate")}for(const r of Object.keys(t)){if(Object.prototype.hasOwnProperty.call(e,r)){if(n===true){e[r]=t[r]}if(o){if(n===true){_debug(`"${r}" is already defined and WAS overwritten`)}else{_debug(`"${r}" is already defined and was NOT overwritten`)}}}else{e[r]=t[r]}}}const l={configDotenv:configDotenv,_configVault:_configVault,_parseVault:_parseVault,config:config,decrypt:decrypt,parse:parse,populate:populate};e.exports.configDotenv=l.configDotenv;e.exports._configVault=l._configVault;e.exports._parseVault=l._parseVault;e.exports.config=l.config;e.exports.decrypt=l.decrypt;e.exports.parse=l.parse;e.exports.populate=l.populate;e.exports=l},684:e=>{"use strict";e.exports=require("./package.json")},113:e=>{"use strict";e.exports=require("crypto")},147:e=>{"use strict";e.exports=require("fs")},37:e=>{"use strict";e.exports=require("os")},17:e=>{"use strict";e.exports=require("path")}};var t={};function __nccwpck_require__(r){var o=t[r];if(o!==undefined){return o.exports}var n=t[r]={exports:{}};var s=true;try{e[r](n,n.exports,__nccwpck_require__);s=false}finally{if(s)delete t[r]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var r=__nccwpck_require__(845);module.exports=r})();
|
|
@@ -12,7 +12,6 @@ export interface DotenvParseOutput {
|
|
|
12
12
|
* See https://docs.dotenv.org
|
|
13
13
|
*
|
|
14
14
|
* @param src - contents to be parsed. example: `'DB_HOST=localhost'`
|
|
15
|
-
* @param options - additional options. example: `{ debug: true }`
|
|
16
15
|
* @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }`
|
|
17
16
|
*/
|
|
18
17
|
export function parse<T extends DotenvParseOutput = DotenvParseOutput>(
|
|
@@ -100,10 +99,6 @@ export interface DotenvPopulateOptions {
|
|
|
100
99
|
override?: boolean;
|
|
101
100
|
}
|
|
102
101
|
|
|
103
|
-
export interface DotenvPopulateOutput {
|
|
104
|
-
error?: Error;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
102
|
export interface DotenvPopulateInput {
|
|
108
103
|
[name: string]: string;
|
|
109
104
|
}
|
|
@@ -141,7 +136,7 @@ export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput;
|
|
|
141
136
|
* @returns {void}
|
|
142
137
|
*
|
|
143
138
|
*/
|
|
144
|
-
export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions):
|
|
139
|
+
export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulateInput, options?: DotenvConfigOptions): void;
|
|
145
140
|
|
|
146
141
|
/**
|
|
147
142
|
* Decrypt ciphertext
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"dotenv","version":"16.3.
|
|
1
|
+
{"name":"dotenv","version":"16.3.2","funding":"https://github.com/motdotla/dotenv?sponsor=1","license":"BSD-2-Clause","types":"lib/main.d.ts","type":"commonjs"}
|
package/dist/cli/commands.js
CHANGED
|
@@ -112,7 +112,7 @@ const applyServerOptions = (command) => {
|
|
|
112
112
|
command.option("-o --open [url]", "open the page in browser on startup").option("--port <port>", "specify a port number for server to listen").option("--host <host>", "specify the host that the server listens to");
|
|
113
113
|
};
|
|
114
114
|
function runCli() {
|
|
115
|
-
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.
|
|
115
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.3.11");
|
|
116
116
|
const devCommand = import_commander.program.command("dev");
|
|
117
117
|
const buildCommand = import_commander.program.command("build");
|
|
118
118
|
const previewCommand = import_commander.program.command("preview");
|
package/dist/cli/prepare.js
CHANGED
|
@@ -34,7 +34,7 @@ function prepareCli() {
|
|
|
34
34
|
if (!npm_execpath || npm_execpath.includes("npx-cli.js")) {
|
|
35
35
|
console.log();
|
|
36
36
|
}
|
|
37
|
-
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.3.11"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -38,7 +38,7 @@ var import_createRsbuild = require("./createRsbuild");
|
|
|
38
38
|
var import_config = require("./cli/config");
|
|
39
39
|
var import_shared = require("@rsbuild/shared");
|
|
40
40
|
var import_constants = require("./constants");
|
|
41
|
-
const version = "0.3.
|
|
41
|
+
const version = "0.3.11";
|
|
42
42
|
// Annotate the CommonJS export names for ESM import in node:
|
|
43
43
|
0 && (module.exports = {
|
|
44
44
|
PLUGIN_BABEL_NAME,
|
package/dist/provider/index.d.ts
CHANGED
|
@@ -10,3 +10,4 @@ export type { InternalContext } from '../types';
|
|
|
10
10
|
export { setHTMLPlugin, getHTMLPlugin } from './htmlPluginUtil';
|
|
11
11
|
export { formatStats } from './shared';
|
|
12
12
|
export { getChainUtils } from './core/rspackConfig';
|
|
13
|
+
export { applySwcDecoratorConfig } from './plugins/swc';
|
package/dist/provider/index.js
CHANGED
|
@@ -20,6 +20,7 @@ var provider_exports = {};
|
|
|
20
20
|
__export(provider_exports, {
|
|
21
21
|
applyBaseCSSRule: () => import_css.applyBaseCSSRule,
|
|
22
22
|
applyCSSModuleRule: () => import_css.applyCSSModuleRule,
|
|
23
|
+
applySwcDecoratorConfig: () => import_swc.applySwcDecoratorConfig,
|
|
23
24
|
createContext: () => import_createContext.createContext,
|
|
24
25
|
createPublicContext: () => import_createContext.createPublicContext,
|
|
25
26
|
formatStats: () => import_shared2.formatStats,
|
|
@@ -43,10 +44,12 @@ var import_css = require("./plugins/css");
|
|
|
43
44
|
var import_htmlPluginUtil = require("./htmlPluginUtil");
|
|
44
45
|
var import_shared2 = require("./shared");
|
|
45
46
|
var import_rspackConfig = require("./core/rspackConfig");
|
|
47
|
+
var import_swc = require("./plugins/swc");
|
|
46
48
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
49
|
0 && (module.exports = {
|
|
48
50
|
applyBaseCSSRule,
|
|
49
51
|
applyCSSModuleRule,
|
|
52
|
+
applySwcDecoratorConfig,
|
|
50
53
|
createContext,
|
|
51
54
|
createPublicContext,
|
|
52
55
|
formatStats,
|
|
@@ -5,3 +5,4 @@ export declare function getDefaultSwcConfig(config: NormalizedConfig, rootPath:
|
|
|
5
5
|
* Provide some swc configs of rspack
|
|
6
6
|
*/
|
|
7
7
|
export declare const pluginSwc: () => RsbuildPlugin;
|
|
8
|
+
export declare function applySwcDecoratorConfig(swcConfig: BuiltinSwcLoaderOptions, config: NormalizedConfig): void;
|
|
@@ -28,6 +28,7 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
28
28
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
29
29
|
var swc_exports = {};
|
|
30
30
|
__export(swc_exports, {
|
|
31
|
+
applySwcDecoratorConfig: () => applySwcDecoratorConfig,
|
|
31
32
|
getDefaultSwcConfig: () => getDefaultSwcConfig,
|
|
32
33
|
pluginSwc: () => pluginSwc
|
|
33
34
|
});
|
|
@@ -59,42 +60,45 @@ async function getDefaultSwcConfig(config, rootPath, target) {
|
|
|
59
60
|
const pluginSwc = () => ({
|
|
60
61
|
name: import_constants.PLUGIN_SWC_NAME,
|
|
61
62
|
setup(api) {
|
|
62
|
-
api.modifyBundlerChain(
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
rule
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
applyDecorator(swcConfig, config.output.enableLatestDecorators);
|
|
79
|
-
if (swcConfig.jsc?.externalHelpers) {
|
|
80
|
-
chain.resolve.alias.set(
|
|
81
|
-
"@swc/helpers",
|
|
82
|
-
import_node_path.default.dirname(require.resolve("@swc/helpers/package.json"))
|
|
63
|
+
api.modifyBundlerChain({
|
|
64
|
+
order: "pre",
|
|
65
|
+
handler: async (chain, { CHAIN_ID, target }) => {
|
|
66
|
+
const config = api.getNormalizedConfig();
|
|
67
|
+
const rule = chain.module.rule(CHAIN_ID.RULE.JS).test(import_shared.SCRIPT_REGEX).type("javascript/auto");
|
|
68
|
+
(0, import_shared.applyScriptCondition)({
|
|
69
|
+
rule,
|
|
70
|
+
config,
|
|
71
|
+
context: api.context,
|
|
72
|
+
includes: [],
|
|
73
|
+
excludes: []
|
|
74
|
+
});
|
|
75
|
+
const swcConfig = await getDefaultSwcConfig(
|
|
76
|
+
config,
|
|
77
|
+
api.context.rootPath,
|
|
78
|
+
target
|
|
83
79
|
);
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
80
|
+
applyTransformImport(swcConfig, config.source.transformImport);
|
|
81
|
+
applySwcDecoratorConfig(swcConfig, config);
|
|
82
|
+
if (swcConfig.jsc?.externalHelpers) {
|
|
83
|
+
chain.resolve.alias.set(
|
|
84
|
+
"@swc/helpers",
|
|
85
|
+
import_node_path.default.dirname(require.resolve("@swc/helpers/package.json"))
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
if ((0, import_shared.isWebTarget)(target)) {
|
|
89
|
+
const polyfillMode = config.output.polyfill;
|
|
90
|
+
if (polyfillMode === "off" || polyfillMode === "ua") {
|
|
91
|
+
swcConfig.env.mode = void 0;
|
|
92
|
+
} else {
|
|
93
|
+
swcConfig.env.mode = polyfillMode;
|
|
94
|
+
await applyCoreJs(swcConfig, chain, polyfillMode);
|
|
95
|
+
}
|
|
92
96
|
}
|
|
97
|
+
rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
|
|
98
|
+
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
99
|
+
or: ["text/javascript", "application/javascript"]
|
|
100
|
+
}).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
|
|
93
101
|
}
|
|
94
|
-
rule.use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options(swcConfig);
|
|
95
|
-
chain.module.rule(CHAIN_ID.RULE.JS_DATA_URI).mimetype({
|
|
96
|
-
or: ["text/javascript", "application/javascript"]
|
|
97
|
-
}).use(CHAIN_ID.USE.SWC).loader(builtinSwcLoaderName).options((0, import_shared.cloneDeep)(swcConfig));
|
|
98
102
|
});
|
|
99
103
|
}
|
|
100
104
|
});
|
|
@@ -118,17 +122,27 @@ function applyTransformImport(swcConfig, pluginImport) {
|
|
|
118
122
|
swcConfig.rspackExperiments.import.push(...pluginImport);
|
|
119
123
|
}
|
|
120
124
|
}
|
|
121
|
-
function
|
|
125
|
+
function applySwcDecoratorConfig(swcConfig, config) {
|
|
122
126
|
var _a;
|
|
123
|
-
|
|
124
|
-
|
|
127
|
+
swcConfig.jsc || (swcConfig.jsc = {});
|
|
128
|
+
(_a = swcConfig.jsc).transform || (_a.transform = {});
|
|
129
|
+
const { version } = config.source.decorators;
|
|
130
|
+
switch (version) {
|
|
131
|
+
case "legacy":
|
|
132
|
+
swcConfig.jsc.transform.legacyDecorator = true;
|
|
133
|
+
swcConfig.jsc.transform.decoratorMetadata = true;
|
|
134
|
+
break;
|
|
135
|
+
case "2022-03":
|
|
136
|
+
swcConfig.jsc.transform.legacyDecorator = false;
|
|
137
|
+
swcConfig.jsc.transform.decoratorVersion = "2022-03";
|
|
138
|
+
break;
|
|
139
|
+
default:
|
|
140
|
+
throw new Error("Unknown decorators version: ${version}");
|
|
125
141
|
}
|
|
126
|
-
(_a = swcConfig.jsc).transform ?? (_a.transform = {});
|
|
127
|
-
swcConfig.jsc.transform.legacyDecorator = true;
|
|
128
|
-
swcConfig.jsc.transform.decoratorMetadata = true;
|
|
129
142
|
}
|
|
130
143
|
// Annotate the CommonJS export names for ESM import in node:
|
|
131
144
|
0 && (module.exports = {
|
|
145
|
+
applySwcDecoratorConfig,
|
|
132
146
|
getDefaultSwcConfig,
|
|
133
147
|
pluginSwc
|
|
134
148
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "The Rspack-based build tool.",
|
|
5
5
|
"homepage": "https://rsbuild.dev",
|
|
6
6
|
"bugs": {
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"core-js": "~3.32.2",
|
|
58
58
|
"html-webpack-plugin": "npm:html-rspack-plugin@5.5.7",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.3.
|
|
60
|
+
"@rsbuild/shared": "0.3.11"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|