rollup / rollup-starter-lib Goto Github PK
View Code? Open in Web Editor NEWBare-bones example of how to create a library using Rollup
License: MIT License
Bare-bones example of how to create a library using Rollup
License: MIT License
0.67.3
to 0.67.4
.This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
To see what happens to your code in Node.js 10, Greenkeeper has created a branch with the following changes:
.travis.yml
If you’re interested in upgrading this repo to Node.js 10, you can open a PR with these changes. Please note that this issue is just intended as a friendly reminder and the PR as a possible starting point for getting your code running on Node.js 10.
Greenkeeper has checked the engines
key in any package.json
file, the .nvmrc
file, and the .travis.yml
file, if present.
engines
was only updated if it defined a single version, not a range..nvmrc
was updated to Node.js 10.travis.yml
was only changed if there was a root-level node_js
that didn’t already include Node.js 10, such as node
or lts/*
. In this case, the new version was appended to the list. We didn’t touch job or matrix configurations because these tend to be quite specific and complex, and it’s difficult to infer what the intentions were.For many simpler .travis.yml
configurations, this PR should suffice as-is, but depending on what you’re doing it may require additional work or may not be applicable at all. We’re also aware that you may have good reasons to not update to Node.js 10, which is why this was sent as an issue and not a pull request. Feel free to delete it without comment, I’m a humble robot and won’t feel rejected 🤖
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hello there, I want to upate to @rollup/plugin-typescript from rollup-plugin-typescript, but found it only compile main.ts
but not the lunchtime.ts
, millisecondsUntil.ts
(as in this repo) in the cjs
format.
I have look through https://rollupjs.org/guide
but do not found anything to solve this.
So, I want to know if there is any special configuaration about this problem?
The example rollup.config.js
imports the package.json
Not sure if this is a new requirement from rollup. But this is seemingly not possible without adding @rollup/plugin-json
.
Heres the error:
Error: Unexpected token (Note that you need @rollup/plugin-json to import JSON files)
../../node_modules/iconv-lite/encodings/tables/gb18030-ranges.json (1:9)
1: {"uChars":[128,165,169,178,184,216,226,235,238,244,248,251,253,258,276,284,300,325,329,334,364,463,465,467,469,471,473,475,477,506,594,610,712,716,730,930,938,962,970,1026,1104,1106,8209,8215,8218,8222,8231,8241,8244,8246,8252,8365,8452,8454,8458,8471,8482,8556,8570,8596,8602,8713,8720,8722,8726,8731,8737,8740,8742,8748,8751,8760,8766,8777,8781,8787,8802,8808,8816,8
If I use lates rollup 3.17.2
(now is 1.29.0
), then I run yarn run dev
, the error throws:
rollup-starter-lib [master] % yarn run build
yarn run v1.22.19
$ rollup -c
(node:70006) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
[!] RollupError: Node tried to load your configuration file as CommonJS even though it is likely an ES module. To resolve this, change the extension of your configuration to ".mjs", set "type": "module" in your package.json file or pass the "--bundleConfigAsCjs" flag.
Original error: Cannot use import statement outside a module
https://rollupjs.org/command-line-interface/#bundleconfigascjs
/Users/hwf/source/rollup-starter-lib/rollup.config.js:3
import pkg from './package.json';
^^^^^^
SyntaxError: Cannot use import statement outside a module
at wrapSafe (internal/modules/cjs/loader.js:1001:16)
at Module._compile (internal/modules/cjs/loader.js:1049:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
at Module.load (internal/modules/cjs/loader.js:950:32)
at Function.Module._load (internal/modules/cjs/loader.js:790:12)
at ModuleWrap.<anonymous> (internal/modules/esm/translators.js:203:29)
at ModuleJob.run (internal/modules/esm/module_job.js:183:25)
at async Loader.import (internal/modules/esm/loader.js:178:24)
at async getConfigFileExport (/Users/hwf/source/rollup-starter-lib/node_modules/rollup/dist/shared/loadConfigFile.js:432:17)
at async Object.loadConfigFile (/Users/hwf/source/rollup-starter-lib/node_modules/rollup/dist/shared/loadConfigFile.js:391:59)
Seems like need do this if want use rollup3.x:
I am assuming
const howLongTillLunch = require('..');
reads package.json
and pulls
dist/how-long-till-lunch.umd.js
from browser
Can someone confirm?
1.9.2
to 1.9.3
.This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
2019-04-10
The new version differs by 3 commits.
516a06d
1.9.3
a5526ea
Update changelog
c3d73ff
Handle out-of-order binding of identifiers to improve tree-shaking (#2803)
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
11.0.1
to 11.0.2
.This version is covered by your current version range and after updating it in your project the build failed.
@rollup/plugin-commonjs is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi, thanks for great kick in! but..
I think that dist
should be ignored from version control, like build
is excluded in many others projects.
I expected that there will be more opinions, but I did't found it there, no much opened issues, no debates.. so I'm trying kick up this with this one 🙂
I notice in this example that it is referencing the umd build in the dist folder in the browser
field of package.json:
{
"main": "dist/how-long-till-lunch.cjs.js",
"module": "dist/how-long-till-lunch.esm.js",
"browser": "dist/how-long-till-lunch.umd.js",
}
Thinking of interop with other tools, I wonder whether this is right?
I think Browserify and Webpack both use the browser
field as having the meaning 'the entry point for this package, for browsers'. But they assume 'normal' cjs code.
For example have a look at the browser
field in the package.json of debug:
{
"main": "./src/index.js",
"browser": "./src/browser.js",
"unpkg": "./dist/debug.js"
}
Notice how they use a file in the src folder here. Both Browserify and Webpack will pick up this file and package / bundle it, wrapping it with a umd wrapper for umd builds.
So I wonder, is it right that the file this project is setting for the browser
field is a umd build, that already has a umd wrapper? Won't this file end up being wrapped twice?
the babel variant still uses a number of properties that have been renamed like entry
instead of input
.
Also this could be of importance: regarding the transform-runtime
plugin vs external-helpers
plugins for babel.
I'm talking about babel
branch specifically.
Correct me if I'm wrong, but the point of babel-preset-env
is to automate the Babel settings, specifying only the target platform, like "targets": { "browsers": ["last 2 versions", "ie >= 7"] }
or "browsers": "> 5%"
and so on. The Babel then knows what level of transpiling is needed. Because maybe, for example, your internal corporate portal is ran by Chrome users only. Or, for example, you can't sort out IE flexbox bugs and block it completely.
For example, .babelrc
would have settings for babel-preset-env
:
{
"presets": [
["env", {
"targets": {
"browsers": ["last 2 versions"]
}
}]
]
}
Now, I see we set the Babel settings in rollup.config.js
:
UMD settings part:
{
entry: 'src/main.js',
dest: pkg.browser,
format: 'umd',
moduleName: 'howLongUntilLunch',
plugins: [
resolve(), // so Rollup can find `ms`
commonjs(), // so Rollup can convert `ms` to an ES module
babel({
exclude: ['node_modules/**']
})
]
}
My question: why does babel-preset-env
have no settings in UMD part for the target environment? Is it because we want to make the module the most universal and therefore we apply the maximum transpiling?
Would it be possible to make this a Github template as well within the repos settings?
It'd make it handy to create a new repo directly from this in Github vs cloning each time.
Hey,
this is a fantastic starter kit for building a lib.
What if I want to serve the cjs, umd, and esm version both unminified and minified? For example:
How do I obtain this?
Thanks
Got directed to this repo from the rollup website.
Trying to figure out how to use Rollup to ship a TypeScript React component library as ESM.
It looks like the packages being used in the TypeScript example are wrong:
https://github.com/rollup/rollup-starter-lib/blob/typescript/package.json#L13-L15
The latest versions of plugins have been moved under the @rollup
organization on npm and the example should be updated to use those packages.
https://github.com/rollup/plugins/tree/master/packages/typescript
First time coming across tslib
in this project (thanks). From its README:
This is a runtime library for TypeScript that contains all of the TypeScript helper functions.
For optimized bundles with TypeScript, you should absolutely consider using tslib and --importHelpers.
So it seems like the existing package.json
for this project should be updated to put tslib
under dependencies
(not devDependencies
), and that tsconfig.json
should have importHelpers
uncommented to set it to true
.
Would probably add some docs in README.md to the effect that e.g. if your lib is small (e.g. you only have one module), then you're better off just removing tslib
and the importHelpers
option.
What do you think? Do you want a PR for this?
Cheers
1.27.6
to 1.27.7
.This version is covered by your current version range and after updating it in your project the build failed.
rollup is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
2019-12-01
The new version differs by 4 commits.
c753a7f
1.27.7
1b8a3de
Update changelog
d5651be
Fix incomplete computed property deoptimization (#3267)
d7e3993
Update changelog
See the full diff
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
Hi! Using this starter lib, I wanted to use Jest so I had to dig in various blog posts etc to find how to do it, here's the result: https://github.com/algolia/rollup-jest-boilerplate
Hope it has some usage to you, let me know!
Hi, if your library depends on an external package, how can you build for <script type="module">
? Bonus points if you can make it work as CJS, too.
Here's our library
// my-library.js
import fetch from 'isomorphic-unfetch'
export default function (url) {
// do stuff
return fetch(url)
}
Using rollup es
format, can this work?
<script type="module">
import myLibrary from './dist/my-library.es.js'
myLibrary(42)
</script>
Right now you it warns you
Uncaught TypeError: Failed to resolve module specifier "isomorphic-unfetch". Relative references must start with either "/", "./", or "../".`
If you change the library's import to something like ./node_modules/isomorphic-unfetch/es-version.js
it'll work locally but of course break the built version. What to do? What is this rabbit hole?
Any help would be great appreciated! Thank you.
Possibly related
I am trying to figure if I can use rollup to resolve modules for jasmine.
With Babel I can use babel-node and run Jasmine using API like:
https://gist.github.com/mauvm/172878a9646095d03fd7
I would like to avoid pulling in Babel for a project that targets modern node.
Should I try to use buble? but I only need ESM-> CJS
Edit.
Basically, I am looking for "roll as you go" option :)
I used ()=>{} is not work it's tips me
[!] (plugin uglify) Error: Unexpected token: punc «)»
SyntaxError: Unexpected token: punc «)»
Hello :)
TLDR; I've used this project to bundle my plugin, but I can't seem to reference it in a demo project
I'm upgrading a project of mine, a Vue JS plugin called VueSource to use Rollup as the bundler.
I'm using this project as the starting point, as it seems the most likely candidate I've found to successfully create a module I can use in other projects, and publish to NPM.
The current branch for this upgrade is:
To make sure the plugin is robust before publishing, I generally host a demo project side-by-side with the plugin, using Vue CLI to compile the web app and NPM Link to see changes live as I update the plugin:
+- VueSource
+- vue-source
+- vue-source-demo
The current branch for this demo project is:
This setup has worked very successfully in other projects using Webpack.
However, although I've got the bundling, linking and compiling working, when the browser loads the demo webapp, the plugin is undefined
:
In the image above the ../vue-source
link seems curious to me, as I would have expected to have seen it in node_modules
- where it actually is.
At first I thought this might be an NPM link problem, but now I am thinking this has more to do with Rollup's external
option.
I confirmed this by adding a breakpoint to both files, and it seems that both actually load so I'm suspecting that the reason that the module is undefined
has something to do with this, though I'm not sure.
Can anyone shed any light?
Thanks.
🚨 You need to enable Continuous Integration on all branches of this repository. 🚨
To enable Greenkeeper, you need to make sure that a commit status is reported on all branches. This is required by Greenkeeper because it uses your CI build statuses to figure out when to notify you about breaking changes.
Since we didn’t receive a CI status on the greenkeeper/initial
branch, it’s possible that you don’t have CI set up yet. We recommend using Travis CI, but Greenkeeper will work with every other CI service as well.
If you have already set up a CI for this repository, you might need to check how it’s configured. Make sure it is set to run on all new branches. If you don’t want it to run on absolutely every branch, you can whitelist branches starting with greenkeeper/
.
Once you have installed and configured CI on this repository correctly, you’ll need to re-trigger Greenkeeper’s initial pull request. To do this, please delete the greenkeeper/initial
branch in this repository, and then remove and re-add this repository to the Greenkeeper integration’s white list on Github. You'll find this list on your repo or organization’s settings page, under Installed GitHub Apps.
7.0.0
to 7.1.0
.This version is covered by your current version range and after updating it in your project the build failed.
@rollup/plugin-node-resolve is a devDependency of this project. It might not break your production code or affect downstream projects, but probably breaks your build or test tools, which may prevent deploying or publishing.
There is a collection of frequently asked questions. If those don’t help, you can always ask the humans behind Greenkeeper.
Your Greenkeeper Bot 🌴
.editorconfig is great to define standards for a repo.
I could do a PR if you want.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.