$ mkdir -p node_modules/my-lib
$ cp package.json node_modules/my-lib/
$ mv my_lib.js node_modules/my-lib/index.js
$ node index_static.js
$ node index_dynamic.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules | |
/package-lock.json | |
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules | |
/package-lock.json | |
/dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/vendor |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/node_modules | |
/dist |
test case for resolving implicit package names
-
npm install
-
./test
should emit something like the following:project directory: /home/dev moving to /tmp
resolved: /tmp/node_modules/material-design-icons/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
let { generate } = require("escodegen"); | |
let jsx = require("acorn-jsx"); | |
let acorn = require("acorn"); | |
let { strictEqual: assertSame } = require("assert"); | |
let JSXParser = acorn.Parser.extend(jsx()); | |
let ast = JSXParser.parse(`<Card title={123}> |
compare before.js
with after.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// render view | |
let tree = frontpage({ | |
title: "My Site", | |
groups: ["AAA", "BBB"] | |
}); | |
console.log("ready to render", tree); | |
// views | |
function frontpage({ title, groups }) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="utf-8"> | |
<title>My Static Site</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
</head> | |
<body> |