swiing / rollup-plugin-import-assertions Goto Github PK
View Code? Open in Web Editor NEWA Rollup plugin which bundles TC39 import assertions.
License: MIT License
A Rollup plugin which bundles TC39 import assertions.
License: MIT License
When running with node 18, this deprecation warning is generated:
(node:17848) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at PROJECT_FOLDER\node_modules\.pnpm\[email protected]\node_modules\acorn-import-assertions\package.json imported from PROJECT_FOLDER\node_modules\.pnpm\[email protected]\node_modules\rollup-plugin-import-assertions\dist\index.js.
Update this package.json to use a subpath pattern like "./*".
Installing rollup cli and executing rollup -c rollup.config.js
works without any errors but when I run this using npm run build
then I get following error:
╰─ npm run build ─╯
> [email protected] build
> rimraf dist && rollup -c rollup.config.js
./index.html → dist...
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db
Why you should do it regularly: https://github.com/browserslist/browserslist#browsers-data-updating
(node:21616) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at C:\Users\khash\Developme
nt\gramps-project\Gramps.js\node_modules\tslib\package.json. Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
[!] (plugin import-assertions) TypeError: self.load is not a function
src\lang\index.js
TypeError: self.load is not a function
at C:\Users\khash\Development\gramps-project\Gramps.js\node_modules\rollup-plugin-import-assertions\src\index.js:143:16
at runMicrotasks (<anonymous>)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Promise.all (index 0)
at Object.transform (C:\Users\khash\Development\gramps-project\Gramps.js\node_modules\rollup-plugin-import-assertions\src\index.js:126:7)
at ModuleLoader.addModuleSource (C:\Users\khash\Development\gramps-project\Gramps.js\node_modules\rollup\dist\shared\rollup.js:19708:30)
at ModuleLoader.fetchModule (C:\Users\khash\Development\gramps-project\Gramps.js\node_modules\rollup\dist\shared\rollup.js:19761:9)
at async Promise.all (index 0)
at ModuleLoader.fetchStaticDependencies (C:\Users\khash\Development\gramps-project\Gramps.js\node_modules\rollup\dist\shared\rollup.js:19792:34)
at async Promise.all (index 0)
My package.json
build command:
"scripts": {
"lint:eslint": "eslint --ext .js,.html . --ignore-path .gitignore",
"format:eslint": "eslint --ext .js,.html . --fix --ignore-path .gitignore",
"lint:prettier": "prettier \"**/*.js\" --check --ignore-path .gitignore",
"format:prettier": "prettier \"**/*.js\" --write --ignore-path .gitignore",
"lint": "npm run lint:eslint && npm run lint:prettier",
"format": "npm run format:eslint && npm run format:prettier",
"build": "rollup -c rollup.config.js",
"start": "web-dev-server --app-index index.html --node-resolve --open --watch"
}
And here is my rollup.config.js
import merge from 'deepmerge'
import copy from 'rollup-plugin-copy'
import { createSpaConfig } from '@open-wc/building-rollup'
import importAssertions from 'rollup-plugin-import-assertions'
import replace from '@rollup/plugin-replace'
const API_URL = (process.env.API_URL === undefined)
? ''
: process.env.API_URL
const BASE_DIR = (process.env.BASE_DIR === undefined)
? ''
: process.env.BASE_DIR
const baseConfig = createSpaConfig({
developmentMode: process.env.ROLLUP_WATCH === 'true',
injectServiceWorker: true,
workbox: {
navigateFallbackDenylist: [/^\/api.*/],
skipWaiting: false,
clientsClaim: false
},
html: {
transform: [
(html) =>
html.replace(
'<base href="/">',
`<base href="${BASE_DIR}/">`
)
]
}
})
export default merge(baseConfig, {
input: './index.html',
plugins: [
copy({
targets: [
{ src: './leaflet.css', dest: 'dist/' },
{ src: './manifest.json', dest: 'dist/' },
{ src: './images/**/*', dest: 'dist/images' },
{
src: 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm',
dest: 'dist/'
},
{
src: 'node_modules/@hpcc-js/wasm/dist/graphvizlib.wasm',
dest: 'dist/@hpcc-js/wasm'
},
{
src: 'node_modules/@hpcc-js/wasm/dist/index.min.js',
dest: 'dist/@hpcc-js/wasm'
}
]
}),
replace({
'http://localhost:5555': API_URL,
BASE_DIR: JSON.stringify(BASE_DIR),
preventAssignment: true
}),
importAssertions()
]
})
Current version is not compliant with latest rollup
At the moment, there is an issue with the dependency (acorn-import-assertions). So we need to depend on a fork implementing a fix instead.
However, once the above-mentioned issue is fixed in the main repo, we could revert back to depending on the original repo.
I'm using rollup-plugin-import-assertions to parse CSS files as CSSStyleSheet, but I noticed that comments in the CSS files are included as strings in the resulting CSSStyleSheet object. However, even with terser, the resulting files still contain the comments.This increases the file size.
It would be great if there was an option to remove comments when parsing CSS files as CSSStyleSheet. This would make the resulting CSSStyleSheet object smaller.
Is it possible to add such an option to rollup-plugin-import-assertions?
Thank you!
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.