@travetto/pack 8.0.0-alpha.3 → 8.0.0-alpha.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@travetto/pack",
3
- "version": "8.0.0-alpha.3",
3
+ "version": "8.0.0-alpha.5",
4
4
  "type": "module",
5
5
  "description": "Code packing utilities",
6
6
  "keywords": [
@@ -29,13 +29,13 @@
29
29
  "@rollup/plugin-commonjs": "^29.0.2",
30
30
  "@rollup/plugin-json": "^6.1.0",
31
31
  "@rollup/plugin-node-resolve": "^16.0.3",
32
- "@rollup/plugin-terser": "^0.4.4",
33
- "@travetto/runtime": "^8.0.0-alpha.2",
34
- "@travetto/terminal": "^8.0.0-alpha.2",
32
+ "@rollup/plugin-terser": "^1.0.0",
33
+ "@travetto/runtime": "^8.0.0-alpha.3",
34
+ "@travetto/terminal": "^8.0.0-alpha.3",
35
35
  "rollup": "^4.59.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "@travetto/cli": "^8.0.0-alpha.3"
38
+ "@travetto/cli": "^8.0.0-alpha.4"
39
39
  },
40
40
  "peerDependenciesMeta": {
41
41
  "@travetto/cli": {
@@ -1,4 +1,5 @@
1
1
  import type { AstNode, Plugin } from 'rollup';
2
+ // @ts-expect-error - This module lacks types
2
3
  import { walk } from 'estree-walker';
3
4
  import magicString from 'magic-string';
4
5
 
@@ -33,16 +34,14 @@ export function travettoImportPlugin(config: CoreRollupConfig): Plugin {
33
34
  let ms: magicString | undefined;
34
35
 
35
36
  walk(parsed, {
36
- enter: (node) => {
37
- // eslint-disable-next-line @typescript-eslint/consistent-type-assertions
38
- const impNode = node as TNode;
39
- if (impNode.type === 'ImportExpression' && impNode.source?.type !== 'Literal') {
40
- if (!/["']/.test(code.substring(impNode.start, impNode.end))) {
41
- (ms ??= new magicString(code)).overwrite(impNode.start, impNode.start + 6, GLOBAL_IMPORT);
37
+ enter: (node: TNode) => {
38
+ if (node.type === 'ImportExpression' && node.source?.type !== 'Literal') {
39
+ if (!/["']/.test(code.substring(node.start, node.end))) {
40
+ (ms ??= new magicString(code)).overwrite(node.start, node.start + 6, GLOBAL_IMPORT);
42
41
  }
43
- } else if (impNode.type === 'CallExpression' && impNode.callee?.type === 'Identifier' && impNode.callee.name === 'require') {
44
- if (!/["']/.test(code.substring(impNode.start, impNode.end))) {
45
- (ms ??= new magicString(code)).overwrite(impNode.start, impNode.start + 7, GLOBAL_IMPORT);
42
+ } else if (node.type === 'CallExpression' && node.callee?.type === 'Identifier' && node.callee.name === 'require') {
43
+ if (!/["']/.test(code.substring(node.start, node.end))) {
44
+ (ms ??= new magicString(code)).overwrite(node.start, node.start + 7, GLOBAL_IMPORT);
46
45
  }
47
46
  }
48
47
  }
@@ -18,7 +18,7 @@ export function travettoSourcemaps(config: CoreRollupConfig): Plugin {
18
18
  return {
19
19
  name: 'travetto-source-maps',
20
20
  async load(this: PluginContext, id: string): Promise<LoadResult> {
21
- if (!id.endsWith('.js')) {
21
+ if (!id.endsWith('.js') || id.endsWith('@travetto/runtime/support/polyfill.js')) {
22
22
  return null;
23
23
  }
24
24
  try {
@@ -31,7 +31,10 @@ export function travettoSourcemaps(config: CoreRollupConfig): Plugin {
31
31
  }
32
32
  const loader = new FileLoader([path.dirname(id)]);
33
33
  const map = await loader.readText(mapPath)
34
- .then(JSONUtil.fromBase64<SourceMapInput>);
34
+ .then(value => value.startsWith('{') ?
35
+ JSONUtil.fromUTF8<SourceMapInput>(value) :
36
+ JSONUtil.fromBase64<SourceMapInput>(value)
37
+ );
35
38
  return { code, map };
36
39
  }
37
40
  return { code, map: null };