Sunday 19 August 2018

How to 'include' a file like with PHP and include(file), require(file), etc...?

I figure it would be as easy as using require() but that isn't working. import.js is the file I wish to include in every other file. It has all the class imports in it:/** import.js -- a collection / record of every .class.js file all in one place. */ import EventMonitor from './EventMonitor.class'; import Model from './Model.class'; import Upgrade from './Upgrade.class'; import UpgradeMonitor from './UpgradeMonitor.class'; import View from './View.class'; However, if I put this at the top of every class file which needs to import one another:require('./import'); It doesn't work. I get "View is not defined", then if I write an import statement to import View specifically in the main js file I get "EventMonitor is not defined", and so on. Is there something I'm missing with 'including' import.js in all other client-side .js files?

Submitted August 19, 2018 at 12:28PM by koenigsforst

No comments:

Post a Comment