Meteor-Community-Packages / check-npm-versions

Enforces "peer" npm dependencies in Meteor 1.3+ Atmosphere packages.
MIT License
11 stars 10 forks source link

Use with Package.registerBuildPlugin? #17

Closed GeoffreyBooth closed 4 years ago

GeoffreyBooth commented 7 years ago

I’m trying to use this to update the coffeescript package to use whatever version of the NPM coffeescript module the project has installed. I can’t seem to get it to work. This is in package.js:

Package.registerBuildPlugin({
  name: 'compileCoffeescript',
  use: [
    'caching-compiler',
    'ecmascript',
    'tmeasday:check-npm-versions@0.3.1'
  ],
  sources: ['plugin/compile-coffeescript.js'],
  npmDependencies: {
    'source-map': '0.5.6'
  }
});

And this is the top of plugin/compile-coffeescript.js:

import { checkNpmVersions } from 'meteor/tmeasday:check-npm-versions';
checkNpmVersions({
  coffeescript: '2.0.0-beta3',
}, 'coffeescript');

import CoffeeScript from 'coffeescript';
import { BabelCompiler } from 'meteor/babel-compiler';
import { SourceMapConsumer, SourceMapGenerator } from 'source-map';

I keep getting error: Can't load npm module 'coffeescript' from packages/modules-runtime.js. Check your Npm.depends().

Any ideas? Does check-npm-versions not work in the context of Package.registerBuildPlugin?

mitar commented 6 years ago

I think this was the issue of plugins not being able to access modules in node_modules from the app. I think this works now, at least it seems in one other plugin (minifier) in Meteor 1.6.1.1.

copleykj commented 4 years ago

Just for future reference, I think this may have been due to import hoisting as mentioned in the readme file.

copleykj commented 4 years ago

Closing due to age.