@babel/runtime error creating local package

I am attempting to draft a new package in the packages directory within a larger Meteor project (so that I can test out the package and its use at the same time). I’ve worked with the packages directory before, but I’m not an expert in writing from-scratch Meteor packages, and this package is written in modern ecmascript, so maybe that’s the issue? Anyway, I’m getting this classic error message when running meteor (in the larger Meteor project):

=> Errors prevented startup:

   While loading plugin `compileStaticPug` from package `edemaine:static-pug`:
   packages/babel-runtime.js:20:9:
   The @babel/runtime npm package could not be found in your node_modules
   directory. Please run the following command to install it:

   meteor npm install --save @babel/runtime

   at module (packages/babel-runtime.js:20:9)
   at fileEvaluate (packages/modules-runtime.js:336:7)
   at Module.require (packages/modules-runtime.js:238:14)
   at require (packages/modules-runtime.js:258:21)
   at packages/babel-runtime.js:53:15
   at packages/babel-runtime.js:58:3

I’m confused by this message because

  1. node_modules/@babel/runtime exists (in the larger project), and is depended upon by package.json (in the larger project). [And the Meteor project was working fine before I created this package and meteor added this package.] I’ve also tried deleting node_modules and running meteor npm install again.
  2. I didn’t think that packages were supposed to depend on @babel/runtime explicitly, only on the ecmascript Meteor package. (To do so would require a specific version, which seems bad.)

Here’s the package’s package.js (in packages/static-pug/package.js):

Package.describe({
  name: 'edemaine:static-pug',
  summary: "Define static page content in .pug files",
  version: '0.0.0',
  git: 'TODO'
});

Package.registerBuildPlugin({
  name: 'compileStaticPug',
  use: [
    'caching-compiler@1.2.2',
    'ecmascript@0.14.3',
    'templating-tools@1.1.2',
  ],
  sources: [
    'static-pug.js',
  ],
  npmDependencies: {
    'pug': '3.0.0',
  }
});

Package.onUse(function(api) {
  api.use('isobuild:compiler-plugin@1.0.0');
  api.imply('meteor@1.2.17', 'client'); // I've tried other versions too
});

I’m on Meteor 1.10.2.

Am I missing something in package.js?

have you tried without the api.imply('meteor line? I don’t have that in my build plugin?

Thanks for the suggestion! Alas, removing that line didn’t help.

Digging around the package directory, I noticed .npm/plugin/compileStaticPug which has its own npm-shrinkwrap.json and node_modules, and while it has lots of Babel (@babel/helper-validator-identifier, @babel/parser, @babel/types), it lacks @babel/runtime, which is presumably the issue. Not sure how to change the generation of this though. (I tried deleting it and Meteor regenerates it the same, so doesn’t seem to be a fluke…)

Ugh, adding '@babel/runtime': '7.9.6' to npmDependencies, letting Meteor compile, and then removing the dependency again, seems to have fixed the problem, so I guess it was transient. But deleting .npm and rebuilding causes the problem to recur, so maybe a real bug? :frowning_face:

Possibly relevant: I’m using Windows. Tried on Linux too – same issue.

It seems that the issue is with the pug NPM module – if I remove that dependency, I no longer have the @babel/runtime issue (instead I get a lack of pug issue). Replacing it with a peer dependency works for me, though I’m not sure why this is any different. Recompiling is possible in an app but not a package, but I didn’t turn that on, so I’m not sure why a dependency in app vs. package would be different in this way… :face_with_raised_eyebrow:

Sorry, I’m wrong again, and this remains an issue. I’ve released The trusted source for JavaScript packages, Meteor.js resources and tools | Atmosphere (meteor publish was fine with it) and added it to my project (meteor add edemaine:static-pug). In a copy of the project that recently had a working manual packages version, it works fine (remnants of @babel/runtime dependency?). But in a fresh checkout, I get the above error message again, even though the project has @babel/runtime in package.json dependencies and in node_modules. :frowning_face:

Oops, I had some remnant packages directories… I seem to have successfully released a working package, The trusted source for JavaScript packages, Meteor.js resources and tools | Atmosphere
– source code at GitHub - edemaine/static-pug: Render static .pug files as static HTML in Meteor