GithubHelp home page GithubHelp logo

acorn-import-attributes's People

Contributors

dnalborczyk avatar henriksjostrom avatar kirjavascript avatar marvinhagemeister avatar nicolo-ribaudo avatar paulrrogers avatar riywo avatar xtuc avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

acorn-import-attributes's Issues

Build failed for V1.9.2

Hello,

Could you fix the build so the new version with the hardcoded test262 dependency can we published to npm?

Thanks

TypeScript declaration

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.

License file?

I don't see any license file. Can one added to the repository?

Syntax error when used with rollup's `this.parse` function

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)

image

Using via esm leads to acorn import error

Error

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.

Reproduction

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

Suggestion

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: Package.json Reference To Non-NPM Package: "test262"

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 package.json, at least to satisfy audits? [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.]

allow to customize `keyword`

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

Parsing error when parsing reexport statement that exports a specifier that is not a valid identifier

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.