rolldown-require 1.0.4 → 1.0.5
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/dist/index.cjs +69 -39
- package/dist/index.mjs +63 -33
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
throw Error('Dynamic require of "' + x + '" is not supported');
|
|
6
6
|
});
|
|
7
7
|
|
|
8
|
-
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.
|
|
8
|
+
// ../../node_modules/.pnpm/tsup@8.5.0_@swc+core@1.14.0_jiti@2.6.1_postcss@8.5.6_tsx@4.20.6_typescript@5.9.3_yaml@2.8.1/node_modules/tsup/assets/cjs_shims.js
|
|
9
9
|
var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.src || new URL("main.js", document.baseURI).href;
|
|
10
10
|
var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
|
|
11
11
|
|
|
@@ -881,40 +881,70 @@ async function bundleFile(fileName, options) {
|
|
|
881
881
|
const filenameVarName = "__vite_injected_original_filename";
|
|
882
882
|
const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
|
|
883
883
|
const rolldownInputOptions = _optionalChain([options, 'optionalAccess', _39 => _39.rolldownOptions, 'optionalAccess', _40 => _40.input]) || {};
|
|
884
|
-
const
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
884
|
+
const {
|
|
885
|
+
transform: userTransform,
|
|
886
|
+
resolve: userResolve,
|
|
887
|
+
...restRolldownInputOptions
|
|
888
|
+
} = rolldownInputOptions;
|
|
889
|
+
const transformDefine = {
|
|
890
|
+
..._nullishCoalesce(_optionalChain([userTransform, 'optionalAccess', _41 => _41.define]), () => ( {})),
|
|
891
|
+
"__dirname": dirnameVarName,
|
|
892
|
+
"__filename": filenameVarName,
|
|
893
|
+
"import.meta.url": importMetaUrlVarName,
|
|
894
|
+
"import.meta.dirname": dirnameVarName,
|
|
895
|
+
"import.meta.filename": filenameVarName
|
|
896
|
+
};
|
|
897
|
+
const transformOptions = {
|
|
898
|
+
..._nullishCoalesce(userTransform, () => ( {})),
|
|
899
|
+
define: transformDefine
|
|
900
|
+
};
|
|
901
|
+
const resolveOptions = {
|
|
902
|
+
..._nullishCoalesce(userResolve, () => ( {})),
|
|
903
|
+
mainFields: ["main"],
|
|
904
|
+
tsconfigFilename: options.tsconfig
|
|
905
|
+
};
|
|
906
|
+
const originalConsoleWarn = console.warn;
|
|
907
|
+
console.warn = (...args) => {
|
|
908
|
+
const message = typeof args[0] === "string" ? args[0] : "";
|
|
909
|
+
if (message.includes("resolve.tsconfigFilename") || message.includes("Invalid input options") || message.includes('top-level "define" option is deprecated')) {
|
|
910
|
+
return;
|
|
911
|
+
}
|
|
912
|
+
originalConsoleWarn(...args);
|
|
913
|
+
};
|
|
914
|
+
let bundle;
|
|
915
|
+
try {
|
|
916
|
+
bundle = await _rolldown.rolldown.call(void 0, {
|
|
917
|
+
...restRolldownInputOptions,
|
|
918
|
+
input: fileName,
|
|
919
|
+
// target: [`node${process.versions.node}`],
|
|
920
|
+
platform: "node",
|
|
921
|
+
resolve: resolveOptions,
|
|
922
|
+
define: transformDefine,
|
|
923
|
+
transform: transformOptions,
|
|
924
|
+
// disable treeshake to include files that is not sideeffectful to `moduleIds`
|
|
925
|
+
treeshake: false,
|
|
926
|
+
plugins: [
|
|
927
|
+
createExternalizeDepsPlugin({
|
|
928
|
+
entryFile: fileName,
|
|
929
|
+
isESM,
|
|
930
|
+
moduleSyncEnabled
|
|
931
|
+
}),
|
|
932
|
+
createFileScopeVariablesPlugin({
|
|
933
|
+
dirnameVarName,
|
|
934
|
+
filenameVarName,
|
|
935
|
+
importMetaUrlVarName
|
|
936
|
+
})
|
|
937
|
+
],
|
|
938
|
+
external: options.external
|
|
939
|
+
// preserveEntrySignatures: 'exports-only'
|
|
940
|
+
});
|
|
941
|
+
} finally {
|
|
942
|
+
console.warn = originalConsoleWarn;
|
|
943
|
+
}
|
|
944
|
+
if (!bundle) {
|
|
945
|
+
throw new Error("Failed to initialize bundler");
|
|
946
|
+
}
|
|
947
|
+
const rolldownOutputOptions = _optionalChain([options, 'optionalAccess', _42 => _42.rolldownOptions, 'optionalAccess', _43 => _43.output]) || {};
|
|
918
948
|
const result = await bundle.generate({
|
|
919
949
|
...rolldownOutputOptions,
|
|
920
950
|
format: options.format,
|
|
@@ -975,7 +1005,7 @@ async function loadFromBundledFile(fileName, bundledCode, options) {
|
|
|
975
1005
|
);
|
|
976
1006
|
return mod;
|
|
977
1007
|
} finally {
|
|
978
|
-
if (!_optionalChain([options, 'optionalAccess',
|
|
1008
|
+
if (!_optionalChain([options, 'optionalAccess', _44 => _44.preserveTemporaryFile])) {
|
|
979
1009
|
_fs2.default.unlink(outfile, () => {
|
|
980
1010
|
});
|
|
981
1011
|
}
|
|
@@ -1028,7 +1058,7 @@ function createExternalizeDepsPlugin({
|
|
|
1028
1058
|
}) {
|
|
1029
1059
|
const packageCache = /* @__PURE__ */ new Map();
|
|
1030
1060
|
const resolveByViteResolver = (id, importer, isRequire) => {
|
|
1031
|
-
return _optionalChain([tryNodeResolve, 'call',
|
|
1061
|
+
return _optionalChain([tryNodeResolve, 'call', _45 => _45(id, importer, {
|
|
1032
1062
|
root: _path2.default.dirname(entryFile),
|
|
1033
1063
|
isBuild: true,
|
|
1034
1064
|
isProduction: true,
|
|
@@ -1048,7 +1078,7 @@ function createExternalizeDepsPlugin({
|
|
|
1048
1078
|
packageCache,
|
|
1049
1079
|
isRequire,
|
|
1050
1080
|
builtins: nodeLikeBuiltins
|
|
1051
|
-
}), 'optionalAccess',
|
|
1081
|
+
}), 'optionalAccess', _46 => _46.id]);
|
|
1052
1082
|
};
|
|
1053
1083
|
return {
|
|
1054
1084
|
name: "externalize-deps",
|
|
@@ -1150,7 +1180,7 @@ function resolveTsconfigPath(options) {
|
|
|
1150
1180
|
if (typeof options.tsconfig === "string") {
|
|
1151
1181
|
return options.tsconfig;
|
|
1152
1182
|
}
|
|
1153
|
-
return _nullishCoalesce(_optionalChain([_gettsconfig.getTsconfig.call(void 0, options.cwd, "tsconfig.json"), 'optionalAccess',
|
|
1183
|
+
return _nullishCoalesce(_optionalChain([_gettsconfig.getTsconfig.call(void 0, options.cwd, "tsconfig.json"), 'optionalAccess', _47 => _47.path]), () => ( void 0));
|
|
1154
1184
|
}
|
|
1155
1185
|
|
|
1156
1186
|
|
package/dist/index.mjs
CHANGED
|
@@ -870,39 +870,69 @@ async function bundleFile(fileName, options) {
|
|
|
870
870
|
const filenameVarName = "__vite_injected_original_filename";
|
|
871
871
|
const importMetaUrlVarName = "__vite_injected_original_import_meta_url";
|
|
872
872
|
const rolldownInputOptions = options?.rolldownOptions?.input || {};
|
|
873
|
-
const
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
873
|
+
const {
|
|
874
|
+
transform: userTransform,
|
|
875
|
+
resolve: userResolve,
|
|
876
|
+
...restRolldownInputOptions
|
|
877
|
+
} = rolldownInputOptions;
|
|
878
|
+
const transformDefine = {
|
|
879
|
+
...userTransform?.define ?? {},
|
|
880
|
+
"__dirname": dirnameVarName,
|
|
881
|
+
"__filename": filenameVarName,
|
|
882
|
+
"import.meta.url": importMetaUrlVarName,
|
|
883
|
+
"import.meta.dirname": dirnameVarName,
|
|
884
|
+
"import.meta.filename": filenameVarName
|
|
885
|
+
};
|
|
886
|
+
const transformOptions = {
|
|
887
|
+
...userTransform ?? {},
|
|
888
|
+
define: transformDefine
|
|
889
|
+
};
|
|
890
|
+
const resolveOptions = {
|
|
891
|
+
...userResolve ?? {},
|
|
892
|
+
mainFields: ["main"],
|
|
893
|
+
tsconfigFilename: options.tsconfig
|
|
894
|
+
};
|
|
895
|
+
const originalConsoleWarn = console.warn;
|
|
896
|
+
console.warn = (...args) => {
|
|
897
|
+
const message = typeof args[0] === "string" ? args[0] : "";
|
|
898
|
+
if (message.includes("resolve.tsconfigFilename") || message.includes("Invalid input options") || message.includes('top-level "define" option is deprecated')) {
|
|
899
|
+
return;
|
|
900
|
+
}
|
|
901
|
+
originalConsoleWarn(...args);
|
|
902
|
+
};
|
|
903
|
+
let bundle;
|
|
904
|
+
try {
|
|
905
|
+
bundle = await rolldown({
|
|
906
|
+
...restRolldownInputOptions,
|
|
907
|
+
input: fileName,
|
|
908
|
+
// target: [`node${process.versions.node}`],
|
|
909
|
+
platform: "node",
|
|
910
|
+
resolve: resolveOptions,
|
|
911
|
+
define: transformDefine,
|
|
912
|
+
transform: transformOptions,
|
|
913
|
+
// disable treeshake to include files that is not sideeffectful to `moduleIds`
|
|
914
|
+
treeshake: false,
|
|
915
|
+
plugins: [
|
|
916
|
+
createExternalizeDepsPlugin({
|
|
917
|
+
entryFile: fileName,
|
|
918
|
+
isESM,
|
|
919
|
+
moduleSyncEnabled
|
|
920
|
+
}),
|
|
921
|
+
createFileScopeVariablesPlugin({
|
|
922
|
+
dirnameVarName,
|
|
923
|
+
filenameVarName,
|
|
924
|
+
importMetaUrlVarName
|
|
925
|
+
})
|
|
926
|
+
],
|
|
927
|
+
external: options.external
|
|
928
|
+
// preserveEntrySignatures: 'exports-only'
|
|
929
|
+
});
|
|
930
|
+
} finally {
|
|
931
|
+
console.warn = originalConsoleWarn;
|
|
932
|
+
}
|
|
933
|
+
if (!bundle) {
|
|
934
|
+
throw new Error("Failed to initialize bundler");
|
|
935
|
+
}
|
|
906
936
|
const rolldownOutputOptions = options?.rolldownOptions?.output || {};
|
|
907
937
|
const result = await bundle.generate({
|
|
908
938
|
...rolldownOutputOptions,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rolldown-require",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.5",
|
|
5
5
|
"description": "bundle and require a file using rolldown!",
|
|
6
6
|
"author": "ice breaker <1324318532@qq.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -52,7 +52,7 @@
|
|
|
52
52
|
},
|
|
53
53
|
"dependencies": {
|
|
54
54
|
"@rollup/pluginutils": "^5.3.0",
|
|
55
|
-
"get-tsconfig": "^4.
|
|
55
|
+
"get-tsconfig": "^4.13.0",
|
|
56
56
|
"mlly": "^1.8.0",
|
|
57
57
|
"resolve.exports": "^2.0.3"
|
|
58
58
|
},
|