Skip to content

Commit 6818027

Browse files
committed
Initial build system
0 parents  commit 6818027

File tree

8 files changed

+366
-0
lines changed

8 files changed

+366
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

package-lock.json

+231
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "wasm-feature-detect",
3+
"version": "0.0.1",
4+
"description": "",
5+
"main": "index.js",
6+
"scripts": {
7+
"build": "rollup -c",
8+
"fmt": "prettier --write './{,src,rollup-plugins}/**/*.{js,md}'"
9+
},
10+
"keywords": [],
11+
"author": "Surma <[email protected]>",
12+
"license": "Apache-2.0",
13+
"devDependencies": {
14+
"prettier": "^1.18.2",
15+
"rollup": "^1.20.3",
16+
"rollup-plugin-terser": "^5.1.1"
17+
}
18+
}

rollup-plugins/index-generator.js

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
import { promises as fsp } from "fs";
15+
import { dirname, join } from "path";
16+
17+
export default function({ indexPath, pluginFolder }) {
18+
const rootPluginPath = join(dirname(indexPath), pluginFolder);
19+
return {
20+
resolveId(id) {
21+
if (id === indexPath) {
22+
return id;
23+
}
24+
},
25+
async load(id) {
26+
if (id !== indexPath) {
27+
return;
28+
}
29+
30+
const plugins = await fsp.readdir(rootPluginPath);
31+
const src = plugins
32+
.map(
33+
plugin =>
34+
`export {default as ${plugin}} from "./${pluginFolder}/${plugin}/index.js";`
35+
)
36+
.join("\n");
37+
return src;
38+
}
39+
};
40+
}

rollup.config.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
import { terser } from "rollup-plugin-terser";
15+
16+
import indexGenerator from "./rollup-plugins/index-generator.js";
17+
18+
export default {
19+
input: "./src/index.js",
20+
output: {
21+
dir: "dist",
22+
format: "esm"
23+
},
24+
plugins: [
25+
indexGenerator({ indexPath: "./src/index.js", pluginFolder: "detectors" }),
26+
terser()
27+
]
28+
};

src/detectors/simd/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
export default function() {
15+
return "simd";
16+
}

src/detectors/threads/index.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
export default function() {
15+
return "threads";
16+
}

src/index.js

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Copyright 2019 Google Inc. All Rights Reserved.
3+
* Licensed under the Apache License, Version 2.0 (the "License");
4+
* you may not use this file except in compliance with the License.
5+
* You may obtain a copy of the License at
6+
* http://www.apache.org/licenses/LICENSE-2.0
7+
* Unless required by applicable law or agreed to in writing, software
8+
* distributed under the License is distributed on an "AS IS" BASIS,
9+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
10+
* See the License for the specific language governing permissions and
11+
* limitations under the License.
12+
*/
13+
14+
// This is a dummy file.
15+
// The contents will be generated by rollup-plugins/index-generator.js

0 commit comments

Comments
 (0)