glimmerjs / glimmer-vm

MIT License
1.13k stars 190 forks source link

Published package.json broken for @glimmer/interfaces #1294

Open simonihmig opened 3 years ago

simonihmig commented 3 years ago

I wanted to import types from @glimmer/interfaces (Component manager interfaces) in an Ember addon, however that fails with Can't resolve '@glimmer/interfaces':

Stack Trace ``` ================================================================================= ENV Summary: TIME: Wed Apr 07 2021 20:24:37 GMT+0200 (Central European Summer Time) TITLE: ember ARGV: - /Users/simonihmig/.volta/tools/image/node/10.22.0/bin/node - /Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/.bin/ember - serve EXEC_PATH: /Users/simonihmig/.volta/tools/image/node/10.22.0/bin/node TMPDIR: /var/folders/q3/yzggf_l965zbzps_bk8xr37c0000gn/T SHELL: /bin/zsh PATH: - /var/folders/q3/yzggf_l965zbzps_bk8xr37c0000gn/T/yarn--1617819854705-0.6245694040083662 - /Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/.bin - /Users/simonihmig/.config/yarn/link/node_modules/.bin - /Users/simonihmig/.volta/tools/image/node/10.22.0/libexec/lib/node_modules/npm/bin/node-gyp-bin - /Users/simonihmig/.volta/tools/image/node/10.22.0/lib/node_modules/npm/bin/node-gyp-bin - /Users/simonihmig/.volta/tools/image/node/10.22.0/bin/node_modules/npm/bin/node-gyp-bin - /Users/simonihmig/.volta/tools/image/npm/6.14.11/bin - /Users/simonihmig/.volta/tools/image/yarn/1.22.4/bin - /Users/simonihmig/.volta/tools/image/node/10.22.0/bin - /Users/simonihmig/.volta/bin - /Users/simonihmig/.yarn/bin - /Users/simonihmig/.cargo/bin - /usr/local/bin - /usr/bin - /bin - /usr/sbin - /sbin - /Library/Apple/usr/bin - /Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/.bin PLATFORM: darwin x64 FREEMEM: 40628224 TOTALMEM: 17179869184 UPTIME: 373736 LOADAVG: 3.63525390625,2.64208984375,2.794921875 CPUS: - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 - Intel(R) Core(TM) i7-6700HQ CPU @ 2.60GHz - 2600 ENDIANNESS: LE VERSIONS: - ares: 1.15.0 - brotli: 1.0.7 - cldr: 35.1 - http_parser: 2.9.3 - icu: 64.2 - modules: 64 - napi: 6 - nghttp2: 1.41.0 - node: 10.22.0 - openssl: 1.1.1g - tz: 2019c - unicode: 12.1 - uv: 1.34.2 - v8: 6.8.275.32-node.58 - zlib: 1.2.11 ERROR Summary: - broccoliBuilderErrorStack: Error: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' at doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:209:21) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1) at resolver.doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1) at resolver.doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:30:40) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) - code: [undefined] - codeFrame: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' - errorMessage: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' at Bundler -~- created here: -~- at new Plugin (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/node_modules/broccoli-plugin/dist/index.js:47:36) at new Bundler (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/bundler.js:34:9) at AutoImport.makeBundler (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:57:16) at AutoImport.addTo (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:67:38) at EmberAddon.host.addonPostprocessTree (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:101:29) at EmberAddon.toTree (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/broccoli/ember-app.js:1670:17) at module.exports (/Users/simonihmig/Projects/ember-ecsy-babylon/ember-cli-build.js:15:14) at Builder.readBuildFile (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:49:14) at Builder.setupBroccoliBuilder (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:63:22) at new Builder (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:29:10) -~- (end) -~- - errorType: Build Error - location: - column: [undefined] - file: [undefined] - line: [undefined] - treeDir: [undefined] - message: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' at Bundler -~- created here: -~- at new Plugin (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/node_modules/broccoli-plugin/dist/index.js:47:36) at new Bundler (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/bundler.js:34:9) at AutoImport.makeBundler (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:57:16) at AutoImport.addTo (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:67:38) at EmberAddon.host.addonPostprocessTree (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-auto-import/js/auto-import.js:101:29) at EmberAddon.toTree (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/broccoli/ember-app.js:1670:17) at module.exports (/Users/simonihmig/Projects/ember-ecsy-babylon/ember-cli-build.js:15:14) at Builder.readBuildFile (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:49:14) at Builder.setupBroccoliBuilder (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:63:22) at new Builder (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/ember-cli/lib/models/builder.js:29:10) -~- (end) -~- - name: Error - nodeAnnotation: [undefined] - nodeName: Bundler - originalErrorMessage: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' - stack: Error: Can't resolve '@glimmer/interfaces' in '/Users/simonihmig/Projects/ember-ecsy-babylon' at doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:209:21) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :15:1) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1) at resolver.doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:67:43) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) at _fn0 (eval at create (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/tapable/lib/HookCodeFactory.js:33:10), :27:1) at resolver.doResolve (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:30:40) at hook.callAsync (/Users/simonihmig/Projects/ember-ecsy-babylon/node_modules/enhanced-resolve/lib/Resolver.js:285:5) ================================================================================= ```

Turns out that the published package.json contains references (main, module etc.) that actually don't exist. The magic that write-package-json.js applies does not fit for this type-only package. So it seems trying to resolve() the package location fails as main does not point to a valid location.

For easier reference see what gets published here:

image

rwjblue commented 3 years ago

Ya the types entry point seems wrong there (I think it should be dist/types/index.d.ts).

simonihmig commented 3 years ago

Yes, and the right path exists for its alias typings. But the bigger problem, leading to the exception, seems to be that the other entry points (main etc.) don't exist (or rather the files they refer to).