@siddharatha/adapter-node-rolldown 1.1.3 → 1.1.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/index.js +39 -17
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -18,7 +18,16 @@ const files = fileURLToPath(new URL('./files', import.meta.url).href);
|
|
|
18
18
|
|
|
19
19
|
/** @type {import('./index.js').default} */
|
|
20
20
|
export default function (opts = {}) {
|
|
21
|
-
const {
|
|
21
|
+
const {
|
|
22
|
+
out = 'build',
|
|
23
|
+
precompress = false,
|
|
24
|
+
envPrefix = '',
|
|
25
|
+
polyfill = true,
|
|
26
|
+
copyDevNodeModules = false,
|
|
27
|
+
cleanPackageJson = true,
|
|
28
|
+
keepPackageDependencies = false,
|
|
29
|
+
copyNpmrc = true
|
|
30
|
+
} = opts;
|
|
22
31
|
|
|
23
32
|
return {
|
|
24
33
|
name: '@sveltejs/adapter-node',
|
|
@@ -57,15 +66,6 @@ export default function (opts = {}) {
|
|
|
57
66
|
|
|
58
67
|
const pkg = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
59
68
|
|
|
60
|
-
// determine external patterns for bundling
|
|
61
|
-
let externalPatterns;
|
|
62
|
-
if (bundleAll) {
|
|
63
|
-
externalPatterns = [];
|
|
64
|
-
} else if (external) {
|
|
65
|
-
externalPatterns = typeof external === 'function' ? external(pkg) : external;
|
|
66
|
-
} else {
|
|
67
|
-
externalPatterns = Object.keys(pkg.dependencies || {});
|
|
68
|
-
}
|
|
69
69
|
|
|
70
70
|
/** @type {Record<string, string>} */
|
|
71
71
|
const input = {
|
|
@@ -82,14 +82,12 @@ export default function (opts = {}) {
|
|
|
82
82
|
// will get included in the bundled code
|
|
83
83
|
const bundle = await rolldown({
|
|
84
84
|
input,
|
|
85
|
-
external: externalPatterns,
|
|
86
85
|
platform: 'node',
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
...rolldownOptions
|
|
86
|
+
treeshake: true,
|
|
87
|
+
shimMissingExports: true,
|
|
88
|
+
external: keepPackageDependencies
|
|
89
|
+
? [...Object.keys(pkg.dependencies || {}).map((d) => new RegExp(`^${d}(\\/.*)?$`))]
|
|
90
|
+
: undefined,
|
|
93
91
|
});
|
|
94
92
|
|
|
95
93
|
await bundle.write({
|
|
@@ -120,6 +118,30 @@ export default function (opts = {}) {
|
|
|
120
118
|
}
|
|
121
119
|
});
|
|
122
120
|
}
|
|
121
|
+
|
|
122
|
+
if (!polyfill) {
|
|
123
|
+
writeFileSync(`${out}/shims.js`, '', 'utf-8');
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
if (copyDevNodeModules) {
|
|
127
|
+
builder.copy('node_modules', `${out}/node_modules`, {});
|
|
128
|
+
}
|
|
129
|
+
if (copyNpmrc) {
|
|
130
|
+
builder.copy('.npmrc', `${out}/.npmrc`, {});
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
if (cleanPackageJson) {
|
|
134
|
+
const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
|
|
135
|
+
delete packageJson.devDependencies;
|
|
136
|
+
|
|
137
|
+
if (!keepPackageDependencies) {
|
|
138
|
+
delete packageJson.dependencies;
|
|
139
|
+
}
|
|
140
|
+
delete packageJson.scripts;
|
|
141
|
+
writeFileSync(`${out}/package.json`, JSON.stringify(packageJson, null, 2), 'utf-8');
|
|
142
|
+
} else {
|
|
143
|
+
builder.copy('package.json', `${out}/package.json`, {});
|
|
144
|
+
}
|
|
123
145
|
},
|
|
124
146
|
|
|
125
147
|
supports: {
|