Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,6 @@ target/
# Mac Temporary Files
.DS_Store
**/.DS_Store

# Node Modules
**/node_modules/
2 changes: 1 addition & 1 deletion dfx.nix
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ let
cp ${pkgs.motoko.didc}/bin/didc $out
cp ${pkgs.motoko.rts}/rts/mo-rts.wasm $out
mkdir $out/stdlib && cp -R ${pkgs.motoko.stdlib}/. $out/stdlib
mkdir $out/js-user-library && cp -R ${userlib-js}/. $out/js-user-library
mkdir $out/js-user-library && tar --strip-components=1 --directory=$out/js-user-library -xzvf ${userlib-js}/internet-computer-*.tgz
'';
}
)
Expand Down
2 changes: 1 addition & 1 deletion src/dfx/assets/new_project_node_files/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const aliases = Object.entries(dfxJson.canisters).reduce((acc, [name,value]) =>
process.env["HOME"],
".cache/dfinity/versions",
dfxJson.dfx || process.env["DFX_VERSION"],
"js-user-library/dist/lib.prod.js",
"js-user-library/",
),
});

Expand Down
2 changes: 1 addition & 1 deletion src/dfx/src/commands/start.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ pub fn exec(env: &dyn Environment, args: &ArgMatches<'_>) -> DfxResult {

let bootstrap_dir = env
.get_cache()
.get_binary_command_path("js-user-library/dist/bootstrap")?;
.get_binary_command_path("js-user-library/bootstrap")?;
let frontend_watchdog = webserver(
address_and_port,
vec![url::Url::parse(IC_CLIENT_BIND_ADDR).unwrap()],
Expand Down
7 changes: 5 additions & 2 deletions src/userlib/js/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
dist/
out/
build_info.json
node_modules/
src/**/*.js
src/**/*.js.map
src/**/*.d.ts

13 changes: 13 additions & 0 deletions src/userlib/js/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# We work with a safelist here, so block everything that's not permitted, and add packages
# that are.
**

!bootstrap/**
!src/**/*.d.ts
!src/**/*.js
!types/**/*.d.ts
!package.json
!README.md

# The following line further removes all test files (which matches .js and .d.ts).
src/**/*.test.*
27 changes: 25 additions & 2 deletions src/userlib/js/README.adoc
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
= js-user-library
= JavaScript User Library

This is an internal document and is not published to NPM. The public facing README is in
`./README.md`. This file can be safely removed once we are open sourced.

Package: `@internet-computer/userlib`

== Development

Run `nix-shell` in this directory, and then use `npm` as normal.
=== How to build and use locally

In this repo:

[source,bash]
cd src/userlib/js # You are here
npm install
npm run build
pwd # Keep this
cp -rf . $(dfx cache show)

Alternatively, it might be easier to simply create a symlink;

[source,bash]
rm -rf $(dfx cache show)/js-user-library
ln -s src/userlib/js $(dfx cache show)/js-user-library

Then you just need to run `npm run build` when you change the code. You can also use
`npm run build -- --watch` for a quick watch mode.
7 changes: 7 additions & 0 deletions src/userlib/js/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# JavaScript User Library

Package: `@internet-computer/userlib`

## API

TBD.
12 changes: 7 additions & 5 deletions src/userlib/js/default.nix
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
{ pkgs }:

{ pkgs ? import ../../../nix { inherit system; }
, system ? builtins.currentSystem
}:
let
repoRoot = ../../..;
src = pkgs.lib.noNixFiles (pkgs.lib.gitOnlySource repoRoot ./.);
in
pkgs.napalm.buildPackage src {
root = ./.;
name = "dfinity-sdk-userlib-js";

# ci script now does everything CI should do. Bundle is needed because it's the output
# of the nix derivation.
npmCommands = [
Expand All @@ -16,9 +18,9 @@ pkgs.napalm.buildPackage src {
];

installPhase = ''
npm pack
mkdir -p $out
cp -R dist $out
cp package.json $out
cp README.adoc $out

cp internet-computer-*.tgz $out
'';
}
14 changes: 4 additions & 10 deletions src/userlib/js/package.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
{
"private": true,
"name": "@internet-computer/js-user-library",
"version": "0.1.0",
"main": "dist/lib.node.js",
"browser": {
"./dist/lib.node.js": "./dist/lib.web.js"
},
"files": [
"dist/**/*"
],
"name": "@internet-computer/userlib",
"version": "0.5.0",
"main": "src/index.js",
"scripts": {
"build": "tsc -p tsconfig.json",
"bundle": "npm run build && webpack",
"bundle": "npm run build",
"ci": "npm run prettier && npm run lint && npm run build && npm run test",
"lint": "tslint --project tsconfig.json --config tslint.json",
"lint:fix": "npm run lint -- --fix",
Expand Down
4 changes: 2 additions & 2 deletions src/userlib/js/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
"sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
"outDir": "out", /* Redirect output structure to the directory. */
// "outDir": "out", /* Redirect output structure to the directory. */
// "rootDir": "./", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */
// "composite": true, /* Enable project compilation */
"tsBuildInfoFile": "./out/build_info.json", /* Specify file to store incremental compilation information */
"tsBuildInfoFile": "./build_info.json", /* Specify file to store incremental compilation information */
// "removeComments": true, /* Do not emit comments to output. */
// "noEmit": true, /* Do not emit outputs. */
// "importHelpers": true, /* Import emit helpers from 'tslib'. */
Expand Down
116 changes: 0 additions & 116 deletions src/userlib/js/webpack.config.js

This file was deleted.