Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[1.7.0.4 ] Minify errors with dynamically imported server modules #10178

Closed
nabiltntn opened this issue Aug 24, 2018 · 1 comment
Closed

[1.7.0.4 ] Minify errors with dynamically imported server modules #10178

nabiltntn opened this issue Aug 24, 2018 · 1 comment

Comments

@nabiltntn
Copy link

nabiltntn commented Aug 24, 2018

Hi,

i have recently upgraded my application from 1.5 to 1.7.0. 4

It uses packages structure like this :

capture d ecran 2018-08-21 a 13 58 44

The idea is to to separate mobile and web code when creating bundles. Both of them are declared with lazy: true

web

api.mainModule('client/index.js', 'web.browser', { lazy: true });

mobile

api.mainModule('client/index.js', 'web.cordova', { lazy: true });

In the api package, i am defining ValidatedMethods that import modules from server ( following Meteor Guide to hide secret server code ) like this :

export const aMethod = new ValidatedMethod({
  name: 'name',
  validate: SomeSchema.validator(),
  async run({ param1, param2 }) {
    if (Meteor.isServer) {
      const { functionFromServerModule: method } = await import('../../server/moduleWithFunction');
      return method.call(this, { param1, param2 });
    }
  }
});

To call these mthods from web and mobile package, i import them like this :

import { aMethod } from 'meteor/xxxxx:api/modules/module1/api';

In Dev, the application works fine , but when building or running with --production flag , i get errors due to minification.

I tried to verify the files that cause errors by displaying the input of standard-minifier-js pckage
and it seems like meteor does not transpile source from server modules imported dynamically inside functions like ../../server/moduleWithFunction ( copy them as they are with import, export, etc )

The result is the same when i replace standard-minifier-js with abernix:standard-minifier-js@2.1.0

NPM Packages

  • @babel/runtime: "7.0.0-beta.55"
  • meteor-node-stubs: "^0.4.1"

Meteor Packages

  • dynamic-import@0.4.2
  • es5-shim@4.8.0
  • ecmascript@0.11.1
  • standard-minifier-css@1.4.1
  • standard-minifier-js@2.3.4
  • xxxxx:api
  • xxxxx:client-web
  • xxxxx:client-mobile
@nabiltntn nabiltntn changed the title [1.7.0.4 ] Minify errors with dynamically imported server module [1.7.0.4 ] Minify errors with dynamically imported server modules Aug 24, 2018
@nabiltntn
Copy link
Author

Fixed by #10414

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant