From f118338c0a095780287a22a85288403b583cbab6 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 5 Sep 2017 13:27:26 -0600 Subject: [PATCH 1/2] Add .js extension to import paths --- transforms/module.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/transforms/module.js b/transforms/module.js index 101b82cc4f..cdb494ef61 100644 --- a/transforms/module.js +++ b/transforms/module.js @@ -61,7 +61,7 @@ function resolve(fromName, toName) { if (relative.endsWith('/')) { relative += 'index'; } - return relative; + return relative + '.js'; } function getUnprovided(path) { From e412ba113ce85e677d806080ff2e593b109c0a20 Mon Sep 17 00:00:00 2001 From: Tim Schaub Date: Tue, 5 Sep 2017 14:46:05 -0600 Subject: [PATCH 2/2] Add @module annotation to source modules --- transforms/module.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/transforms/module.js b/transforms/module.js index cdb494ef61..ca09221344 100644 --- a/transforms/module.js +++ b/transforms/module.js @@ -259,5 +259,17 @@ module.exports = function(info, api) { // replace any initial comments root.get().node.comments = comments; + // add @module annotation for src modules + if (info.path.startsWith('src')) { + const name = info.path.replace(/^src\//, '').replace(/\.js$/, ''); + const comment = j.commentBlock(`*\n * @module ${name}\n `); + const node = root.get().node; + if (!node.comments) { + node.comments = [comment]; + } else { + node.comments.unshift(comment); + } + } + return root.toSource({quote: 'single'}); };