@rsbuild/core 0.4.5 → 0.4.6
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/package.json +1 -1
- package/compiled/dotenv-expand/index.js +1 -1
- package/compiled/dotenv-expand/lib/main.d.ts +30 -9
- package/compiled/dotenv-expand/package.json +1 -1
- package/dist/cli/commands.js +1 -1
- package/dist/cli/config.d.ts +1 -1
- package/dist/cli/config.js +1 -1
- package/dist/cli/prepare.js +1 -1
- package/dist/index.js +1 -1
- package/dist/plugins/entry.d.ts +3 -1
- package/dist/plugins/entry.js +32 -17
- package/dist/provider/createContext.js +4 -3
- package/package.json +2 -2
package/compiled/dotenv/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{var e={
|
|
1
|
+
(()=>{var e={434:(e,t,o)=>{const r=o(147);const n=o(17);const s=o(37);const c=o(113);const a=o(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 o=e.toString();o=o.replace(/\r\n?/gm,"\n");let r;while((r=u.exec(o))!=null){const e=r[1];let o=r[2]||"";o=o.trim();const n=o[0];o=o.replace(/^(['"`])([\s\S]*)\1$/gm,"$2");if(n==='"'){o=o.replace(/\\n/g,"\n");o=o.replace(/\\r/g,"\r")}t[e]=o}return t}function _parseVault(e){const t=_vaultPath(e);const o=l.configDotenv({path:t});if(!o.parsed){const e=new Error(`MISSING_DATA: Cannot parse ${t} for an unknown reason`);e.code="MISSING_DATA";throw e}const r=_dotenvKey(e).split(",");const n=r.length;let s;for(let e=0;e<n;e++){try{const t=r[e].trim();const n=_instructions(o,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 o;try{o=new URL(t)}catch(e){if(e.code==="ERR_INVALID_URL"){const e=new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");e.code="INVALID_DOTENV_KEY";throw e}throw e}const r=o.password;if(!r){const e=new Error("INVALID_DOTENV_KEY: Missing key part");e.code="INVALID_DOTENV_KEY";throw e}const n=o.searchParams.get("environment");if(!n){const e=new Error("INVALID_DOTENV_KEY: Missing environment part");e.code="INVALID_DOTENV_KEY";throw e}const s=`DOTENV_VAULT_${n.toUpperCase()}`;const c=e.parsed[s];if(!c){const e=new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${s} in your .env.vault file.`);e.code="NOT_FOUND_DOTENV_ENVIRONMENT";throw e}return{ciphertext:c,key:r}}function _vaultPath(e){let t=null;if(e&&e.path&&e.path.length>0){if(Array.isArray(e.path)){for(const o of e.path){if(r.existsSync(o)){t=o.endsWith(".vault")?o:`${o}.vault`}}}else{t=e.path.endsWith(".vault")?e.path:`${e.path}.vault`}}else{t=n.resolve(process.cwd(),".env.vault")}if(r.existsSync(t)){return t}return null}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 o=process.env;if(e&&e.processEnv!=null){o=e.processEnv}l.populate(o,t,e);return{parsed:t}}function configDotenv(e){const t=n.resolve(process.cwd(),".env");let o="utf8";const s=Boolean(e&&e.debug);if(e&&e.encoding){o=e.encoding}else{if(s){_debug("No encoding is specified. UTF-8 is used by default")}}let c=[];if(e&&e.path){if(!Array.isArray(e.path)){if(r.existsSync(e.path)){c=[_resolveHome(e.path)]}}else{for(const t of e.path){if(r.existsSync(t)){c.push(_resolveHome(t))}}}if(!c.length){c=[t]}}const a=c.length?c:[t];const i={};try{for(const t of a){const n=l.parse(r.readFileSync(t,{encoding:o}));l.populate(i,n,e)}let t=process.env;if(e&&e.processEnv!=null){t=e.processEnv}l.populate(t,i,e)}catch(e){if(s){_debug(`Failed to load ${a} ${e.message}`)}return{error:e}}return{parsed:i}}function config(e){if(_dotenvKey(e).length===0){return l.configDotenv(e)}const t=_vaultPath(e);if(!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 o=Buffer.from(t.slice(-64),"hex");let r=Buffer.from(e,"base64");const n=r.subarray(0,12);const s=r.subarray(-16);r=r.subarray(12,-16);try{const e=c.createDecipheriv("aes-256-gcm",o,n);e.setAuthTag(s);return`${e.update(r)}${e.final()}`}catch(e){const t=e instanceof RangeError;const o=e.message==="Invalid key length";const r=e.message==="Unsupported state or unable to authenticate data";if(t||o){const e=new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");e.code="INVALID_DOTENV_KEY";throw e}else if(r){const e=new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");e.code="DECRYPTION_FAILED";throw e}else{throw e}}}function populate(e,t,o={}){const r=Boolean(o&&o.debug);const n=Boolean(o&&o.override);if(typeof t!=="object"){const e=new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");e.code="OBJECT_REQUIRED";throw e}for(const o of Object.keys(t)){if(Object.prototype.hasOwnProperty.call(e,o)){if(n===true){e[o]=t[o]}if(r){if(n===true){_debug(`"${o}" is already defined and WAS overwritten`)}else{_debug(`"${o}" is already defined and was NOT overwritten`)}}}else{e[o]=t[o]}}}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__(o){var r=t[o];if(r!==undefined){return r.exports}var n=t[o]={exports:{}};var s=true;try{e[o](n,n.exports,__nccwpck_require__);s=false}finally{if(s)delete t[o]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var o=__nccwpck_require__(434);module.exports=o})();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"dotenv","version":"16.4.
|
|
1
|
+
{"name":"dotenv","version":"16.4.4","funding":"https://dotenvx.com","license":"BSD-2-Clause","types":"lib/main.d.ts","type":"commonjs"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
(()=>{"use strict";var e={
|
|
1
|
+
(()=>{"use strict";var e={693:e=>{const r=/(\\)?(\$)(?!\()(\{?)([\w.]+)(?::?-((?:\$\{(?:\$\{(?:\$\{[^}]*\}|[^}])*}|[^}])*}|[^}])+))?(\}?)/gi;function _resolveEscapeSequences(e){return e.replace(/\\\$/g,"$")}function interpolate(e,t,n){return e.replace(r,((r,s,a,p,i,o,u)=>{if(s==="\\"){return r.slice(1)}else{if(t[i]){if(t[i]===n[i]){return t[i]}else{return interpolate(t[i],t,n)}}if(n[i]){if(n[i]===e){return n[i]}else{return interpolate(n[i],t,n)}}if(o){if(o.startsWith("$")){return interpolate(o,t,n)}else{return o}}return""}}))}function expand(e){let r=process.env;if(e&&e.processEnv!=null){r=e.processEnv}for(const t in e.parsed){let n=e.parsed[t];const s=Object.prototype.hasOwnProperty.call(r,t);if(s){if(r[t]===e.parsed[t]){n=interpolate(n,r,e.parsed)}else{n=r[t]}}else{n=interpolate(n,r,e.parsed)}e.parsed[t]=_resolveEscapeSequences(n)}for(const t in e.parsed){r[t]=e.parsed[t]}return e}e.exports.expand=expand}};var r={};function __nccwpck_require__(t){var n=r[t];if(n!==undefined){return n.exports}var s=r[t]={exports:{}};var a=true;try{e[t](s,s.exports,__nccwpck_require__);a=false}finally{if(a)delete r[t]}return s.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(693);module.exports=t})();
|
|
@@ -1,20 +1,41 @@
|
|
|
1
1
|
// TypeScript Version: 3.0
|
|
2
2
|
/// <reference types="node" />
|
|
3
3
|
|
|
4
|
+
export interface DotenvPopulateInput {
|
|
5
|
+
[name: string]: string;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface DotenvParseInput {
|
|
9
|
+
[name: string]: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DotenvParseOutput {
|
|
13
|
+
[name: string]: string;
|
|
14
|
+
}
|
|
15
|
+
|
|
4
16
|
export interface DotenvExpandOptions {
|
|
5
|
-
ignoreProcessEnv?: boolean;
|
|
6
17
|
error?: Error;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Default: `process.env`
|
|
21
|
+
*
|
|
22
|
+
* Specify an object to write your secrets to. Defaults to process.env environment variables.
|
|
23
|
+
*
|
|
24
|
+
* example: `const processEnv = {}; require('dotenv').config({ processEnv: processEnv })`
|
|
25
|
+
*/
|
|
26
|
+
processEnv?: DotenvPopulateInput;
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Default: `object`
|
|
30
|
+
*
|
|
31
|
+
* Object coming from dotenv's parsed result.
|
|
32
|
+
*/
|
|
33
|
+
parsed?: DotenvParseInput;
|
|
10
34
|
}
|
|
11
35
|
|
|
12
36
|
export interface DotenvExpandOutput {
|
|
13
|
-
ignoreProcessEnv?: boolean;
|
|
14
37
|
error?: Error;
|
|
15
|
-
parsed?:
|
|
16
|
-
[name: string]: string;
|
|
17
|
-
};
|
|
38
|
+
parsed?: DotenvParseOutput;
|
|
18
39
|
}
|
|
19
40
|
|
|
20
41
|
/**
|
|
@@ -22,7 +43,7 @@ export interface DotenvExpandOutput {
|
|
|
22
43
|
*
|
|
23
44
|
* See https://docs.dotenv.org
|
|
24
45
|
*
|
|
25
|
-
* @param options - additional options. example: `{
|
|
46
|
+
* @param options - additional options. example: `{ processEnv: {}, error: null, parsed: { { KEY: 'value' } }`
|
|
26
47
|
* @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } }
|
|
27
48
|
*
|
|
28
49
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"dotenv-expand","author":"motdotla","version":"
|
|
1
|
+
{"name":"dotenv-expand","author":"motdotla","version":"11.0.6","funding":"https://dotenvx.com","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.4.
|
|
115
|
+
import_commander.program.name("rsbuild").usage("<command> [options]").version("0.4.6");
|
|
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/config.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ export declare function defineConfig(config: RsbuildConfigAsyncFn): RsbuildConfi
|
|
|
17
17
|
export declare function defineConfig(config: RsbuildConfigExport): RsbuildConfigExport;
|
|
18
18
|
export declare function watchFiles(files: string[]): Promise<void>;
|
|
19
19
|
export declare function loadConfig({ cwd, path, envMode, }: {
|
|
20
|
-
cwd
|
|
20
|
+
cwd?: string;
|
|
21
21
|
path?: string;
|
|
22
22
|
envMode?: string;
|
|
23
23
|
}): Promise<{
|
package/dist/cli/config.js
CHANGED
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.4.
|
|
37
|
+
import_rslog.logger.greet(` ${`Rsbuild v${"0.4.6"}`}
|
|
38
38
|
`);
|
|
39
39
|
}
|
|
40
40
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/index.js
CHANGED
|
@@ -37,7 +37,7 @@ var import_createRsbuild = require("./createRsbuild");
|
|
|
37
37
|
var import_config = require("./cli/config");
|
|
38
38
|
var import_shared = require("@rsbuild/shared");
|
|
39
39
|
var import_constants = require("./constants");
|
|
40
|
-
const version = "0.4.
|
|
40
|
+
const version = "0.4.6";
|
|
41
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
42
42
|
0 && (module.exports = {
|
|
43
43
|
PLUGIN_CSS_NAME,
|
package/dist/plugins/entry.d.ts
CHANGED
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type RsbuildEntry, type RsbuildTarget } from '@rsbuild/shared';
|
|
2
|
+
import type { NormalizedConfig, RsbuildConfig, RsbuildPlugin } from '../types';
|
|
3
|
+
export declare function getEntryObject(config: RsbuildConfig | NormalizedConfig, target: RsbuildTarget): RsbuildEntry;
|
|
2
4
|
export declare const pluginEntry: () => RsbuildPlugin;
|
package/dist/plugins/entry.js
CHANGED
|
@@ -18,30 +18,44 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var entry_exports = {};
|
|
20
20
|
__export(entry_exports, {
|
|
21
|
+
getEntryObject: () => getEntryObject,
|
|
21
22
|
pluginEntry: () => pluginEntry
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(entry_exports);
|
|
24
25
|
var import_shared = require("@rsbuild/shared");
|
|
26
|
+
function getEntryObject(config, target) {
|
|
27
|
+
if (!config.source?.entry) {
|
|
28
|
+
return {};
|
|
29
|
+
}
|
|
30
|
+
return (0, import_shared.mergeChainedOptions)({
|
|
31
|
+
defaults: {},
|
|
32
|
+
options: config.source?.entry,
|
|
33
|
+
utils: { target },
|
|
34
|
+
useObjectParam: true
|
|
35
|
+
});
|
|
36
|
+
}
|
|
25
37
|
const pluginEntry = () => ({
|
|
26
38
|
name: "rsbuild:entry",
|
|
27
39
|
setup(api) {
|
|
28
|
-
api.modifyBundlerChain(
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
api.modifyBundlerChain(
|
|
41
|
+
async (chain, { target, isServer, isServiceWorker }) => {
|
|
42
|
+
const config = api.getNormalizedConfig();
|
|
43
|
+
const { preEntry } = config.source;
|
|
44
|
+
const entry = target === "web" ? api.context.entry : getEntryObject(config, target);
|
|
45
|
+
const injectCoreJsEntry = config.output.polyfill === "entry" && !isServer && !isServiceWorker;
|
|
46
|
+
Object.keys(entry).forEach((entryName) => {
|
|
47
|
+
const entryPoint = chain.entry(entryName);
|
|
48
|
+
const addEntry = (item) => {
|
|
49
|
+
entryPoint.add(item);
|
|
50
|
+
};
|
|
51
|
+
preEntry.forEach(addEntry);
|
|
52
|
+
if (injectCoreJsEntry) {
|
|
53
|
+
addEntry((0, import_shared.createVirtualModule)('import "core-js";'));
|
|
54
|
+
}
|
|
55
|
+
(0, import_shared.castArray)(entry[entryName]).forEach(addEntry);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
);
|
|
45
59
|
api.onBeforeCreateCompiler(({ bundlerConfigs }) => {
|
|
46
60
|
if (bundlerConfigs.every((config) => !config.entry)) {
|
|
47
61
|
throw new Error(
|
|
@@ -57,5 +71,6 @@ const pluginEntry = () => ({
|
|
|
57
71
|
});
|
|
58
72
|
// Annotate the CommonJS export names for ESM import in node:
|
|
59
73
|
0 && (module.exports = {
|
|
74
|
+
getEntryObject,
|
|
60
75
|
pluginEntry
|
|
61
76
|
});
|
|
@@ -27,6 +27,7 @@ var import_node_path = require("node:path");
|
|
|
27
27
|
var import_shared = require("@rsbuild/shared");
|
|
28
28
|
var import_initHooks = require("./initHooks");
|
|
29
29
|
var import_config = require("./config");
|
|
30
|
+
var import_entry = require("../plugins/entry");
|
|
30
31
|
function getAbsolutePath(root, filepath) {
|
|
31
32
|
return (0, import_node_path.isAbsolute)(filepath) ? filepath : (0, import_node_path.join)(root, filepath);
|
|
32
33
|
}
|
|
@@ -41,9 +42,9 @@ async function createContextByConfig(options, bundlerType, config = {}) {
|
|
|
41
42
|
const cachePath = (0, import_node_path.join)(rootPath, "node_modules", ".cache");
|
|
42
43
|
const tsconfigPath = config.source?.tsconfigPath;
|
|
43
44
|
const context = {
|
|
44
|
-
entry: config
|
|
45
|
+
entry: (0, import_entry.getEntryObject)(config, "web"),
|
|
45
46
|
targets: config.output?.targets || [],
|
|
46
|
-
version: "0.4.
|
|
47
|
+
version: "0.4.6",
|
|
47
48
|
rootPath,
|
|
48
49
|
distPath,
|
|
49
50
|
cachePath,
|
|
@@ -56,7 +57,7 @@ function updateContextByNormalizedConfig(context, config) {
|
|
|
56
57
|
context.targets = config.output.targets;
|
|
57
58
|
context.distPath = getAbsoluteDistPath(context.rootPath, config);
|
|
58
59
|
if (config.source.entry) {
|
|
59
|
-
context.entry = config
|
|
60
|
+
context.entry = (0, import_entry.getEntryObject)(config, "web");
|
|
60
61
|
}
|
|
61
62
|
if (config.source.tsconfigPath) {
|
|
62
63
|
context.tsconfigPath = getAbsolutePath(
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rsbuild/core",
|
|
3
|
-
"version": "0.4.
|
|
3
|
+
"version": "0.4.6",
|
|
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.6.0",
|
|
59
59
|
"postcss": "^8.4.33",
|
|
60
|
-
"@rsbuild/shared": "0.4.
|
|
60
|
+
"@rsbuild/shared": "0.4.6"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
63
|
"@types/node": "16.x",
|