xtuc / acorn-import-attributes Goto Github PK
View Code? Open in Web Editor NEWSupport for import assertions in acorn
License: MIT License
Support for import assertions in acorn
License: MIT License
Hello,
Could you fix the build so the new version with the hardcoded test262 dependency can we published to npm?
Thanks
5f4e814 introduced charcodes package. To avoid distributing the code / optimising we can run https://github.com/xtuc/charcodes/tree/master/packages/babel-plugin-transform-charcodes to transpile them away.
I'm trying to use this package in a Rollup config that's written in TypeScript (rollup.config.ts
). This leads to an error during import { importAssertions } from 'acorn-import-assertions'
because there are no type definitions for this package. DefinitelyTyped doesn't have any yet, either.
Would you be okay with adding type definitions directly to this package? I think writing the following index.d.ts
would suffice:
import { Parser } from 'acorn'
export function importAssertions (BaseParser: typeof Parser): typeof Parser
Along with the required changes to package.json
to include this new file in the NPM package, and setting "types": "index.d.ts"
so that TS can find this declaration.
I'd be willing to make a PR containing all required changes.
I don't see any license file. Can one added to the repository?
See this issue repro for reference: https://stackblitz.com/edit/rollup-repro-fbdojc?file=package.json
Issue originally posted at: rollup/rollup#4813
Given the following source code:
import styleSheet from './styles.css' assert { type: 'css' };
console.log(styleSheet);
When trying to parse this source code from a rollup plugin, e.g.:
export default {
input: 'index.js',
output: {
dir: 'dist',
format: 'es',
},
plugins: [
{
transform(code, id) {
this.parse(code);
}
}
],
};
I get the following error:
[!] (plugin at position 1) SyntaxError: Unexpected token (1:5)
Hi,
Could you document how to port from old name ?
Thanks
In "real" esm you get this error message
import _acorn from "acorn";
^^^^^^
SyntaxError: The requested module 'acorn' does not provide an export named 'default'
which is true as acorn
only has named exports
// node_modules/acorn/dist/acorn.mjs
export { Node, Parser, Position, SourceLocation, TokContext, Token, TokenType, defaultOptions, getLineInfo, isIdentifierChar, isIdentifierStart, isNewLine, keywords$1 as keywordTypes, lineBreak, lineBreakG, nonASCIIwhitespace, parse, parseExpressionAt, types$1 as tokContexts, types as tokTypes, tokenizer, version };
I assume it keeps working with cjs as it's always an object by default.
I created a reproduction here
https://github.com/daKmoR/acorn-import-assertions-esm-bug
git clone https://github.com/daKmoR/acorn-import-assertions-esm-bug.git
cd acorn-import-assertions-esm-bug
npm i
npm run build
it can probably be solved via
- import _acorn from "acorn";
+ import * as _acorn from "acorn";
in https://github.com/xtuc/acorn-import-assertions/blob/main/src/index.js#L1
Security tools dislike references to packages not defined in the public NPM repo because of the risk someone could squat them and intercept installation attempts to inject naughty code.
Is that package still needed? Has it perhaps been renamed? If hosted elsewhere can that be defined in the [EDIT: Now I see the package source is defined, albeit implicitly via GitHub, perhaps that needs to be full URL or must be the public NPM.]package.json
, at least to satisfy audits?
Will be great to allow setup keyword
on different names, in webpack we need support assert
and with
together for compatibility, yes we can use old acorn-import-asse
package, but there is a problem - no bugs fixes in acorn-import-assertions
, because it was renamed
/cc @xtuc
Hi,
Could you deprecate old name
https://docs.npmjs.com/cli/v10/commands/npm-deprecate
Originally reported here but then I realized that the error was only thrown when this plugin was used
Repro
const { Parser } = require('acorn')
const { importAssertions } = require('acorn-import-assertions')
Parser
.extend(importAssertions)
.parse(`export * as '๐' from 'external'`, { sourceType: 'module', ecmaVersion: 'latest' })
Actual
Uncaught [SyntaxError: Unexpected token (1:12)
] {
pos: 12,
loc: Position { line: 1, column: 12 },
raisedAt: 15
}
Expected
It should parse this input correctly
How can I find the license file of [@acorn-import-assertions 1.8.0] . Master license is available, but I am looking for the specific these one.
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.