Skip to content

Commit 7da9206

Browse files
committed
fix: webpack import issue
1 parent fb97d63 commit 7da9206

File tree

6 files changed

+150
-57
lines changed

6 files changed

+150
-57
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [1.0.1] - 2020-10-07
9+
10+
### Fixed
11+
- Issue with webpack import statements
12+
813
## [1.0.0] - 2020-10-06
914

1015
- Initial release

dist/script.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package-lock.json

Lines changed: 115 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
{
22
"name": "ficusjs-script",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "FicusJS script is a loader for ES modules and ES5 Javascript",
55
"main": "dist/script.js",
66
"module": "dist/script.js",
77
"types": "types/script.d.ts",
88
"scripts": {
99
"build": "rollup -i src/script.js -o dist/script.js -f es -p \"terser={mangle: { keep_fnames: true, toplevel: true, module: true }}\"",
10+
"postbuild": "replace-in-file \"import(r)\" \"import(/* webpackIgnore: true*/r)\" dist/script.js",
1011
"cy:open": "cypress open",
1112
"cy:run": "cypress run",
1213
"dev": "run-p serve open",
@@ -22,6 +23,7 @@
2223
"http-server": "0.12.3",
2324
"npm-run-all": "4.1.5",
2425
"open-cli": "6.0.1",
26+
"replace-in-file": "6.1.0",
2527
"rollup": "2.28.2",
2628
"rollup-plugin-terser": "7.0.2",
2729
"standard": "14.3.4",

site/app/src/docs/getting-started.md

Lines changed: 23 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -9,61 +9,33 @@ The easiest way to try out FicusJS script loader is using a simple example.
99
Create an `index.html` file and copy the following between the `<body>` tags.
1010

1111
```html
12-
<top-nav></top-nav>
13-
<div id="router-outlet"></div>
12+
<div id="content"></div>
1413

1514
<script type="module">
16-
import { createRouter } from 'https://unpkg.com/ficusjs-router?module'
17-
import { createComponent } from 'https://unpkg.com/ficusjs?module'
18-
import { render as renderer, html } from 'https://unpkg.com/lit-html?module'
19-
20-
createComponent('home-page', {
21-
renderer,
22-
render () {
23-
return html`<div>Welcome to the home page!</div>`
24-
}
25-
})
26-
27-
createComponent('page-one', {
28-
renderer,
29-
render () {
30-
return html`<div>Welcome to the page one!</div>`
31-
}
32-
})
33-
34-
createComponent('page-two', {
35-
renderer,
36-
render () {
37-
return html`<div>Welcome to the page two!</div>`
38-
}
39-
})
40-
41-
const router = createRouter([
42-
{ path: '', component: 'home-page' },
43-
{ path: '/one', component: 'page-one' },
44-
{ path: '/two', component: 'page-two' }
45-
], '#router-outlet', { mode: 'hash' })
46-
47-
createComponent('top-nav', {
48-
renderer,
49-
navigateTo (path) {
50-
router.push(path)
51-
},
52-
render () {
53-
return html`
54-
<nav>
55-
<ul>
56-
<li><button type="button" @click="${() => this.navigateTo('/')}">Home</button></li>
57-
<li><button type="button" @click="${() => this.navigateTo('/one')}">Page one</button></li>
58-
<li><button type="button" @click="${() => this.navigateTo('/two')}">Page two</button></li>
59-
</ul>
60-
</nav>
61-
`
62-
}
63-
})
15+
import { loadScript } from 'https://unpkg.com/ficusjs-script?module'
16+
const markdownToRender = `# FicusJS script loader
17+
18+
Dynamically load ES modules and ES5 scripts.
19+
20+
- Lazy load ES modules
21+
- Lazy load ES5 scripts
22+
- Dynamically load based on path
23+
- Functional programming patterns
24+
- Small footprint (1.3 KB gzipped for everything!)
25+
- No dependencies
26+
- Works with client-side frameworks
27+
`
28+
29+
// load the ES module for marked
30+
loadScript('https://unpkg.com/marked@1.2.0/lib/marked.esm.js')
31+
.then(mod => mod.default)
32+
.then(marked => {
33+
const content = document.getElementById('content')
34+
content.innerHTML = marked(markdownToRender)
35+
})
6436
</script>
6537
```
6638

67-
> Alternatively, fork this Codepen to see it in action - [https://codepen.io/ducksoupdev/pen/PoNvGwK](https://codepen.io/ducksoupdev/pen/PoNvGwK)
39+
> Alternatively, fork this Codepen to see it in action - [https://codepen.io/ducksoupdev/pen/abZbdbq](https://codepen.io/ducksoupdev/pen/abZbdbq)
6840
6941
The example creates a set of page components, a page navigation component and a new router using hash mode.

site/app/src/index.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,9 @@ <h1 class="hero__title">
5252
<p class="hero__description">Lightweight script loader for lazy loading ES modules and ES5 scripts or both based on dynamic paths</p>
5353
</div>
5454
<div class="hero__terminal">
55-
<p class="codepen" data-height="320" data-theme-id="dark" data-default-tab="html,result" data-user="ducksoupdev" data-slug-hash="PoNvGwK" style="height: 320px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="FicusJS router example">
56-
<span>See the Pen <a href="https://codepen.io/ducksoupdev/pen/PoNvGwK">
57-
FicusJS router example</a> by Matt Levy (<a href="https://codepen.io/ducksoupdev">@ducksoupdev</a>)
55+
<p class="codepen" data-height="320" data-theme-id="dark" data-default-tab="html,result" data-user="ducksoupdev" data-slug-hash="abZbdbq" style="height: 320px; box-sizing: border-box; display: flex; align-items: center; justify-content: center; border: 2px solid; margin: 1em 0; padding: 1em;" data-pen-title="FicusJS script loader example">
56+
<span>See the Pen <a href="https://codepen.io/ducksoupdev/pen/abZbdbq">
57+
FicusJS script loader example</a> by Matt Levy (<a href="https://codepen.io/ducksoupdev">@ducksoupdev</a>)
5858
on <a href="https://codepen.io">CodePen</a>.</span>
5959
</p>
6060
<script async src="https://static.codepen.io/assets/embed/ei.js"></script>

0 commit comments

Comments
 (0)