@siddharatha/adapter-node-rolldown 1.1.3 → 1.1.4

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.
Files changed (2) hide show
  1. package/index.js +39 -8
  2. 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 { out = 'build', precompress = true, envPrefix = '', external, bundleAll = false, rolldownOptions = {} } = opts;
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',
@@ -82,14 +91,12 @@ export default function (opts = {}) {
82
91
  // will get included in the bundled code
83
92
  const bundle = await rolldown({
84
93
  input,
85
- external: externalPatterns,
86
94
  platform: 'node',
87
- resolve: {
88
- conditionNames: ['node', 'import'],
89
- ...rolldownOptions.resolve
90
- },
91
- cwd: process.cwd(),
92
- ...rolldownOptions
95
+ treeshake: true,
96
+ shimMissingExports: true,
97
+ external: keepPackageDependencies
98
+ ? [...Object.keys(pkg.dependencies || {}).map((d) => new RegExp(`^${d}(\\/.*)?$`))]
99
+ : undefined,
93
100
  });
94
101
 
95
102
  await bundle.write({
@@ -120,6 +127,30 @@ export default function (opts = {}) {
120
127
  }
121
128
  });
122
129
  }
130
+
131
+ if (!polyfill) {
132
+ writeFileSync(`${out}/shims.js`, '', 'utf-8');
133
+ }
134
+
135
+ if (copyDevNodeModules) {
136
+ builder.copy('node_modules', `${out}/node_modules`, {});
137
+ }
138
+ if (copyNpmrc) {
139
+ builder.copy('.npmrc', `${out}/.npmrc`, {});
140
+ }
141
+
142
+ if (cleanPackageJson) {
143
+ const packageJson = JSON.parse(readFileSync('package.json', 'utf8'));
144
+ delete packageJson.devDependencies;
145
+
146
+ if (!keepPackageDependencies) {
147
+ delete packageJson.dependencies;
148
+ }
149
+ delete packageJson.scripts;
150
+ writeFileSync(`${out}/package.json`, JSON.stringify(packageJson, null, 2), 'utf-8');
151
+ } else {
152
+ builder.copy('package.json', `${out}/package.json`, {});
153
+ }
123
154
  },
124
155
 
125
156
  supports: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@siddharatha/adapter-node-rolldown",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "description": "Just replacing @sveltejs/adapter-node with rolldown",
5
5
  "type": "module",
6
6
  "exports": {