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

Empty modules #55

Merged
merged 11 commits into from
Sep 21, 2018
Merged

Empty modules #55

merged 11 commits into from
Sep 21, 2018

Conversation

stoeffel
Copy link
Contributor

@stoeffel stoeffel commented Apr 6, 2018

closes #19

output looks like this:

(function() {
var jetpackCache = {};
function jetpackRequire(fn, fnName) {
  var e = {};
  var m = { exports : e };
  if (typeof fn !== "function") {
    console.error("Required function isn't a jetpack module.", fn)
    return;
  }
  if (jetpackCache[fnName]) {
    return jetpackCache[fnName];
  }
  jetpackCache[fnName] = m.exports;
  fn(m, e);
  jetpackCache[fnName] = m.exports;
  return m.exports;
}
/* START: require_empty_js_js */
function require_empty_js_js(module, exports) {
var empty = jetpackRequire(empty_js_js, "empty_js_js")

} /* END: require_empty_js_js */
+/* START: empty_js_js */
+  console.warn("empty.js: is an empty module!");
+function empty_js_js(module, exports) {
+} /* END: empty_js_js */

jetpackRequire(require_empty_js_js, "require_empty_js_js");
})();

@stoeffel stoeffel added the WIP label Apr 6, 2018
@stoeffel stoeffel self-assigned this Apr 6, 2018
@stoeffel stoeffel removed the WIP label Apr 6, 2018
Copy link
Contributor

@ento ento left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for fixing! Left some 🎨 comments; nothing blocking.

I merged master and confirmed the original issue is resolved. Can you double-check that the merge was clean?

T.concat
[ "/* START: "
, fnName
, " */"
, if all isSpace $ T.unpack body
then " console.warn(\"" <> T.pack filePath <>
": is an empty module!\");"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 A module being empty might not be a runtime concern, but a compile-time concern.

wrapper config (Dependency {filePath}, ds) = do
let Config {tempDir} = config
withContent ::
Config -> (Dependency, [Dependency]) -> IO (FilePath, [Dependency], T.Text)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎨 (FilePath, [Dependency], T.Text) could be a named type like

data Module = Module
  { filePath :: FilePath
  , dependencies :: [Dependency]
  , content :: T.Text
  }

-- and perhaps rename withContent
readModule :: Config -> (Dependency, [Dependency]) -> IO Module

-- and perhaps rename wrapDependency
compileModule :: Module -> T.Text

@ento ento assigned stoeffel and unassigned ento Sep 21, 2018
@stoeffel stoeffel merged commit 8728314 into master Sep 21, 2018
@stoeffel stoeffel deleted the empty-modules branch September 21, 2018 15:36
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

Successfully merging this pull request may close these issues.

Empty module doesn't get generated
2 participants