@travetto/pack 3.4.0-rc.4 → 3.4.0-rc.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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/pack",
|
|
3
|
-
"version": "3.4.0-rc.
|
|
3
|
+
"version": "3.4.0-rc.6",
|
|
4
4
|
"description": "Code packing utilities",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"travetto",
|
|
@@ -29,11 +29,10 @@
|
|
|
29
29
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
30
30
|
"@rollup/plugin-terser": "^0.4.4",
|
|
31
31
|
"@travetto/base": "^3.4.0-rc.0",
|
|
32
|
-
"rollup": "^4.1.5"
|
|
33
|
-
"rollup-plugin-sourcemaps": "^0.6.3"
|
|
32
|
+
"rollup": "^4.1.5"
|
|
34
33
|
},
|
|
35
34
|
"peerDependencies": {
|
|
36
|
-
"@travetto/cli": "^3.4.0-rc.
|
|
35
|
+
"@travetto/cli": "^3.4.0-rc.1"
|
|
37
36
|
},
|
|
38
37
|
"peerDependenciesMeta": {
|
|
39
38
|
"@travetto/cli": {
|
package/support/bin/config.ts
CHANGED
|
@@ -24,7 +24,8 @@ function getFilesFromModule(m: ManifestModule): string[] {
|
|
|
24
24
|
return [
|
|
25
25
|
...m.files.$index ?? [],
|
|
26
26
|
...m.files.src ?? [],
|
|
27
|
-
...m.files.bin ?? []
|
|
27
|
+
...(m.files.bin ?? [])
|
|
28
|
+
.filter(f => !(/bin\/trv[.]js$/.test(f[0]) && m.name === '@travetto/cli')),
|
|
28
29
|
...(m.files.support ?? [])
|
|
29
30
|
.filter(f => !/support\/(test|doc)/.test(f[0]))
|
|
30
31
|
]
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import fs from 'fs/promises';
|
|
3
|
+
|
|
4
|
+
import { LoadResult, Plugin, PluginContext } from 'rollup';
|
|
5
|
+
|
|
6
|
+
function toString(error: unknown): string {
|
|
7
|
+
return error instanceof Error ? error.stack ?? error.toString() : JSON.stringify(error);
|
|
8
|
+
}
|
|
9
|
+
// Pulled from https://github.com/Azure/azure-sdk-for-js/blob/main/common/tools/dev-tool/src/config/rollup.base.config.ts#L128
|
|
10
|
+
export function sourcemaps(): Plugin {
|
|
11
|
+
return {
|
|
12
|
+
name: 'load-source-maps',
|
|
13
|
+
async load(this: PluginContext, id: string): Promise<LoadResult> {
|
|
14
|
+
if (!id.endsWith('.js')) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
try {
|
|
18
|
+
const code = await fs.readFile(id, 'utf8');
|
|
19
|
+
if (code.includes('sourceMappingURL')) {
|
|
20
|
+
const mapPath = code.match(/sourceMappingURL=(.*)/)?.[1];
|
|
21
|
+
if (!mapPath) {
|
|
22
|
+
this.warn({ message: `Could not find map path in file ${id}`, id });
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
const basePath = path.dirname(id);
|
|
26
|
+
const absoluteMapPath = path.join(basePath, mapPath);
|
|
27
|
+
const map = JSON.parse(await fs.readFile(absoluteMapPath, 'utf8'));
|
|
28
|
+
return { code, map };
|
|
29
|
+
}
|
|
30
|
+
return { code, map: null };
|
|
31
|
+
} catch (e) {
|
|
32
|
+
this.warn({ message: toString(e), id });
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
}
|
package/support/bin/rollup.ts
CHANGED
|
@@ -2,13 +2,13 @@ import commonjsRequire from '@rollup/plugin-commonjs';
|
|
|
2
2
|
import nodeResolve from '@rollup/plugin-node-resolve';
|
|
3
3
|
import terser from '@rollup/plugin-terser';
|
|
4
4
|
import jsonImport from '@rollup/plugin-json';
|
|
5
|
-
import sourceMaps from 'rollup-plugin-sourcemaps';
|
|
6
5
|
import type { RollupOptions } from 'rollup';
|
|
7
6
|
|
|
8
7
|
import { RootIndex } from '@travetto/manifest';
|
|
9
8
|
|
|
10
9
|
import { getEntry, getOutput, getTerserConfig, getFiles, getIgnoredModules } from './config';
|
|
11
10
|
import { travettoImportPlugin } from './rollup-esm-dynamic-import';
|
|
11
|
+
import { sourcemaps } from './rollup-sourcemaps';
|
|
12
12
|
|
|
13
13
|
const NEVER_INCLUDE = new Set<string>([]);
|
|
14
14
|
|
|
@@ -31,7 +31,7 @@ export default function buildConfig(): RollupOptions {
|
|
|
31
31
|
}),
|
|
32
32
|
...(output.format === 'module' ? [travettoImportPlugin(entry, files)] : []),
|
|
33
33
|
nodeResolve({ preferBuiltins: true }),
|
|
34
|
-
...(output.sourcemap !== 'hidden' && output.sourcemap !== false ? [
|
|
34
|
+
...(output.sourcemap !== 'hidden' && output.sourcemap !== false ? [sourcemaps()] : []),
|
|
35
35
|
...(output.compact ? [terser(getTerserConfig())] : [])
|
|
36
36
|
]
|
|
37
37
|
};
|